]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add SKIP LOCKED variations of sqlippool allocate_find queries as options.
authorNathan Ward <nward@braintrust.co.nz>
Fri, 11 Jan 2019 03:13:35 +0000 (16:13 +1300)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 11 Jan 2019 10:50:11 +0000 (18:50 +0800)
# Conflicts:
# raddb/mods-config/sql/ippool/mysql/queries.conf

raddb/mods-config/sql/ippool/mysql/queries.conf
raddb/mods-config/sql/ippool/oracle/queries.conf
raddb/mods-config/sql/ippool/postgresql/queries.conf

index 8dbfb0453528dd5e28672914e202b5502790eb72..5ffd74eed8bb3c14e194b630dc2ce0d3c5cd29d3 100644 (file)
@@ -91,6 +91,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.
 #
@@ -103,11 +118,25 @@ 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"
 
 #
 #  pool_check allows the module to differentiate between a full pool
 #  and no pool when an IP address could not be allocated so an appropriate
 #  error message can be returned.
+#
+
 #
 #  Note: If you are not running redundant pool modules this query may be
 #  commented out as it provides no additional information in that case.
index ad74651578da5656efde3296a4a200ad2d21df1f..3660d55a9d6966f32a7e367372c53b394500c3c1 100644 (file)
@@ -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
index b08bcd7af666dc1e4326d67a9ce6c3b0873e0969..00e3a528c1136d00de1f955fb7797dfdd79e7b65 100644 (file)
@@ -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