Repository navigation
fix(storage): Keep TTL's run state across restarts and failovers - #5073
Conversation
Tracking
Standard development
CI Testing Labels
Kubernetes operator / Helm chartsDoes this change affect how Memgraph is deployed or configured on Kubernetes? It likely does if it adds, removes or renames a flag; changes run-time or startup settings; touches the license, AWS settings, coordinators, replication, TLS, monitoring or another enterprise feature.
Documentation checklist
|
|
This PR has potential conflicts with the following other open pull requests which modify the same files:
|
|
4a80474 to
e0c1926
Compare
|
Release note advisory resolved Release note: |
There was a problem hiding this comment.
Automated review by the Memgraph review service
Verdict: APPROVE WITH NON-BLOCKING
Findings: 0 blocker, 2 non-blocking, 3 nit (3 inline)
Findings outside the diff
-
src/storage/v2/disk/storage.hpp:459-463[Nit] Disk
StartTtlignoresrepl_argsAlways calls
Resume()regardless of role. Safe (theuser_check_gate prevents replica writes) but diverges from the documented contract. -
src/storage/v2/durability/snapshot.cpp:8081[Nit] Snapshot load un-pauses the worker on replica recovery
(and 6 other load blocks).
ttl->Resume()runs during recovery even when the instance is a replica. Functionally inert (deny-defaultuser_check_is installed before recovery), but the scheduler ticks uselessly.
|
Re the two findings outside the diff:
|
A TTL that was running came back paused after a restart from the exit snapshot, because shutdown stops the TTL job before the snapshot records whether it runs. Promotion to MAIN also resumed every TTL, undoing STOP TTL. TTL now keeps whether it was asked to run apart from its job's state: the snapshot records that, demotion pauses the job without changing it, and promotion resumes only the TTLs that should run.
Promotion read whether TTL should run and then resumed it, so a STOP TTL in between was undone. Pause, Resume, and ResumeIfWanted now hold one mutex, so each reads or sets the flag and pauses or resumes TTL as one step.
a7c18e7 to
5dbd5d7
Compare
andrejtonev
left a comment
There was a problem hiding this comment.
LGTM — wanted flag verified across restart, failover, replicated ENABLE/STOP and the STOP-vs-promotion race; mutation-tested the new e2e tests, all three catch a regression.
Test gap: nothing covers a replicated STOP TTL or DISABLE TTL followed by promotion.
…pshot A replica keeps its TTL scheduler alive while paused, so loading a snapshot from MAIN called Configure on a running scheduler and threw "TTL already running!". The replica was left without data and MAIN retried forever. The snapshot loaders now configure TTL only when it isn't running, as WAL recovery already does.



A TTL that was running came back paused after a restart that recovered from the exit snapshot, and stayed paused until it was enabled again. Shutdown stops the TTL job before the exit snapshot records whether TTL runs, so the snapshot always recorded it as stopped. Promotion to MAIN had the opposite problem: it resumed every TTL, undoing
STOP TTLon failover.TTL now keeps whether it was asked to run separately from the state of its background job.
ENABLE TTLandSTOP TTLset it, the snapshot records it, demotion pauses the job without changing it, and promotion resumes only the TTLs that should run.