Repository navigation
fix(controller): take auto-snapshots on LINSTOR's schedule - #301
Conversation
AutoSnapshot/RunEvery 1 produced one snapshot every two minutes. The runnable polled once a minute and counted the next interval from the poll that took the snapshot, so a poll that arrived a few milliseconds short of the minute found nothing due and the snapshot waited for the following poll. LINSTOR's AutoSnapshotTask polls every ten seconds and books each run at the slot that fell due, the previous slot plus RunEvery, so poll delay never stretches the interval. Do the same. A slot missed by a whole interval, after controller downtime, is booked at the time it is taken instead of being caught up one snapshot per poll, which would only rotate older snapshots out of the keep budget. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The annotation now holds the schedule slot, not the creation time, so an operator comparing it with the Snapshot's creationTimestamp would see up to one poll of difference and suspect a bug. The downtime rationale claimed LINSTOR catches up one snapshot per poll. It does not: it keeps the schedule in memory and after a restart starts it at start + RunEvery + one poll. Booking a missed slot at take time is our own choice, which also keeps the slot across a failover shorter than RunEvery. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
Matches LINSTOR v1.33.1 AutoSnapshotTask: a 10 s poll (TASK_TIMEOUT) and the next run booked at the slot (AutoSnapshotConfig.next()). Keeping the slot across a restart instead of LINSTOR's start-plus-RunEvery is documented and does not catch up missed slots. LGTM.
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
The schedule matches LINSTOR v1.33.1 AutoSnapshotTask: a 10 s poll (TASK_TIMEOUT) and the next run booked at the slot (AutoSnapshotConfig.next()). One repo rule is not met yet, inline.
| // catch-up would take one snapshot per poll and only rotate older | ||
| // snapshots out of Keep. LINSTOR keeps its schedule in memory and | ||
| // after downtime restarts it at start + RunEvery + one poll; keeping | ||
| // the slot across a failover shorter than RunEvery is deliberate. |
There was a problem hiding this comment.
This is an intentional divergence from LINSTOR (it books start + RunEvery + TASK_TIMEOUT after a restart, AutoSnapshotTask.java:104 in v1.33.1, while blockstor keeps the slot in the annotation), and the PR body says so too. CLAUDE.md asks for every intentional divergence to get a row in docs/cli-parity-known-deltas.md, and the PR adds none. Please add a BEHAVIOR row for the auto-snapshot schedule after a controller restart or failover.
There was a problem hiding this comment.
Agreed, added in 9c52ff6: row 100 in docs/cli-parity-known-deltas.md, BEHAVIOR, permanent. It describes LINSTOR's start plus RunEvery plus one poll after a restart (AutoSnapshotTask.java in v1.33.1) against blockstor keeping the slot in the annotation, notes that a slot missed by a whole interval is booked at the take time with no catch-up, and points to the two cadence tests that pin it. The id skips 95 to 99, which other open branches already use.
On the red Unit tests and Integration tests runs of this head: TestReconcileComesBackWhenAPlacementHoldRunsOut and TestManagerIndexesCachedReplicasByDefinitionKey fail the same way on main at bd9d4df (run 45202362404), and TestGroupKWFHappyPath failed on main at 1e095f3 too (run 45171569631). None of them touches the auto-snapshot path; the cadence tests pass.
The PR keeps the auto-snapshot slot in the definition's annotation, so a restart or a leader failover shorter than RunEvery does not shift the schedule, while LINSTOR v1.33.1 rebooks the first run at start plus RunEvery plus one poll. That is an intentional divergence, and every intentional divergence gets a row in the accept-list. The id skips the rows other open branches already use. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
Row 100 covers the restart divergence, which was my only point. I rechecked the schedule against AutoSnapshotTask at v1.33.2: same TASK_TIMEOUT, same first-run booking, same next(). The red unit and integration tests fail the same way on main.
The cadence tests take auto-snapshots of a definition with no replicas and never finish a take. #292 targets an auto-snapshot at the definition's diskful replicas, skips a tick without one, and holds a tick back while the previous take still has I/O suspended, so with both branches merged the tests took no snapshot after the first. They now give the definition its replicas and finish each take, with helpers of their own so the file builds with or without #292. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Several open branches added accept-list rows at the next free id on main, so the merged table carried ids 95, 96, 97 and 100 twice. Each branch now takes its own ids above main's 98, in PR order, so they stay unique whatever order the branches merge in. This row moves from 100 to 106. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
prealloc failed Lint on the new withCadenceReplicas helper, whose length is known up front. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The volume definition disk options and the render-input wake-ups both added a ResourceGroup watch to the replica reconciler, each mapping a group event to this node's replicas of the group's definitions. With two handlers for one event, the pass was counted under whichever enqueued first, so a group edit was sometimes reported as a definition change rather than a configuration one, and the render-input test that waits for the latter timed out. The render-input watch covers the same replicas, so the older one goes and its test now checks the mapper that remains. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
What this PR does
With
AutoSnapshot/RunEvery 1the controller took one auto-snapshot every two minutes instead of every minute. The runnable polled once a minute and started the next interval at the moment the poll ran, so a poll that arrived a few milliseconds before the minute was up found nothing due and the snapshot waited a whole extra poll.The runnable now schedules the way LINSTOR's
AutoSnapshotTaskdoes: it polls every ten seconds, and each snapshot is booked at the slot that fell due (previous slot plusRunEvery), not at the moment the poll noticed it, so poll delay never adds up across intervals. When a slot was missed by a whole interval or more, for example while the controller was down, the snapshot is booked at the time it is taken instead of catching up slot by slot, which would only rotate older snapshots out of theAutoSnapshot/Keepbudget. This part deliberately differs from LINSTOR: LINSTOR keeps its schedule in memory and after a restart books the first snapshot at start plusRunEveryplus one poll, while blockstor keeps the slot in the definition's annotation, so a leader failover shorter thanRunEverydoes not shift the schedule. The annotation now holds that slot rather than the creation time, so it can read up to one poll earlier than the Snapshot'screationTimestamp.Release note
Testing
RunEvery 1, and checks after every tick that each minute's snapshot was taken by the first poll at or after it (31 snapshots in total). It fails with the old one-minute poll (3 snapshots after 3 minutes, want 4), with intervals counted from the poll time (same), and with both (the shipped behaviour).dev/v0.4.0-alpha.6branch, with that branch's replica fixtures, and fail there with the old scheduling.make lint-config && make lint: 0 issues.go test ./...passes. IntegrationTestGroupGpasses.Not tested
RunEvery 1, each take finishing within two seconds.