FR 2.2.1 rlm_sqlippool / mysql 5.5.31 - deadlocks

George Chelidze gchelidze at magticom.ge
Tue Nov 26 09:22:49 CET 2013


On 2013-11-25 18:31, Alan DeKok wrote:
>    Looks good.  I'll commit a patch.
>
>    It should also be doing the CLEAR only once per second.  It doesn't
> make sense to do it on every FIND.  That's just unnecessary overhead.
>
>    Alan DeKok.

Hello Alan,

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?

now = time(NULL);
if (data->last_clear < now) {
     data->last_clear = now;
     ...
}

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:

SELECT framedipaddress FROM ${ippool_table} WHERE pool_name = 
'%{control:Pool-Name}' AND expiry_time IS NULL OR expiry_time <= NOW() - 
INTERVAL 1 SECOND ORDER BY RAND() LIMIT 1 FOR UPDATE

OR is inefficient here so we can change expiry_time from:

`expiry_time` datetime DEFAULT NULL

to

`expiry_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'

and later use the following query:

SELECT framedipaddress FROM ${ippool_table} WHERE pool_name = 
'%{control:Pool-Name}' AND expiry_time <= NOW() - INTERVAL 1 SECOND 
ORDER BY RAND() LIMIT 1 FOR UPDATE

Yes, I know I have covered mysql case only, but I believe the similar 
approach can be used with other databases.

BR,

-- George Chelidze Software Developer Magticom Ltd.



More information about the Freeradius-Devel mailing list