Repository navigation
Description
Describe the bug
On a database cluster, two Syslog processing masters can run at the same time. #495 replaced the GET_LOCK() processing lock with register_process_start('syslog', 'master', ...), which removed the worker check that failed in #479, but the registry cannot guarantee a single master when the database has more than one node. I noted this as a caveat in #495; this issue tracks it.
@TheWitness for your call on timing. This can wait until the release settles unless a cluster user reports overlapping runs sooner.
Why it happens
- Cacti's
processestable isENGINE=MEMORYon both1.2.xanddevelop. Galera replicates InnoDB only; MariaDB's known limitations say writes to tables of other engines are not replicated. A master's registration therefore exists only on the node that took the insert. - Cacti's install documentation already describes this for Galera: the
MEMORYtables are not replicated among nodes, and it does not apply when Cacti connects to one node only. It lists the tables to convert to InnoDB otherwise,processesamong them (develop, 1.2.x). register_process_start()decides whether a master is running with aSELECTon that table. If the read is routed to another node, it finds no row and registers a second master.- The primary key is
(pid, tasktype, taskname, taskid), so a second registration with a different pid does not collide with the first, even on the same node. developwraps the check in the InnoDBprocess_locksmutex. That stops two starters racing each other, but the check still reads the node-localprocessestable.1.2.xhas noprocess_locks, andINFOdeclarescompat = 1.2.23, so the plugin cannot rely on it.
This is from reading the code. I have not reproduced it on a cluster, and whether a proxy sends that SELECT to another node depends on its routing rules.
When it matters
A second master starts only if a run is still going when the next one is launched, or if two Cacti hosts process the same Syslog database. Workers are not affected: they are started by the master on the same host and check that the master process is alive locally.
Expected behavior
Only one master, partition rebuild or table repair runs against a Syslog database at a time, whichever node a connection lands on.
Fix direction
Per the maintainer comments below: move the core processes table to InnoDB, and remove entries whose process is gone, in poller_maintenance.php and on cactid restart. That makes the registration visible on every node.
Points to settle in that change:
- A process id can only be checked on the host that started it. With the table replicated, each row needs the host recorded, so a host removes only its own dead entries and never another host's live ones.
- The registration check is a
SELECTfollowed by anINSERT. On1.2.xnothing serialises the two, and on a cluster the read can also be stale on another node. One conditional write, with a key that does not include the pid, would close both. - Syslog supports core back to 1.2.23. On a core that still has the
MEMORYtable, the plugin needs its own guard or has to document single-node routing as a requirement.
Plugin-only alternative, if the core change has to wait: a lease row in an InnoDB table in the Syslog database (owner, host, pid, an epoch that increases on each takeover, and an expiry taken from the database clock), acquired and renewed with a single conditional UPDATE and an affected-rows check. cli/upgrade_partitioning.php and the on-demand repair in includes/schema.php would take the same lease.
Related: named locks still in the plugin
#495 removed only the processing lock. GET_LOCK() is still called on develop in syslog_pipeline_health_check(), syslog_partition_create(), syslog_partition_remove(), syslog_threshold_deliver_recoveries(), syslog_replace_data() and syslog_dashboard_seed_default(). MariaDB lists GET_LOCK() as unsupported explicit locking under Galera. The lock belongs to one server, so these guards only hold when every connection reaches the same node.
Versions
Syslog develop after #495. Seen as a risk for MariaDB Galera behind MaxScale read/write split (the setup reported in #479).
Edited 2026-12-03: added documentation references, the maintainer's fix direction and the remaining named locks, and corrected the first paragraph, which said #495 fixed #479. That is not yet confirmed by the reporters.
Activity
somethingwithproof commentedon Dec 3, 2026
Workaround until the registry is cluster-safe: send all Cacti and Syslog connections to one node
Use the cluster for failover, not for spreading Cacti's queries. Cacti keeps state that lives on one database node and assumes its next query lands on the same node:
MEMORYtables such asprocesses, which Galera does not replicate.GET_LOCK()), which belong to one server and are listed by MariaDB as unsupported under Galera.Cacti's install documentation gives the same two choices for Galera: connect Cacti to one node only, or convert the listed
MEMORYtables to InnoDB (develop, 1.2.x). The table lists differ between the two branches.Recommended setup:
readconnrouteservice withrouter_options=master, notreadwritesplit. Its documentation says a session stays on one backend and is closed if that backend connection breaks, so Cacti reconnects after a failover. It does not say what happens to open sessions when the primary role moves.backupis an open alternative; I have only read the documentation for the pieces, not run that layout.MEMORYtables are empty on the new primary. Stale registrations disappearing is the safe direction for the process registry.With everything on one node, the check and the registration hit the same node, so the second-master case described above mostly goes away.
This follows from the documentation and from how the code behaves. I have not tested it on a cluster.
Edited 2026-12-03: the first version said read/write split breaks all three kinds of state. MaxScale's readwritesplit documentation says
GET_LOCK(),RELEASE_LOCK()andIS_USED_LOCK()are always routed to the primary, so the named-lock case does not follow from read/write split alone. Also added the Cacti documentation references and the MaxScale licence note.TheWitness commentedon Dec 3, 2026
You can move the process table to innodb but upon say for example a cactid restart, we may want to check the status of pid's and eliminate things that are gone. Make it so.
TheWitness commentedon Dec 3, 2026
For people using cron maybe we do that in poller_maintenance.php. do it there regardless of course but if you do it inside of cactid it's also very convenient.
somethingwithproof commentedon Dec 3, 2026
I tested this on a real cluster: three MariaDB 10.6.24 Galera nodes, MaxScale 24.02.9 and HAProxy 2.8, Cacti 1.2.32 from
1.2.x, Syslogdevelopat 369b859, two workers, 12,000 to 30,000 generated messages per run. Two masters were started one second apart unless noted.readconnroute,router_options=masterreadwritesplitSyslog worker(s) exited without recording completion: 1, 2andOne or more transfer workers failed.readwritesplitSyslog worker PID N is no longer running, removing its stale process entrywas logged for a worker that had just finished.So the report is confirmed, and moving
processesto InnoDB fixes the case where the starts are apart in time. It does not close the race when two masters start together:register_process_start()reads and then inserts, and the primary key includes the pid, so two rows for the same job are both accepted. The core change needs a unique key on(tasktype, taskname, taskid), or an insert that fails for the second caller, as well as the engine change.In every overlapping run the number of rows added to
syslogequalled the number injected. I would not read that as safe: no alerts, reports or removal rules were configured.Two more things showed up through
readwritesplitthat the engine change does not fix:SELECTs, so they are answered by replicas. With the MEMORY registry the master saw no worker rows, stopped waiting, and reported the workers as failed while they were still running.GET_LOCK('same_name', 0) = 1. The sixGET_LOCK()calls still in the plugin give no protection across nodes.On a single-writer route none of this happens, and that is what I have written up for the manual in Cacti/documentation#334 (develop) and Cacti/documentation#335 (1.2.x).
Unrelated to the plugin but worth knowing: through
readwritesplitwith the stock tables the core poller reportedRRDsProcessed:0on every cycle and logged no error, becausepoller_outputwas written on the primary and read on a replica.somethingwithproof commentedon Dec 3, 2026
Following the test results above, this is what I think has to change for Syslog to be correct on a cluster that is not behind a single-writer route. Line numbers are
developat 369b859. Nothing here is written or tested yet; it is a proposal to agree on before any PR.On a single-writer route (MaxScale
readconnroutewithrouter_options=master, or HAProxy withbackupservers) the current code already works and needs none of this.1. Make the master registration exclusive
syslog_process.php:243callsregister_process_start('syslog', 'master', <poller_id>, 1200). In core that function readsprocessesand then inserts, and the primary key is(pid, tasktype, taskname, taskid), so two masters with different pids both get a row. That is what happened in 1 of 3 simultaneous starts with the table already on InnoDB.Two ways to fix it:
processesto InnoDB: add a unique key on(tasktype, taskname, taskid)so the second insert fails, and treat a duplicate-key error (and a Galera deadlock, error 1213) as "not acquired". Syslog needs no change beyond handling the return value it already checks.UPDATE ... WHERE holder IS NULL OR expires < NOW(6)and checked by affected rows, with the expiry taken from the database clock.I prefer the core change. It fixes every caller of the registry and not just Syslog.
2. Replace the remaining named locks
Named locks are local to one node. In the test, two sessions on two Galera nodes both got
GET_LOCK('same_name', 0) = 1. Six calls remain:includes/functions.php:2196syslog_pipeline_health_check()includes/functions.php:3555syslog_partition_create()includes/functions.php:3764syslog_partition_remove()includes/functions.php:6019syslog_threshold_deliver_recoveries()includes/processing.php:165syslog_replace_data()setup.php:1252syslog_dashboard_seed_default()These should use the same mechanism as item 1, with a task name per job. The partition ones matter most, because DDL is replicated to every node whichever node ran it.
3. Run the master's coordination reads on the writer
The master tracks its workers with plain
SELECTs onprocesses(syslog_workers_running_ids(),includes/functions.php:3254) and on the per-worker statistics settings. A read/write splitting proxy sends those to a replica. In the two-master run throughreadwritesplit, one master loggedSyslog worker(s) exited without recording completion: 1, 2andOne or more transfer workers failedwhile its workers were still running and went on to finish.The same function deletes a worker's registry row when it thinks the pid is gone, so a stale read can remove a live worker's row.
Options: wrap these reads in a transaction, which MaxScale routes to the primary, or read them with
SELECT ... FOR UPDATE. On a multi-writer Galera setup the session would also needwsrep_sync_wait=1for these reads. This is the item I am least sure how to do cleanly, because the reads go through coredb_fetch_*helpers.4. No change needed: worker liveness
syslog_processing_master_alive()checks a local pid (syslog_process.php:600). That is correct as long as the master and its workers run on the same host, which they do.What I would not do
Try to support writes on several nodes at once. Items 1 to 3 make Syslog safe if a proxy misroutes a statement or two masters start during a failover. They do not make an active-active setup a good idea for Cacti: the core poller has the same dependencies, and through
readwritesplitwith the stock tables it wrote no graphs at all.Suggested order
processesto InnoDB, unique key, dead-pid cleanup inpoller_maintenance.phpand oncactidrestart. Separate issue and PRs in Cacti/cacti for1.2.xanddevelop.@TheWitness does this match what you had in mind for the core side?
somethingwithproof commentedon Dec 3, 2026
Related tickets, so the history is in one place:
Same failure family
GET_LOCK()with the process registry, which is what exposed the node-local registry described here.Where the remaining named locks came from
GET_LOCK()around partition create to stop two pollers racing onREORGANIZE PARTITION. Item 2 above would move that lock, not remove the protection.syslog_threshold_deliver_recoveries().syslog_dashboard_seed_default().Design tracking
Outside this repository
TheWitness commentedon Dec 3, 2026
Yes. Maybe we find a way to tone it down, the turns, since we will only manually do thing in 1.2.31. A migration should be fine for develop and 1.2.32. However, there are not a ton of turns to register, etc.
somethingwithproof commentedon Dec 4, 2026
Status after the maintainer's go-ahead on moving the remaining named locks onto the process registry (item 2 of the proposal above):
1.2.x, fix(poller): [1.2.x] let only one process register a task cacti#9156 madeprocessesan InnoDB table with a unique key on(tasktype, taskname, taskid), andregister_process()now returns false when another holder exists. Thedevelopport is still in review.GET_LOCK()call sites listed above move to the registry with one task name per job. BecauseINFOdeclarescompat = 1.2.23, the pull request will say how the plugin behaves on a core that still has the old table.I will link the pull request here when it is open.
somethingwithproof commentedon Dec 4, 2026
Item 2 is up as #503: the six remaining named locks move onto the process registry when the core has the cluster-safe registry (1.2.32 and later), and keep the named lock on older cores. It has not been run on a Galera cluster. Item 3 and the
developport of Cacti/cacti#9156 remain open here.fix: move the remaining named locks onto the process registry (#503)