Skip to content

fix(pegboard): delete branch-backed sqlite on actor destroy - #5569

Open
SaiThanushreddy wants to merge 1 commit into
rivet-dev:mainfrom
SaiThanushreddy:fix/pegboard-branch-destroy
Open

fix(pegboard): delete branch-backed sqlite on actor destroy#5569
SaiThanushreddy wants to merge 1 commit into
rivet-dev:mainfrom
SaiThanushreddy:fix/pegboard-branch-destroy

Conversation

@SaiThanushreddy

Copy link
Copy Markdown

Description

Fixes #5561

Destroying a sqlite: remote actor cleared only the legacy actor-ID layout (meta_head/shard/delta/pidx via clear_v2_storage_for_destroy) and left the branch-backed layout BR/<branch_id>/... (DBPTR -> DatabaseBranchId) tombstoned. Branch refcount stayed 1 so depot GC never reclaimed it (branch_rows 39->43 in repro).

  • delete branch-backed DBPTR database on actor destroy via depot::conveyer::branch::delete_database (tombstone + Add(refcount,-1)) so GC can reclaim
  • make destroy idempotent on DatabaseNotFound (tracing::debug! per pegboard-envoy pattern)

Both pegboard/src/workflows/actor2/mod.rs:1238 ClearKv and pegboard/src/workflows/actor/destroy.rs:181 ClearKv now call clear_branch_storage_for_destroy outside the KV txn (branch delete has its own versionstamped txn). Legacy clear_v2 kept for pre-branch actors.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • cargo check -p pegboard --all-targets ok
  • cargo test -p pegboard --test actor_sqlite_destroy -- --nocapture 6/6 ok:
    • actor_destroy_clears_branch_backed_databaserefcount 1->0, list_databases []
    • actor_destroy_branch_is_idempotent — double delete no-op
    • actor_destroy_branch_noop_when_no_database — no branch/bucket no-op
    • actor_destroy_clears_both_layouts_like_workflow — legacy clear_v2 + branch delete wiring
    • 2 existing legacy tests still pass

Repro repro-actor-destroy-sqlite.sh now shows refcount 1->0, list_databases [] (branch BR/ rows remain until sweep_unreferenced_branch GC — expected logical delete).

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@SaiThanushreddy

Copy link
Copy Markdown
Author

@claude review

@SaiThanushreddy

Copy link
Copy Markdown
Author

@abcxff @MasterPtato

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.

bug(engine): Branch-backed actor SQLite data is not destroyed

1 participant