Skip to content

feat(cyclestore): add opt-in logical-expiry controller - #631

Merged
ketor merged 49 commits into
dingodb:mainfrom
ketor:cyclestore/dev
Nov 29, 2026
Merged

ketor merged 49 commits into
dingodb:mainfrom
ketor:cyclestore/dev

Conversation

@ketor

@ketor ketor commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Add the opt-in S1-S3 CycleStore foundation for logical cache expiry. The controller is a separate CPU-side component; it is not enabled on an existing production path.

  • S1: production online append-only prefix/decomposition index with preorder range maxima, ancestor witnesses, link/prune and incarnation checks.
  • S2: versioned canonical records, framed journals, RocksDB persistence and checkpoints, plus lookup/commit FSM state and replay semantics.
  • S3: the independent dfkv_cycle_controller using braft/brpc for fixed-shard replication. Adds the protobuf interface, replicated apply/read-barrier read model, snapshot/fence/lease/receipt identity and three-replica fault handling.

Dependency versions are locked and built into a controller-private static stack. The default remains DFKV_BUILD_CYCLESTORE=OFF; CycleStore sources and tests are excluded from the existing dfkv/core/test globs, so existing server/MDS/client libraries do not inherit the controller's braft/brpc/RocksDB dependencies.

Not included: S4 adapters, capability record kinds, perf branches or engine integration. This is not a rollout, a charging-model change, or a public service-entry switch.

Verification on this exact HEAD

  • Registered CycleStore suite: 26/26 PASS (17 S1, 5 S2, 4 S3), including snapshot identity, real store faults, three-replica recovery and business integration.
  • Ordinary and ASan FSM differentials: each 86 cases, 22 deterministic cases plus 64 random seeds, 8,538 events / 1,147,679 field comparisons / 0 mismatches.
  • The independent F1 fault-lifecycle review is GO: Write, ReadMetaAfterWrite, DeriveLink, GC Storage Write and DerivePrune each observe a new fatal at its actual start/index, followed by SIGKILL/restart and consistent replica recovery/digests.
  • Snapshot evidence checks outer and business descriptor identity twice, including 30/3, with subsequent InstallSnapshot and tail replay to last_applied=32/3.
  • The barrier checks distinguish positive and negative FINAL outcomes: 1300000, 1620001, 1702000, with token/prune high-water 1822000 and explicit requested-TTL values.
  • Maintained full regression: discovery=2122, selected=executed=2116, direct JUnit=2017 PASS / 99 SKIP / 0 FAIL, and required rows=32/32. The raw runner is 2011/105; the six raw/name-only differences have per-case CTest Passed plus JUnit status=run evidence rather than being silently adjusted as one count.
  • OFF with tests enabled: 386/386 existing targets built, with no CycleStore module targets/objects.

The original 1024 x 20,000 durability rollup is complete: 1,024 seeds, plus the deterministic cases, with 0 inconsistencies. Its 1,035 total cases collected 28,329,058 semantic events, 541,164,186 projection commands, 1,023,854,036 comparisons and 818,374 invalid-primitive probes. Summary SHA-256: 929ba4eab84a88dc4f5a72b5a68996b910c853d9796d10a7477177d7ba36af8f.

Exit-status boundary: the durability client exit code is UNOBSERVED. The assertion here is specifically the complete rollup's 0 mismatch, not an exit code of 0.

Boundaries

This change does not enable production traffic or alter charging/deployment. It does not claim multi-group routing, cross-datacenter replication, production authentication/TLS, real-model/full-rank/P-D compatibility, engine adapters, or p99/RTO/SLA guarantees. Test-only controller/admin fixtures are not a production API or authority boundary.

GitHub CI and normal code review are still required before merge; this PR does not enable auto-merge.

Follow-up: test release gate

The releasing callback is held until the original false assertion executes, then checks the actual send-pinned disconnect. This is test-only synchronization, not a production-timing change. The targeted grant/quarantine case passes ordinary and true ThreadSanitizer runs; the ordinary RdmaServerMw suite is 14/14 PASS. These counts do not imply a Soft-RoCE environment passed.

Gate result on 7428170d3ed6cfd620b6241f06c094e6de5d35c8

CI run 46233662613 completed: 12/13 jobs succeeded, including RDMA datapath (Soft-RoCE loopback + TSan) and ThreadSanitizer (race detection). build & test (g++) failed in python_storage_activation_controls: 1,656 Passed / 99 Skipped / 1 Failed among 1,756 reported CTest results. The single reported Python error is OwnedPythonLifetimeTest.test_preexisting_control_daemon_exit_is_not_successful_cleanup: the harness observed actual argv mismatch for python-child: [''] instead of the expected command. The checked-in change is confined to test/transport/rdma_loopback_test.cc; this does not prove the separate harness check has no defect or is timing-only. No retry or harness modification was made by this check.

Lifecycle argv-publication wait, head cbf3f99d44c94faaef78f591bb31db6f96df2af0: only the two test harness paths changed. OwnedProcess.start retries solely while a live process has a zero-byte /proc/<pid>/cmdline (1 ms, maximum 1 s); any non-empty argv must match immediately and strictly. Read failures and publication timeout are harness errors, natural zombie exit is reaped and rejected by default, and the explicit allow_early_exit exception alone retains actual_argv=None. Exact-HEAD review repeated the focused lifecycle/helper tests 11/11, the full Python module 45/45, and the formerly failing lifetime case 50/50, all with exit status 0. New CI run 46238412474 is 13/13 successful; python_storage_activation_controls passed and its g++ CTest reported 1,684 Passed / 99 Skipped / 0 Failed (1,783), while the RDMA Soft-RoCE loopback + TSan gate also passed. Local review did not run real etcd/MDS/server acceptance and makes no production/performance claim; the earlier failed run remains recorded above, and auto-merge is not enabled.

ketor added 30 commits November 29, 2026 05:26
Use an implicit Euler-tour treap and binary lifting; add focused tests and the actual S0 three-way differential harness.
Preserve zero-side-effect receipt replay, refresh root incarnation on safe fence reset, compare graph identity independently, register PYTHONPATH, and enforce writer domains in Debug builds.
Keep default-OFF generic dfkv targets independent of test/cyclestore and register S1/S2/S3 targets with the module's own includes, hermetic dependencies and CTest entries.
Cover invalid-parent links and stale/non-leaf prune probes, count them in random traces, and preserve causally valid minimized failure projections for replay.
ketor and others added 15 commits November 29, 2026 08:48
Hold the release-started event before PreparedRead::Commit while checking that replacement promotion is rejected. Then wait for physical removal to prove commit released the final send-pin before expecting promotion to succeed.
Retry only empty Linux argv reads until publication with a bounded one-second deadline.
Preserve early-exit handling, strict argv matching, and detailed failure diagnostics.
Add deterministic regressions for publication, timeout, exit, read failure, and argv mismatch.
@ketor

ketor commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Cross-reference: shared OwnedProcess harness only, not a request to alter this PR's CycleStore scope.

#633 adds a small, independent fixture-side opt-in for the two deliberate SystemExit(7) children. It does not replace this PR's bounded live-argv-publication handling.

I compared the exact candidates using a virtual Git tree from a8516f70bab5be7c786f85058a1f5e7b7772eea3 (test-only #633) and this PR's cbf3f99d44c94faaef78f591bb31db6f96df2af0. The merged tree is 6caa9652c71c354e48a4a7bad588d9761e326d76. Direct execution of the two harness files from that tree produced 45/45 passing Python tests, including this PR's new OwnedArgvCaptureTest cases and the real quick-exit controls. Raw log: ${CODE_ROOT}/dfkv-evidence/pr631-633-harness-compat-6caa9652/combined.stdout.log.

The fixes are complementary:

  • this PR addresses argv publication while the process is alive, with bounded wait and strict non-empty-argv checks;
  • test(storage): handle expected Python child early exits #633 explicitly enables the pre-existing allow_early_exit handling only for the two intentional exit-7 fixtures, so a natural zombie may have actual_argv=None without weakening its real return-code or ownership checks.

If #633 integrates first, please preserve its helper forwarding and the two explicit opt-ins when replaying this PR's bounded-capture logic. If #631 integrates first, I will rebase #633 on the actual resulting main and re-run the combined harness and CI rather than treating this virtual-tree run as the final result. No force-push, branch takeover, or resource stop is being requested. #633 remains unqueued pending public CI and independent post-test/overlap review.

@ketor

ketor commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Correction: the combined harness execution log now exists and is non-empty.

My earlier cross-reference linked combined.stdout.log, which is actually 0 bytes and must not be used as the execution proof. That empty file is preserved and has not been rewritten as if it were raw output.

For the actual recaptured invocation, use:
${CODE_ROOT}/dfkv-evidence/pr631-633-harness-recapture-6caa9652/combined-recapture.stdout.log
SHA-256: 6c6254889dbf12fb2759c463508d27ada71dbb352daf34507c7e46139acb4800 (6,691 bytes).

That log was captured with ordinary stdout+stderr redirection from the two harness files extracted from the same immutable virtual tree 6caa9652c71c354e48a4a7bad588d9761e326d76 (inputs a8516f7/cbf3f99), with no branch edits or different sources. It reports 45 passed, 0 FAIL/ERROR, rc=0, including six OwnedArgvCaptureTest controls, five real OwnedPythonLifetimeTest controls, and the other 34 cases. Direct parsing confirms all 45 and the two positive natural-exit/PID/PGID/exit-7 expectations. This was a small replay for log capture, not changing the test or hiding the earlier empty artifact or launcher failures. The initial empty combined log should not be cited as proof on its own.

The complementary integration conclusion is unchanged: keep the bounded live-argv publication logic and the two explicit expected-natural-exit opt-ins, with all healthy argv checks and cleanup semantics retained. This remains a virtual-tree compatibility test, not actual approval or #630 whole-suite acceptance. Public CI on #633 still must complete before any queue. If #631 merges first, #633 will rebase on that actual base and rerun the combined harness and CI; if #633 merges first, the bounded capture replay on #631 should preserve these two opt-ins and re-run the combined tests on the resulting tree.

Keep local checkpoint descriptors out of canonical business digests.
Publish C<index> and CLATEST only after checkpoint verification succeeds.
Filter shared-CF scans by record kind and reject empty keys explicitly.
- Detect creation with O_EXCL and fsync the parent before acknowledging a new journal.
- Inject fsync failures in the journal unit test and verify existing appends skip directory sync.
- Stop and reap a live child when argv startup validation fails.
- Cover timeout and missing-argv paths with real local process lifetime checks.
…op snapshots

- Reject missing TTLs and duplicate persistent unique-index keys before business persistence.
- Bind business checkpoints to braft's live applied index and ordered leadership term.
- Cover replicated invalid-command recovery, first-no-op snapshots, and durable store faults.
@ketor

ketor commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Review gate: please do not merge the current head as-is. Independent source review found substantive issues, not merely a pending-maintenance delay: local checkpoint metadata contaminated replica canonical digests and could publish an unvalidated CLATEST; missing requested_ttl and duplicate unique keys could turn ordinary bad evidence into replicated StateMachineError; new journal creation lacked parent-directory fsync; leader no-op could leave snapshot term/index inconsistent; metadata scans mixed checkpoint and shard records; and argv publication failure could escape owned-process cleanup. The corresponding scoped fixes now have individual focused evidence, and combined-main verification is in progress. The previous public CI 13/13 does not cover the new substantive validation. A fresh head will still need independent review and real public CI before merge. No auto-merge, force push, or administrator bypass has been enabled.

@ketor

ketor commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Review-fix update on the new head 6fd65f8c64988a5f6fa06dfb1ffc32b2dbc89abd. The independent reviewer has returned GO, with no remaining must-fix for the six substantive findings plus owned-process startup cleanup. Combined-main verification exercised all registered CycleStore focused cases successfully; the affected S2/S3 set also passed ASan 9/9, and the combined owned-process harness passed 47/47. Invalid evidence preserves business command boundaries, checkpoint publication follows verified export with replica-local metadata excluded from the canonical business digest, new-journal ACK includes the parent-directory fsync, and snapshot term/index uses the actual braft applied state rather than guessing a no-op increment. Initial verification-script omissions for the snapshot helper were corrected without changing candidate source or weakening assertions. The main CI watcher is tracking this exact new head; the old run is not being substituted. Merge remains contingent on its real 13/13 result, with no auto-merge, force push, release, deployment, or administrator bypass.

@ketor
ketor added this pull request to the merge queue Nov 29, 2026
Merged via the queue into dingodb:main with commit 1df1493 Nov 29, 2026
13 checks passed
@ketor

ketor commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Merged through the repository-required native merge queue. Actual main/merge commit is 1df1493f145ff5ddf408a60a7aa067d7fc865a4f, at 2026-11-29T18:48:41Z. Its tree is 767613ab6db5bb2cf246d94f562228845d3b18e9, exactly matching the independently reviewed combined-main source tree; the fetched upstream main ref equals this merge commit. PR-head CI run 46294487288 is 13/13 success, with all jobs on 6fd65f8c64988a5f6fa06dfb1ffc32b2dbc89abd. This is a source/PR merge result, not a release, deployment, charging change, production/performance acceptance, or auto-merge claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant