From: Nathan Ward Date: Fri, 11 Jan 2019 03:13:35 +0000 (+1300) Subject: Add SKIP LOCKED variations of sqlippool allocate_find queries as options. X-Git-Tag: release_3_0_18~93^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b01c326516214bfb4bc5dff34613983af6744072;p=thirdparty%2Ffreeradius-server.git Add SKIP LOCKED variations of sqlippool allocate_find queries as options. --- diff --git a/raddb/mods-config/sql/ippool/mysql/queries.conf b/raddb/mods-config/sql/ippool/mysql/queries.conf index 157ea96738f..804a05c29ec 100644 --- a/raddb/mods-config/sql/ippool/mysql/queries.conf +++ b/raddb/mods-config/sql/ippool/mysql/queries.conf @@ -49,6 +49,21 @@ allocate_find = "\ LIMIT 1 \ FOR UPDATE" +# +# The above query again, but with SKIP LOCKED. This requires MySQL >= 8.0.1, +# and InnoDB. +# +#allocate_find = "\ +# SELECT framedipaddress FROM ${ippool_table} \ +# WHERE pool_name = '%{control:${pool_name}}' \ +# AND (expiry_time < NOW() OR expiry_time IS NULL) \ +# ORDER BY \ +# (username <> '%{User-Name}'), \ +# (callingstationid <> '%{Calling-Station-Id}'), \ +# expiry_time \ +# LIMIT 1 \ +# FOR UPDATE SKIP LOCKED" + # # If you prefer to allocate a random IP address every time, use this query instead. # @@ -61,6 +76,19 @@ allocate_find = "\ # LIMIT 1 \ # FOR UPDATE" +# +# The above query again, but with SKIP LOCKED. This requires MySQL >= 8.0.1, +# and InnoDB. +# +#allocate_find = "\ +# SELECT framedipaddress FROM ${ippool_table} \ +# WHERE pool_name = '%{control:${pool_name}}' \ +# AND expiry_time IS NULL \ +# ORDER BY \ +# RAND() \ +# LIMIT 1 \ +# FOR UPDATE SKIP LOCKED" + # # If an IP could not be allocated, check to see if the pool exists or not # This allows the module to differentiate between a full pool and no pool diff --git a/raddb/mods-config/sql/ippool/oracle/queries.conf b/raddb/mods-config/sql/ippool/oracle/queries.conf index 8a94e369c90..6f08bfad2ee 100644 --- a/raddb/mods-config/sql/ippool/oracle/queries.conf +++ b/raddb/mods-config/sql/ippool/oracle/queries.conf @@ -28,6 +28,22 @@ allocate_find = "\ expiry_time \ FOR UPDATE" +# +# The above query again, but with SKIP LOCKED. This requires Oracle > 11g. +# It may work in 9i and 10g, but is not documented, so YMMV. +# +#allocate_find = "\ +# SELECT framedipaddress \ +# FROM ${ippool_table} \ +# WHERE pool_name = '%{control:${pool_name}}' \ +# AND expiry_time < current_timestamp \ +# AND rownum <= 1 \ +# ORDER BY \ +# (username <> '%{SQL-User-Name}'), \ +# (callingstationid <> '%{Calling-Station-Id}'), \ +# expiry_time \ +# FOR UPDATE SKIP LOCKED" + # # This function is available if you want to use multiple pools # @@ -47,6 +63,19 @@ allocate_find = "\ # ORDER BY RANDOM() \ # FOR UPDATE" +# +# The above query again, but with SKIP LOCKED. This requires Oracle > 11g. +# It may work in 9i and 10g, but is not documented, so YMMV. +# +#allocate_find = "\ +# SELECT framedipaddress \ +# FROM ${ippool_table} \ +# WHERE pool_name = '%{control:${pool_name}}' \ +# AND expiry_time < current_timestamp \ +# AND rownum <= 1 \ +# ORDER BY RANDOM() \ +# FOR UPDATE SKIP LOCKED" + # # If an IP could not be allocated, check to see whether the pool exists or not # This allows the module to differentiate between a full pool and no pool diff --git a/raddb/mods-config/sql/ippool/postgresql/queries.conf b/raddb/mods-config/sql/ippool/postgresql/queries.conf index 81856249889..f7942072cb2 100644 --- a/raddb/mods-config/sql/ippool/postgresql/queries.conf +++ b/raddb/mods-config/sql/ippool/postgresql/queries.conf @@ -21,6 +21,21 @@ allocate_find = "\ LIMIT 1 \ FOR UPDATE" +# +# The above query again, but with SKIP LOCKED. This requires PostgreSQL >= 9.5. +# +#allocate_find = "\ +# SELECT framedipaddress \ +# FROM ${ippool_table} \ +# WHERE pool_name = '%{control:${pool_name}}' \ +# AND expiry_time < 'now'::timestamp(0) \ +# ORDER BY \ +# (username <> '%{SQL-User-Name}'), \ +# (callingstationid <> '%{Calling-Station-Id}'), \ +# expiry_time \ +# LIMIT 1 \ +# FOR UPDATE SKIP LOCKED" + # # If you prefer to allocate a random IP address every time, use this query instead # @@ -31,6 +46,16 @@ allocate_find = "\ LIMIT 1 \ FOR UPDATE" +# +# The above query again, but with SKIP LOCKED. This requires PostgreSQL >= 9.5. +# +#allocate_find = "\ +# SELECT framedipaddress FROM ${ippool_table} \ +# WHERE pool_name = '%{control:${pool_name}}' AND expiry_time < 'now'::timestamp(0) \ +# ORDER BY RANDOM() \ +# LIMIT 1 \ +# FOR UPDATE SKIP LOCKED" + # # If an IP could not be allocated, check to see whether the pool exists or not # This allows the module to differentiate between a full pool and no pool