Skip to content

fix(process): coordinate Syslog processing through the process registry instead of GET_LOCK (#479) - #495

Merged
somethingwithproof merged 3 commits into
Cacti:developfrom
somethingwithproof:fix/syslog-processing-lock-registry-479
Dec 3, 2026
Merged

somethingwithproof merged 3 commits into
Cacti:developfrom
somethingwithproof:fix/syslog-processing-lock-registry-479

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

What

Replaces the GET_LOCK()-based Syslog processing lock with Cacti's process
registry (register_process_start), and has transfer workers verify their
master by process id instead of IS_USED_LOCK().

Why (#479)

The processing lock was taken with GET_LOCK() on a dedicated connection, and
each transfer worker checked IS_USED_LOCK() on its own Syslog connection to
confirm the master still held it. Named locks are session-bound and
server-local: behind a proxy in front of a Galera cluster, the master's lock
connection and a worker's connection can land on different nodes, so the worker
sees the lock as unheld, logs "no longer holds the processing lock" and exits
without writing — the failure reported in #479.

How

  • The master's existing register_process_start('syslog', 'master', <poller_id>)
    registration is now the single-master mutex; it also excludes partition
    rebuilds, which register the same task.
  • cli/upgrade_partitioning.php and on-demand table repair in
    includes/schema.php now coordinate through register_process_start(...)
    instead of GET_LOCK(syslog_processing_lock_name()).
  • Workers receive --master-pid instead of --lock-owner and verify the
    master with syslog_processing_master_alive() (a local
    cacti_process_still_running() check), which does not depend on which node a
    connection is routed to. The syslog_processing_lock_* helpers are removed.
  • The failure-stat recording and worker unregistration fix(process): stop waiting out the worker registration window (#479) #494 added are kept.

Relationship to #494

This stacks on #494 (fix/worker-wait-exited-479): its commits appear in
this PR's diff until #494 merges, then rebase away. This change supersedes the
lock mechanism #494 improves, so the two overlap — merge order is yours; I
have not touched the #494 branch.

Correctness caveat (for your call)

Cacti's processes table is ENGINE=MEMORY (node-local), so this change
removes the session-lock fragility and adopts the idiomatic registry plus a
local pid check — the right fix for #479 as reported. It does not by itself
give true cross-node HA for the registration rows; genuine multi-node
coordination would want the InnoDB process_locks primitive. Flagging it so you
can decide whether #479's scope stops at the session-lock fix or should go
further.

Tests

  • Added tests/Unit/ProcessingRegistryTest.php; removed ProcessingLockTest.php.
  • Updated PartitionRebuildTest.php and the two tests/regression/* harnesses
    from the lock to the registry.
  • Full plugin Unit/Security suite: 897 passed (1 pre-existing unrelated
    macOS /proc warning). The two live-DB regression scripts were adapted and
    lint-clean but need a MariaDB server to execute.

TheWitness and others added 3 commits December 3, 2026 00:19
)

syslog_wait_workers() held the master in its registration stage until
every launched worker was registered and running. Workers that had
already finished, or exited because the processing lock check failed,
were never counted, so each parallel phase waited the full ten seconds.
A worker now counts once it is registered or has recorded statistics,
read from the settings table rather than the read_config_option() cache,
and the completion check uses the same fresh read.

A worker that finds the processing lock no longer held by its master
records a failed statistics row so the master stops waiting, and logs
the expected owner and the holder IS_USED_LOCK() reported.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review on Cacti#494. A child of an earlier run could report after the
next run cleared the statistics rows and end its registration wait or be
counted as its result. The wait, the completion check and the transfer
aggregation now count only reports whose run_id and phase match, and a
child that fails the lock check records its failure only while the lock
is free, so it never overwrites a newer run's rows. The double-count
regression test now asserts the exact poll count.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ry instead of GET_LOCK (Cacti#479)

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

@somethingwithproof
somethingwithproof merged commit bc9259a into Cacti:develop Dec 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants