Kea with CB configured on PostgreSQL 15 cannot prepare statement
Newer PostgreSQL servers seem to be more picky about how prepared statements are formatted. Kea fails to start because of a missing space between a placeholder and the WHERE
keyword.
ERROR [kea-dhcp6.dhcp6] DHCP6_INIT_FAIL failed to initialize Kea server: configuration error using file '/etc/kea-dhcp6.conf': during update from config backend database: unable to prepare PostgreSQL statement: name: UPDATE_SUBNET6, reason: ERROR: trailing junk after parameter at or near "$33W"
LINE 1: ...threshold = cast($32 as float), cache_max_age = $33WHERE s...
This is also visible in multiple unit tests in PgSqlConfigBackendDHCPv6Test
.
[ RUN ] PgSqlConfigBackendDHCPv6Test.getType
*** ERROR: unable to open database. The test
*** environment is broken and must be fixed before
*** the tests will run correctly.
*** The reason for the problem is described in the
*** accompanying exception output.
unknown file: Failure
C++ exception with description "unable to prepare PostgreSQL statement: name: UPDATE_SUBNET6, reason: ERROR: trailing junk after parameter at or near "$33W"
LINE 1: ...threshold = cast($32 as float), cache_max_age = $33WHERE s...
^
, text: UPDATE dhcp6_subnet SET subnet_id = $1, subnet_prefix = $2, client_class = $3, interface = $4, modification_ts = $5, preferred_lifetime = $6, min_preferred_lifetime = $7, max_preferred_lifetime = $8, rapid_commit = $9, rebind_timer = $10, relay = $11, renew_timer = $12, require_client_classes = $13, reservations_global = $14, shared_network_name = $15, user_context = cast($16 as json), valid_lifetime = $17, min_valid_lifetime = $18, max_valid_lifetime = $19, calculate_tee_times = $20, t1_percent = cast($21 as float), t2_percent = cast($22 as float), interface_id = $23, ddns_send_updates = $24, ddns_override_no_update = $25, ddns_override_client_update = $26, ddns_replace_client_name = $27, ddns_generated_prefix = $28, ddns_qualifying_suffix = $29, reservations_in_subnet = $30, reservations_out_of_pool = $31, cache_threshold = cast($32 as float), cache_max_age = $33WHERE subnet_id = $34 OR subnet_prefix = $35" thrown in SetUp().
[ FAILED ] PgSqlConfigBackendDHCPv6Test.getType (249 ms)
Adding the space makes the unit tests pass.
Affected PostgreSQL versions: 15.0, 15.1.
It works properly on PostgreSQL 14.6.