Skip to content

Instantly share code, notes, and snippets.

@matthew-levan
Created January 24, 2023 19:54
Show Gist options
  • Save matthew-levan/1db63ed7806d6fdcd1dc46759e84d06b to your computer and use it in GitHub Desktop.
Save matthew-levan/1db63ed7806d6fdcd1dc46759e84d06b to your computer and use it in GitHub Desktop.
chop: offline event log truncation tool

chop is an offline urbit subcommand that truncates a pier's event log, effectively reducing the size of the pier on disk to roughly the size of its current snapshot.

Here's how it might work:

  1. Gracefully shutdown the ship if it's running
  2. Prepare for truncation
    1. Ensure the ship is stopped
    2. Ensure the snapshot is current (maybe no manual check is req'd)
    3. Save a copy of the current snapshot (separate from the one in .urb/chk)
      1. Make a dummy/magic event instead? (probably more difficult implementation)
  3. Truncate
    1. Save the last event and current db's metadata in memory
    2. Move the current db file to data.mdb.bak
    3. Create a new data.mdb file and paste in the last event and metadata
  4. Check the ship's functionality by booting it with -L (local networking only)
    1. On success, safely move/remove/compress data.mdb.bak file and reboot ship on the live network
    2. On failure, stop ship and restore old event log via mv data.mdb.bak data.mdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment