Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swingset): delete unused snapshots #3505

Merged
merged 23 commits into from
Jul 29, 2021
Merged

fix(swingset): delete unused snapshots #3505

merged 23 commits into from
Jul 29, 2021

Conversation

dckc
Copy link
Member

@dckc dckc commented Jul 21, 2021

In addition to maintaining a mapping from vatID to snapshotID,
vatKeeper maintains a reverse mapping.

After commitCrank(), the kernel calls vatWarehouse.pruneSnapshots(),
which, if snapshotPruneInterval cranks have passed:

  1. calls kernelKeeper.getUnusedSnapshots(),
  2. tries to snapStore.delete() each of them, and
  3. reports the results using kernelKeeper.forgetUnusedSnapshots().

fixes #3374

includes progress on #3431

@dckc dckc requested review from warner, mhofman and FUDCo July 21, 2021 21:18
@warner
Copy link
Member

warner commented Jul 22, 2021

Oh, we should make sure that terminated vats get removed from the users list.

@dckc dckc force-pushed the 3374-prune-snapshots branch 3 times, most recently from d5be4a9 to 2b8a348 Compare July 27, 2021 21:06
@dckc dckc requested a review from michaelfig July 28, 2021 01:43
@warner warner self-requested a review July 29, 2021 17:52
Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional check in the unit test recommended, rest looks good.

dckc added 4 commits July 29, 2021 13:29
runSteps didn't create it; its caller still has a reference
In addition to maintaining a mapping from vatID to snapshotID,
vatKeeper maintains a reverse mapping.

After `commitCrank()`, the kernel calls `vatWarehouse.pruneSnapshots()`,
which
 1. calls `kernelKeeper.getUnusedSnapshots()`,
 2. tries to `snapStore.delete()` each of them, and
 3. reports the results using `kernelKeeper.forgetUnusedSnapshots()`.

fixes #3374
Pruning snapshots involves an O(n) query on the DB, so
doing it on every crank seems expensive.

refs #3374
dckc added 19 commits July 29, 2021 13:29
 - makeSnapStoreIO is in swing-store-lmdb now
 - vatKeeper.saveSnapshot() prepares deletes
   - removeFromSnapshot() returns consumers.length
   - no more vatWarehouse.pruneSnapshots
     - no more snapshotPruneInterval
 - test-warehouse: use commit()
 - test-reload-snapshot: update imports
 - getRequired() asserts that get() does not return undefined
 - fix addHelpers() return type by declaring arg type
 - where kvStore.get() is ensured by getKeys() or has(),
   mark the alternative with assert.fail().
to avoid @agoric/xsnap in swing-store-lmdb devDependencies
@dckc dckc enabled auto-merge (squash) July 29, 2021 18:46
@dckc dckc merged commit 317959d into master Jul 29, 2021
@dckc dckc deleted the 3374-prune-snapshots branch July 29, 2021 19:05
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.

snapstore: unused snapshots are never deleted
4 participants