From: Arran Cudbard-Bell Date: Wed, 31 May 2023 23:22:40 +0000 (-0400) Subject: set pool max default internally X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c569503b94b4135fc457191ffbf66be3f12f00de;p=thirdparty%2Ffreeradius-server.git set pool max default internally --- diff --git a/doc/antora/modules/raddb/pages/mods-available/cache.adoc b/doc/antora/modules/raddb/pages/mods-available/cache.adoc index cabfd100ab9..a5d7d16d2dc 100644 --- a/doc/antora/modules/raddb/pages/mods-available/cache.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/cache.adoc @@ -324,9 +324,9 @@ cache { # memcached { # options = "--SERVER=localhost" # pool { -# start = ${thread[pool].num_workers} -# min = ${thread[pool].num_workers} -# max = ${thread[pool].num_workers} +# start = 0 +# min = 0 +# max = # spare = 1 # uses = 0 # lifetime = 0 @@ -339,9 +339,9 @@ cache { # password = 'supersecret' # database = 0 # pool { -# start = ${thread[pool].num_workers} -# min = ${thread[pool].num_workers} -# max = ${thread[pool].num_workers} +# start = 0 +# min = 0 +# max = # spare = 1 # uses = 0 # lifetime = 0 diff --git a/doc/antora/modules/raddb/pages/mods-available/couchbase.adoc b/doc/antora/modules/raddb/pages/mods-available/couchbase.adoc index 1db9493b3d5..94c427161d5 100644 --- a/doc/antora/modules/raddb/pages/mods-available/couchbase.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/couchbase.adoc @@ -243,9 +243,9 @@ couchbase { } } pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 lifetime = 0 diff --git a/doc/antora/modules/raddb/pages/mods-available/cui.adoc b/doc/antora/modules/raddb/pages/mods-available/cui.adoc index e0e2b4881bf..9ecf23912d5 100644 --- a/doc/antora/modules/raddb/pages/mods-available/cui.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/cui.adoc @@ -93,7 +93,7 @@ sql cuisql { pool { start = 5 min = 4 - max = 10 +# max = spare = 3 uses = 0 lifetime = 0 diff --git a/doc/antora/modules/raddb/pages/mods-available/krb5.adoc b/doc/antora/modules/raddb/pages/mods-available/krb5.adoc index 2c45a6eb1dd..1fe4b1407d2 100644 --- a/doc/antora/modules/raddb/pages/mods-available/krb5.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/krb5.adoc @@ -134,9 +134,9 @@ krb5 { keytab = /path/to/keytab service_principal = name_of_principle pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 lifetime = 0 diff --git a/doc/antora/modules/raddb/pages/mods-available/ldap.adoc b/doc/antora/modules/raddb/pages/mods-available/ldap.adoc index e5c6d15bc09..ac8226390d9 100644 --- a/doc/antora/modules/raddb/pages/mods-available/ldap.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/ldap.adoc @@ -849,9 +849,9 @@ ldap { # tls_min_version = "1.2" } pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 retry_delay = 30 diff --git a/doc/antora/modules/raddb/pages/mods-available/linelog.adoc b/doc/antora/modules/raddb/pages/mods-available/linelog.adoc index 4deaf5b5d00..ef6a592a872 100644 --- a/doc/antora/modules/raddb/pages/mods-available/linelog.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/linelog.adoc @@ -354,9 +354,9 @@ linelog { escape_filenames = no } pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 retry_delay = 30 diff --git a/doc/antora/modules/raddb/pages/mods-available/mschap.adoc b/doc/antora/modules/raddb/pages/mods-available/mschap.adoc index f255c8a9131..fbf8f356a5c 100644 --- a/doc/antora/modules/raddb/pages/mods-available/mschap.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/mschap.adoc @@ -341,9 +341,9 @@ mschap { # retry_with_normalised_username = no } pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 retry_delay = 30 diff --git a/doc/antora/modules/raddb/pages/mods-available/redis.adoc b/doc/antora/modules/raddb/pages/mods-available/redis.adoc index 641760e43fd..32ca313158b 100644 --- a/doc/antora/modules/raddb/pages/mods-available/redis.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/redis.adoc @@ -153,9 +153,9 @@ redis { port = 6379 # password = thisisreallysecretandhardtoguess pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 retry_delay = 30 diff --git a/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc b/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc index 60138f5627c..2f3237d3e32 100644 --- a/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc @@ -157,8 +157,8 @@ redis_ippool { server = localhost pool { start = 0 - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + min = 0 +# max = spare = 1 uses = 0 lifetime = 0 diff --git a/doc/antora/modules/raddb/pages/mods-available/sql.adoc b/doc/antora/modules/raddb/pages/mods-available/sql.adoc index e99707b61a8..bfeed9af1a9 100644 --- a/doc/antora/modules/raddb/pages/mods-available/sql.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/sql.adoc @@ -316,9 +316,9 @@ sql { # logfile = ${logdir}/sqllog.sql # query_timeout = 5 pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 retry_delay = 30 diff --git a/doc/antora/modules/raddb/pages/mods-available/winbind.adoc b/doc/antora/modules/raddb/pages/mods-available/winbind.adoc index ef245e1e43a..35ec04ee976 100644 --- a/doc/antora/modules/raddb/pages/mods-available/winbind.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/winbind.adoc @@ -164,9 +164,9 @@ winbind { # attribute = "Winbind-Group" } pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = spare = 1 uses = 0 retry_delay = 30 diff --git a/doc/antora/modules/raddb/pages/mods-available/yubikey.adoc b/doc/antora/modules/raddb/pages/mods-available/yubikey.adoc index b86fae593f0..d4053f06dfe 100644 --- a/doc/antora/modules/raddb/pages/mods-available/yubikey.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/yubikey.adoc @@ -274,9 +274,9 @@ yubikey { # client_id = 00000 # api_key = '000000000000000000000000' pool { - start = ${thread[pool].num_workers} - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = uses = 0 retry_delay = 30 lifetime = 86400 diff --git a/doc/antora/modules/raddb/pages/radclient.conf.adoc b/doc/antora/modules/raddb/pages/radclient.conf.adoc index d3f5425e36a..f036d165502 100644 --- a/doc/antora/modules/raddb/pages/radclient.conf.adoc +++ b/doc/antora/modules/raddb/pages/radclient.conf.adoc @@ -38,9 +38,9 @@ radius { secret = $ENV{RADCLIENT_SECRET} } pool { - start = 1 - min = 1 - max = 1 + start = 0 + min = 0 +# max = } } } diff --git a/raddb/mods-available/cache b/raddb/mods-available/cache index cb30f6b2442..bb669527465 100644 --- a/raddb/mods-available/cache +++ b/raddb/mods-available/cache @@ -77,8 +77,8 @@ cache { # # pool { # start = 0 -# min = ${thread[pool].num_workers} -# max = ${thread[pool].num_workers} +# min = 0 +# max = # spare = 1 # uses = 0 # lifetime = 0 @@ -131,9 +131,9 @@ cache { # pool:: Connection pool. # # pool { -# start = 0 -# min = ${thread[pool].num_workers} -# max = ${thread[pool].num_workers} + start = 0 + min = 0 +# max = # spare = 1 # uses = 0 # lifetime = 0 diff --git a/raddb/mods-available/couchbase b/raddb/mods-available/couchbase index 014a53ffd82..f9949a8918b 100644 --- a/raddb/mods-available/couchbase +++ b/raddb/mods-available/couchbase @@ -175,17 +175,18 @@ couchbase { pool { # # start:: Connections to create during module instantiation. - # If the server cannot create specified number of connections - # during instantiation it will exit. - # Set to `0` to allow the server to start without the couchbase - # being available. + # + # If the server cannot create specified number of + # connections during instantiation it will exit. + # Set to `0` to allow the server to start without the + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -193,14 +194,17 @@ couchbase { # If these connections are all in use and a new one # is requested, the request will NOT get a connection. # - # Setting `max` to LESS than the number of threads means + # Setting `max` to *LESS* than the number of threads means # that some threads may starve, and you will see errors - # like '_No connections available and at max connection limit_' + # like _No connections available and at max connection limit_. # # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/krb5 b/raddb/mods-available/krb5 index 93dea30f4b0..9c8878d6aa4 100644 --- a/raddb/mods-available/krb5 +++ b/raddb/mods-available/krb5 @@ -44,14 +44,14 @@ krb5 { # If the server cannot create specified number of # connections during instantiation it will exit. # Set to `0` to allow the server to start without the - # KDC being available. + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -66,7 +66,10 @@ krb5 { # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/linelog b/raddb/mods-available/linelog index 342c7b96afe..4b2ed19247d 100644 --- a/raddb/mods-available/linelog +++ b/raddb/mods-available/linelog @@ -159,20 +159,19 @@ linelog { # pool { # - # start:: + # start:: Connections to create during module instantiation. # - # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. - # Set to 0 to allow the server to `start` without the - # web service being available. + # Set to `0` to allow the server to start without the + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -180,14 +179,17 @@ linelog { # If these connections are all in use and a new one # is requested, the request will NOT get a connection. # - # Setting `max` to LESS than the number of threads means + # Setting `max` to *LESS* than the number of threads means # that some threads may starve, and you will see errors - # like 'No connections available and at `max` connection limit' + # like _No connections available and at max connection limit_. # # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/mschap b/raddb/mods-available/mschap index 1eb1af492e5..99febfb9743 100644 --- a/raddb/mods-available/mschap +++ b/raddb/mods-available/mschap @@ -201,22 +201,19 @@ mschap { # pool { # - # start:: + # start:: Connections to create during module instantiation. # - # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. - # Set to 0 to allow the server to start without the - # winbind daemon being available. + # Set to `0` to allow the server to start without the + # external service being available. # start = 0 # - # min:: + # min:: Minimum number of connections to keep open. # - # Minimum number of connections to keep open. - # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -224,14 +221,17 @@ mschap { # If these connections are all in use and a new one # is requested, the request will NOT get a connection. # - # Setting `max` to LESS than the number of threads means + # Setting `max` to *LESS* than the number of threads means # that some threads may starve, and you will see errors - # like 'No connections available and at max connection limit' + # like _No connections available and at max connection limit_. # # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/redis b/raddb/mods-available/redis index 38d53f361fb..f8983c05cb1 100644 --- a/raddb/mods-available/redis +++ b/raddb/mods-available/redis @@ -103,18 +103,18 @@ redis { pool { # # start:: Connections to create during module instantiation. - # If the server cannot create specified number of connections - # during instantiation it will exit. # - # Set to `0` to allow the server to start without the web service - # being available. + # If the server cannot create specified number of + # connections during instantiation it will exit. + # Set to `0` to allow the server to start without the + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -122,14 +122,17 @@ redis { # If these connections are all in use and a new one # is requested, the request will NOT get a connection. # - # Setting `max` to LESS than the number of threads means + # Setting `max` to *LESS* than the number of threads means # that some threads may starve, and you will see errors - # like 'No connections available and at max connection limit' + # like _No connections available and at max connection limit_. # # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/redis_ippool b/raddb/mods-available/redis_ippool index 646e4925ea3..5f55236e75b 100644 --- a/raddb/mods-available/redis_ippool +++ b/raddb/mods-available/redis_ippool @@ -156,8 +156,8 @@ redis_ippool { pool { start = 0 - min = ${thread[pool].num_workers} - max = ${thread[pool].num_workers} + min = 0 +# max = 1 spare = 1 uses = 0 lifetime = 0 diff --git a/raddb/mods-available/sql b/raddb/mods-available/sql index 3fde3f1a27f..06290b188ec 100644 --- a/raddb/mods-available/sql +++ b/raddb/mods-available/sql @@ -224,31 +224,35 @@ sql { # # start:: Connections to create during module instantiation. # - # If the server cannot create specified number of connections during instantiation - # it will exit. - # - # Set to `0` to allow the server to start without the database being available. + # If the server cannot create specified number of + # connections during instantiation it will exit. + # Set to `0` to allow the server to start without the + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. # - # If these connections are all in use and a new one is requested, the request - # will NOT get a connection. + # If these connections are all in use and a new one + # is requested, the request will NOT get a connection. + # + # Setting `max` to *LESS* than the number of threads means + # that some threads may starve, and you will see errors + # like _No connections available and at max connection limit_. # - # Setting `max` to LESS than the number of threads means that some threads may starve, - # and you will see errors like _No connections available and at max connection limit_. + # Setting `max` to MORE than the number of threads means + # that there are more connections than necessary. # - # Setting `max` to MORE than the number of threads means that there are more - # connections than necessary. + # If `max` is not specified, then it defaults to the number + # of workers configured. # - max = ${thread[pool].num_workers} +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/winbind b/raddb/mods-available/winbind index f4adff658ca..41b1e818dc7 100644 --- a/raddb/mods-available/winbind +++ b/raddb/mods-available/winbind @@ -81,21 +81,19 @@ winbind { # pool { # - # start:: + # start:: Connections to create during module instantiation. # - # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. - # # Set to `0` to allow the server to start without the - # winbind daemon being available. + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -103,14 +101,17 @@ winbind { # If these connections are all in use and a new one # is requested, the request will NOT get a connection. # - # Setting `max` to LESS than the number of threads means + # Setting `max` to *LESS* than the number of threads means # that some threads may starve, and you will see errors - # like 'No connections available and at max connection limit' + # like _No connections available and at max connection limit_. # # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # spare:: Spare connections to be left idle. diff --git a/raddb/mods-available/yubikey b/raddb/mods-available/yubikey index 50431889f26..aa7cba2766d 100644 --- a/raddb/mods-available/yubikey +++ b/raddb/mods-available/yubikey @@ -170,21 +170,19 @@ yubikey { # pool { # - # start:: + # start:: Connections to create during module instantiation. # - # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. - # # Set to `0` to allow the server to start without the - # winbind daemon being available. + # external service being available. # start = 0 # # min:: Minimum number of connections to keep open. # - min = ${thread[pool].num_workers} + min = 0 # # max:: Maximum number of connections. @@ -192,15 +190,17 @@ yubikey { # If these connections are all in use and a new one # is requested, the request will NOT get a connection. # - # Setting `max` to LESS than the number of threads means + # Setting `max` to *LESS* than the number of threads means # that some threads may starve, and you will see errors - # like 'No connections available and at max connection limit' + # like _No connections available and at max connection limit_. # # Setting `max` to MORE than the number of threads means # that there are more connections than necessary. # - max = ${thread[pool].num_workers} - + # If `max` is not specified, then it defaults to the number + # of workers configured. + # +# max = # # uses:: Number of uses before the connection is closed. # diff --git a/src/lib/server/pool.c b/src/lib/server/pool.c index 26bcf6adfa6..7800eafc14f 100644 --- a/src/lib/server/pool.c +++ b/src/lib/server/pool.c @@ -39,6 +39,7 @@ RCSID("$Id$") typedef struct fr_pool_connection_s fr_pool_connection_t; static int connection_check(fr_pool_t *pool, request_t *request); +static int max_dflt(CONF_PAIR **out, void *parent, CONF_SECTION *cs, fr_token_t quote, CONF_PARSER const *rule); /** An individual connection within the connection pool * @@ -150,7 +151,7 @@ struct fr_pool_s { static const CONF_PARSER pool_config[] = { { FR_CONF_OFFSET("start", FR_TYPE_UINT32, fr_pool_t, start), .dflt = "5" }, { FR_CONF_OFFSET("min", FR_TYPE_UINT32, fr_pool_t, min), .dflt = "5" }, - { FR_CONF_OFFSET("max", FR_TYPE_UINT32, fr_pool_t, max), .dflt = "10" }, + { FR_CONF_OFFSET("max", FR_TYPE_UINT32, fr_pool_t, max), .dflt_func = max_dflt }, { FR_CONF_OFFSET("max_pending", FR_TYPE_UINT32, fr_pool_t, max_pending), .dflt = "0" }, { FR_CONF_OFFSET("spare", FR_TYPE_UINT32, fr_pool_t, spare), .dflt = "3" }, { FR_CONF_OFFSET("uses", FR_TYPE_UINT64, fr_pool_t, max_uses), .dflt = "0" }, @@ -165,6 +166,17 @@ static const CONF_PARSER pool_config[] = { CONF_PARSER_TERMINATOR }; +static int max_dflt(CONF_PAIR **out, UNUSED void *parent, CONF_SECTION *cs, fr_token_t quote, CONF_PARSER const *rule) +{ + char *strvalue; + + strvalue = talloc_asprintf(NULL, "%u", main_config->max_workers); + *out = cf_pair_alloc(cs, rule->name, strvalue, T_OP_EQ, T_BARE_WORD, quote); + talloc_free(strvalue); + + return 0; +} + /** Order connections by reserved most recently */ static int8_t last_reserved_cmp(void const *one, void const *two)