Skip to content

Commit

Permalink
remove (mostly) duplicate configs.
Browse files Browse the repository at this point in the history
It's better to define `skip_locked = "SKIP LOCKED"` once,
and then use it where necessary.  Otherwise, we get near-infinite
variations of the same queries
  • Loading branch information
alandekok committed Jan 11, 2019
1 parent e747671 commit f70ab48
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 44 deletions.
2 changes: 2 additions & 0 deletions raddb/mods-config/files/authorize
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bob Cleartext-Password := "bob"

#
# Configuration file for the rlm_files module.
# Please see rlm_files(5) manpage for more information.
Expand Down
25 changes: 8 additions & 17 deletions raddb/mods-config/sql/ippool/mysql/queries.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
# users to keep old addresses after outages
#

# Using SKIP LOCKED speed up the allocate_find query by 10
# times. However, it requires MySQL >= 8.0.1, and InnoDB.
#
# Uncomment the next line to automatically use SKIP LOCKED
#skip_locked = "SKIP LOCKED"

#
# allocate_clear clears stale IP addresses before processing a new request
#
Expand Down Expand Up @@ -89,22 +95,7 @@ allocate_find = "\
(callingstationid <> '%{Calling-Station-Id}'), \
expiry_time \
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"
FOR UPDATE ${skip_locked}"

#
# If you prefer to allocate a random IP address every time, use this query instead.
Expand All @@ -117,7 +108,7 @@ allocate_find = "\
# ORDER BY \
# RAND() \
# LIMIT 1 \
# FOR UPDATE"
# FOR UPDATE ${skip_locked}"

#
# The above query again, but with SKIP LOCKED. This requires MySQL >= 8.0.1,
Expand Down
35 changes: 8 additions & 27 deletions raddb/mods-config/sql/ippool/postgresql/queries.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#
# $Id$

# Using SKIP LOCKED speed up the allocate_find query by 10
# times. However, it requires PostgreSQL >= 9.5.
#
# Uncomment the next line to automatically use SKIP LOCKED
#skip_locked = "SKIP LOCKED"

#
# This query allocates an IP address from the Pool
# The ORDER BY clause of this query tries to allocate the same IP-address
Expand All @@ -19,22 +25,7 @@ allocate_find = "\
(callingstationid <> '%{Calling-Station-Id}'), \
expiry_time \
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"
FOR UPDATE ${skip_locked}"

#
# If you prefer to allocate a random IP address every time, use this query instead
Expand All @@ -45,17 +36,7 @@ allocate_find = "\
# WHERE pool_name = '%{control:${pool_name}}' AND expiry_time < 'now'::timestamp(0) \
# ORDER BY RANDOM() \
# 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"
# FOR UPDATE ${skip_locked}"

#
# If an IP could not be allocated, check to see whether the pool exists or not
Expand Down

0 comments on commit f70ab48

Please sign in to comment.