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

swingstore mode to move/archive historical transcript spans to separate files, outside the DB #10036

Closed
Tracked by #9174
warner opened this issue Sep 6, 2024 · 1 comment · Fixed by #10055
Closed
Tracked by #9174
Labels
cosmic-swingset package: cosmic-swingset enhancement New feature or request swing-store SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented Sep 6, 2024

What is the Problem Being Solved?

As discussed here, I kinda want a swing-store mode like { keepTranscripts: false, archiveTranscriptsInto: DIRNAME }, which would instruct the transcriptStore to write a compressed span into a new file in DIRNAME, just before deleting the items of that span.

My goal is to enable an external script (some combination of mv and scp or s3cmd) to move the completed files out of the way, upload or transfer them to some cheaper location, and then delete the originals. I want to save space on my follower's SSD, but I still want to have those old transcripts around for analysis purposes.

In addition to the new swing-store option and implementation, it would also need some plumbing through the app.toml config file (similar to what #10032 is doing).

Description of the Design

Security Considerations

None, this is a write-only option for swing-store, to a directory specified by the host application (which also specifies the directory for the SQLite file).

Scaling Considerations

This might improve performance of the SQLite transcriptItems table, in configurations where historical spans are not being retained, by drastically (90%) reducing the number of rows, and correspondingly reducing the size of the index. However I don't have any reason to believe this is currently consuming a significant amount of time in our system.

The stored files would be compressed, which would save about 90% of the disk space, compared to uncompressed items remaining in SQLite. However that's not a fair comparison, because either you're retaining historical transcripts (keepTranscripts: true) in which case they stay in SQLite and you're consuming a whole lot of disk, or you're allowing them to be pruned from the DB (keepTranscripts: false) in which case you're saving all of the space. This third option that I'm asking for will consume more overall space than plain keepTranscripts: false, but at least it will only be consuming about 10% of the disk space that the uncompressed transcriptItems items would have needed. Also note that #8318 would achieve the all-but-10% space savings (by virtue of compression) while still retaining all the historical spans.

Test Plan

unit tests in packages/swing-store, plus something (not sure what) for the app.toml wiring

Upgrade Considerations

None, when this feature is first enabled on a node, subsequent span rollovers will start populating the given directory. This is a local, not-in-consensus property, like maxVatsOnine or the option to retain historical spans at all.

To avoid losing data, a node which wishes to use this mode should change from { keepTranscripts: true } to { keepTranscripts: false, archiveTranscriptsInto: DIRNAME } in a single step, and never run the kernel with merely { keepTranscripts: false }.

cc @gibson042 @mhofman

@warner warner added enhancement New feature or request SwingSet package: SwingSet cosmic-swingset package: cosmic-swingset swing-store labels Sep 6, 2024
@mhofman
Copy link
Member

mhofman commented Sep 6, 2024

just before deleting the items of that span

IMO this option should unconditionally save them there, whether they would be deleted or not by keepTranscripts.

If not too much work, please also consider adding an equivalent archiveHeapSnapshotsInto, writing at the same time as inserted in the DB (aka just a tee). That would likely balloon the disk usage, but would be helpful for some debugging.

gibson042 added a commit that referenced this issue Sep 10, 2024
gibson042 added a commit that referenced this issue Sep 10, 2024
gibson042 added a commit that referenced this issue Sep 11, 2024
@mergify mergify bot closed this as completed in #10055 Sep 11, 2024
@mergify mergify bot closed this as completed in d2d5803 Sep 11, 2024
mergify bot added a commit that referenced this issue Sep 11, 2024
…iguration (#10055)

Fixes #10036

## Description
Adds consensus-independent `vat-{snapshot,transcript}-archive-dir` cosmos-sdk swingset configuration for propagation in AG_COSMOS_INIT. When set, gzip-compressed vat snapshot/transcript files are written to the respective directory (the former when created, the latter when finalized by rollover).

It also includes miscellaneous documentation and code improvements, most significantly a new helper for replacing `const cleanups = []; return aggregateTryFinally(async () => { … cleanups.push(…); … }, async () => { await PromiseAllOrErrors(cleanups.reverse().map(fn => Promise.resolve().then(() => fn()))); });` with `return withDeferredCleanup(async addCleanup => { … addCleanup(…); … });` (i.e., folding in the cleanup registration and ordering).

Best reviewed commit-by-commit.

### Security Considerations
This provides a new interface by which the Swingset kernel can write to its host filesystem, albeit indirectly via callback. But as such, it is a potential vector for filling up a disk or possibly overwriting files, although subject to an operator's own bad configuration and/or elevated permissions.

### Scaling Considerations
When one or both new settings are active and the disk is full or slow, performance may suffer. I considered performing these writes in the background, but decided that silent failures or slow writes would be worse than the new `await`s (and when active, the archive dir will likely be on the same filesystem as the database anyway).

### Documentation Considerations
I think I've covered what I need to, although there might be some other Markdown files worth updating.

### Testing Considerations
New features are covered by unit tests.

### Upgrade Considerations
This is all kernel code that can be used at any node restart (i.e., because the configuration is consensus-independent, it doesn't even need to wait for a chain software upgrade). But we should mention the new cosmos-sdk configuration in release notes, because it won't be added to existing app.toml files already in use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmic-swingset package: cosmic-swingset enhancement New feature or request swing-store SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants