Skip to content

feat(server-ng): add expired personal access token cleaner#3448

Open
krishvishal wants to merge 2 commits into
apache:masterfrom
krishvishal:background-pat-cleaner
Open

feat(server-ng): add expired personal access token cleaner#3448
krishvishal wants to merge 2 commits into
apache:masterfrom
krishvishal:background-pat-cleaner

Conversation

@krishvishal

Copy link
Copy Markdown
Contributor

Summary

  • Leader-gated. The cleaner is spawned on shard 0 of every node but a pass acts only when is_caught_up_primary() holds. The delete is a replicated mutation: the primary proposes once, every replica applies the commit. Independent per-node cleanup would race redundant proposals, and only the primary can commit.
  • Sessionless consensus submit. submit_delete_personal_access_token_in_process is the first server-originated replicated metadata write. With no client session it cannot use the preflight-gated client path, so it mirrors submit_logout_in_process: skip request_preflight, use the reserved internal client id 0. get_session(0) is None, so the commit path skips commit_reply and its assert!(client_id != 0); the preflight and register asserts are never reached. Delete is idempotent, so dropping dedup is safe.
  • Expiry-ordered index. Expired tokens are found by walking an expiry-sorted BTreeSet and stopping at the first not-yet-expired entry, so an idle tick is O(log n) instead of a full per-user scan.
  • Shutdown. Purely periodic (compio::time::timeout); no metadata-commit wake needed. Stop is observed between tokens; an in-flight submit is not cancel-safe, so the current delete finishes rather than being cut, bounding
    shutdown to one submit.
  • Rename RegisterSubmitError -> MetadataSubmitError: the error now covers register, logout, and PAT-delete submits.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jun 10, 2026
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 29.72973% with 156 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.18%. Comparing base (be0c997) to head (aa37db1).

Files with missing lines Patch % Lines
core/metadata/src/impls/metadata.rs 0.00% 72 Missing ⚠️
...ore/server-ng/src/personal_access_token_cleaner.rs 0.00% 45 Missing ⚠️
core/server-ng/src/bootstrap.rs 0.00% 21 Missing ⚠️
core/metadata/src/stm/user.rs 82.27% 14 Missing ⚠️
core/server-ng/src/dispatch.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #3448       +/-   ##
=============================================
- Coverage     74.29%   24.18%   -50.11%     
  Complexity      943      943               
=============================================
  Files          1245     1244        -1     
  Lines        121687   107286    -14401     
  Branches      97959    83586    -14373     
=============================================
- Hits          90403    25946    -64457     
- Misses        28328    80660    +52332     
+ Partials       2956      680     -2276     
Components Coverage Δ
Rust Core 10.53% <29.72%> (-64.86%) ⬇️
Java SDK 58.44% <ø> (ø)
C# SDK 69.41% <ø> (-0.52%) ⬇️
Python SDK 81.06% <ø> (ø)
PHP SDK 83.57% <ø> (ø)
Node SDK 91.22% <ø> (-0.13%) ⬇️
Go SDK 40.25% <ø> (ø)
Files with missing lines Coverage Δ
core/server-ng/src/login_register.rs 55.55% <100.00%> (ø)
core/shard/src/lib.rs 78.69% <ø> (ø)
core/server-ng/src/dispatch.rs 0.00% <0.00%> (ø)
core/metadata/src/stm/user.rs 57.65% <82.27%> (+5.11%) ⬆️
core/server-ng/src/bootstrap.rs 7.55% <0.00%> (-0.11%) ⬇️
...ore/server-ng/src/personal_access_token_cleaner.rs 0.00% <0.00%> (ø)
core/metadata/src/impls/metadata.rs 33.21% <0.00%> (-2.03%) ⬇️

... and 674 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant