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

Backfill blob storage fix #5119

Merged
merged 5 commits into from
Jan 23, 2024

Conversation

realbigsean
Copy link
Member

Issue Addressed

Resolves #5114

Proposed Changes

  • Write the blobs to the blobs DB in import_historical_block_batch.
  • storing blocks/blobs to databases in this order, not atomically between databases: blobs, then hot, then cold.
  • Increment the schema version to v19
  • a database migration for v18 -> v19 that copies blobs from the hot DB to the blobs DB, and then atomically deletes all blobs from the hot DB with the schema version update.
  • No-op downgrade from v19 -> v18

Additional Info

I'm testing out the migration on goerli without batching any of the blob migration writes. I'm going to experiment with writing batches of 100 blob lists (max size ~60MB).

@realbigsean realbigsean added bug Something isn't working ready-for-review The code is ready for review deneb v4.6.0 ETA Q1 2024 labels Jan 23, 2024
Copy link
Member

@pawanjay176 pawanjay176 left a comment

Choose a reason for hiding this comment

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

LGTM.
Tested the migration on goerli and it works as expected.

Jan 23 17:47:10.842 DEBG Attempting schema migration             to_version: 19, from_version: 18, service: freezer_db
Jan 23 17:47:10.842 DEBG Migrating from v18 to v19
Jan 23 17:47:11.884 DEBG Collected 5065 blob lists to migrate
Jan 23 17:47:34.939 DEBG Wrote 5065 blobs to the blobs db
Jan 23 17:47:34.939 INFO Upgrading to v19 schema                 info: ready for Deneb once it is scheduled
lighthouse db inspect --network goerli --column blb

also shows that all blob data has been deleted from the hot db

Jan 23 17:59:24.158 INFO Running database manager for goerli network
Jan 23 17:59:24.235 INFO Blob DB initialized                     oldest_blob_slot: Some(Slot(7413760)), path: "/Users/pawan/.lighthouse/goerli/beacon/blobs_db"
Num keys: 0
Total: 0 bytes 

let ops = migration_schema_v19::upgrade_to_v19::<T>(db.clone(), log)?;
db.store_schema_version_atomically(to, ops)
}
(SchemaVersion(19), SchemaVersion(18)) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need the downgrade if it's no-op?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking so we could support 19 -> 17 for example

@pawanjay176 pawanjay176 mentioned this pull request Jan 23, 2024
@realbigsean
Copy link
Member Author

The migration on goerli took about 69s without batch and 55s with batching:

Initial database

Jan 23 20:34:48.695 INFO Blob DB initialized                     oldest_blob_slot: Some(Slot(7436641)), path: "./beacon/blobs_db"
00096114250a4db786328db8e8e8385dbba7a2fc1916e9e8dbb85dc36a58e469: 527712 bytes
000cdd72730dcf3c726732f92d8138abe40d298768d1e341cfc38c9ef00f3d29: 395784 bytes
000f49b60f95c1286716fdf430081135b0d748ea2d7f01ddbed2e81d3493a551: 395784 bytes
0014587b85a68ff583d17b3dc36faf1cb95781ee556a9e5467f0f9618241d077: 131928 bytes
0026717b26c14388c77012cfdca344b62bd4ff270b7628e880ee9f0fab5ce39f: 395784 bytes
00296b4688a0029967077369a8c8bbff3cfbb243df4626469a1e50d53a232e09: 527712 bytes
...
fff5990e81f03f2ab34c73c9e299ee3fb75613cc75cde9f2b4d4bfbd36e1a72c: 527712 bytes
fff5f1c9e36400280e932a43503cc7ff066c29c55143b67731261252c48c06fb: 659640 bytes
fff7c6d550aeef4a9abd1ec1aaae39a13bde8887caf638a737c23131ca70830f: 527712 bytes
fff823b9cb4b02c78ce65c3c1a35d9422c5c04b8c303ecd95c9c00d9b521d36a: 791568 bytes
fff86d632504d7abe44a9e9b6488b01b9a87815b74813745361804f566b26f53: 791568 bytes
fffcdb8ee620783737d3f2131c988e7f10c02d2cf03dd9a6a85503bf09fe2f74: 659640 bytes
Num keys: 12583
Total: 7064480544 bytes

No batching during migration

Jan 23 20:37:24.675 DEBG Attempting schema migration, to_version: 19, from_version: 18, service: freezer_db, module: store::hot_cold_store:304
Jan 23 20:37:24.675 DEBG Migrating from v18 to v19, module: beacon_chain::schema_change::migration_schema_v19:14
Jan 23 20:37:29.482 DEBG Collected 12583 blob lists to migrate, module: beacon_chain::schema_change::migration_schema_v19:23
Jan 23 20:38:38.728 DEBG Wrote 12583 blobs to the blobs db, module: beacon_chain::schema_change::migration_schema_v19:33
Jan 23 20:38:38.728 INFO Upgrading to v19 schema, info: ready for Deneb once it is scheduled, module: beacon_chain::schema_change::migration_schema_v19:36

Batching 500 writes

Jan 23 21:27:10.837 DEBG Migrating from v18 to v19, module: beacon_chain::schema_change::migration_schema_v19:14
Jan 23 21:27:14.040 DEBG Collected 12583 blob lists to migrate, module: beacon_chain::schema_change::migration_schema_v19:24
Jan 23 21:28:09.265 DEBG Wrote 12583 blobs to the blobs db, module: beacon_chain::schema_change::migration_schema_v19:47
Jan 23 21:28:09.265 INFO Upgrading to v19 schema, module: beacon_chain::schema_change::migration_schema_v19:50

Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

Nice fix, thanks!

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Jan 23, 2024
@michaelsproul michaelsproul merged commit 1cebf41 into sigp:unstable Jan 23, 2024
29 checks passed
danielrachi1 pushed a commit to danielrachi1/lighthouse that referenced this pull request Feb 14, 2024
* store blobs in the correct db in backfill

* add database migration

* add migration file

* remove log info suggesting deneb isn't schedule

* add batching in blob migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deneb ready-for-merge This PR is ready to merge. v4.6.0 ETA Q1 2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants