You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sqllogfill: auto-disable when master cannot service log requests
When all of the master's sql engines are busy and its dispatch queue is
full, the master rejects the logfill's comdb2_transaction_logs() request.
Previously the logfill thread would just disconnect, sleep, and hammer the
already-saturated master again indefinitely -- and because send_rep_all_req/
send_rep_log_req are suppressed while sql_logfill is active, the gap could
not close via normal replication either.
Mirror the existing auth-failure autodisable precedent: count consecutive
failed log requests and set gbl_sql_logfill_auto_disabled once they reach
gbl_sql_logfill_request_fail_autodisable_threshold (default 5; a value <= 0
disables the behavior). Once disabled, sql_logfill_active() returns false and
the db falls back to the traditional fill-request path.
The master's reject is delivered as CDB2ERR_REJECTED, but that code is
retryable: the cdb2 client retries it internally and -- for our
CDB2_DIRECT_CPU handle with min_retries==1 -- surfaces it as
CDB2ERR_CONNECT_ERROR (or CDB2ERR_TRAN_IO_ERROR), not CDB2ERR_REJECTED, so we
key off the codes actually returned. Those same codes are also what an
unreachable master produces: cdb2_open() does not connect for a DIRECT_CPU
handle (and "set transaction blocksql" is a client-side set), so the first
real round-trip -- the "select 1" ping in connect_to_master -- is where an
unreachable master surfaces, and it is a counting site. We deliberately do not
distinguish "reachable but saturated" from "unreachable": both mean logfill
cannot get logs from the master, and falling back to normal replication is the
right response either way.
Spurious trips are avoided not by inspecting the error but by (1) returning
early WITHOUT counting when there is no elected master (thedb->master unset or
".invalid"), which covers ordinary elections and outages, and (2) resetting the
counters the moment we reach the master and make progress (a successful fetch,
or confirming there is no gap), so only a sustained run of failures against a
still-elected master reaches the threshold.
Auto-disable now parks the logfill threads instead of terminating them:
clearing gbl_sql_logfill_auto_disabled (no longer READONLY) resumes them (the
resuming thread logs a message), and parking resets the counters so a resume
starts with a fresh threshold.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
(name='sql_logfill_apply_thread', description='Use a dedicated thread to apply sql logfills. (Default: off)', type='BOOLEAN', value='OFF', read_only='Y')
988
-
(name='sql_logfill_auto_disabled', description='Set to 1 when sql-logfill has been auto-disabled due to consecutive failures. (Default: 0)', type='INTEGER', value='0', read_only='Y')
988
+
(name='sql_logfill_auto_disabled', description='Set to 1 when sql-logfill has been auto-disabled due to consecutive failures; clear it to 0 to resume the parked sql-logfill threads. (Default: 0)', type='INTEGER', value='0', read_only='N')
989
989
(name='sql_logfill_autodisable_threshold', description='Disable sql-logfill after this many consecutive authentication failures. (Default: 5)', type='INTEGER', value='5', read_only='N')
(name='sql_logfill_lookahead_records', description='Max lookahead records cached for dedicated apply thread. (Default: 10000)', type='INTEGER', value='10000', read_only='Y')
992
992
(name='sql_logfill_next_timeout', description='Max amount of time logfill blocked on transaction-logs. (Default: 10)', type='INTEGER', value='10', read_only='N')
993
+
(name='sql_logfill_request_fail_autodisable_threshold', description='Disable sql-logfill after this many consecutive failed log requests to a reachable master (e.g. all sql engines busy and queue full, surfaced as a connect/io error). (Default: 5)', type='INTEGER', value='5', read_only='N')
0 commit comments