George Chelidze wrote:
Feeling stupid to ask this, but shouldn't you use some kind of locking while reading/writing data->last_clear? Do you rely on atomicity of int?
Writes to "int" are atomic. Even if they're not, there's minimal cost to doing the "clear" 2-3 times. The key is to avoid doing the clear 1000 times a second.
Another questions is related to the "CLEAR" operation: do we really need to update "expired" records and then retrieve one from unassigned list? Instead we could take an address if it's unassigned or assigned but expired, something like:
Yes, that would work. The suggestion to change the expiry time to NOT NULL is a good one. Having multiple possibilities for a field causes issues. If it's always a date, it's simpler.
Yes, I know I have covered mysql case only, but I believe the similar approach can be used with other databases.
As always, patches are welcome. :) Alan DeKok.