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

Rocksdb plugin to support OptimisticTransactionDb and TransactionDb #5328

Merged

Conversation

gfukushima
Copy link
Contributor

@gfukushima gfukushima commented Apr 11, 2023

PR description

Tis PR introduces some changes to the RocksDB plugin to allow using the DB in either pessimistic or optimistic transaction mode.
Currently pessimistic is tied to the usage of Forest data format.

The refactor was done with the intent to keep bonsai as it is currently with usage of the optimistic transaction db.

This is just a initial draft not ready for review yet.

Fixed Issue(s)

Fixes #5300

Scenarios tested:

Sepolia

  • Fast-sync Forest (uses Pessimistic mode)
  • Snap-sync Bonsai (uses Optimistic mode)

Goerli

  • Fast-sync Forest (uses Pessimistic mode)
  • Snap-sync Bonsai (uses Optimistic mode)

Mainnet

  • Snap-sync Forest (uses Pessimistic mode) not finished yet
  • Snap-sync Bonsai (uses Optimistic mode)
  • Checkpoint-sync Forest (uses Pessimistic mode) not finished yet
  • Checkpoint-sync Bonsai (uses Optimistic mode)

Backwards compatibility

  • Roll back a Forest synced node to 23.1.2 forcing it to use Optimistic
  • Update a current synced Forest node that is using Optimistic to use the new version with pessimistic to ensure this won't require resyncs. (not done yet)

…t to optimistic and pessimistic

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
@github-actions
Copy link

github-actions bot commented Apr 11, 2023

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.
  • I have considered running ./gradlew acceptanceTestNonMainnet locally if my PR affects non-mainnet modules.
  • I thought about the changelog and included a changelog update if required.

@gfukushima gfukushima changed the title Rocksdb plugin to support OptimisticTxDb and PessimisticTxDb Rocksdb plugin to support OptimisticTransactionDb and TransactionDb Apr 11, 2023
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
@gfukushima gfukushima added TeamGroot GH issues worked on by Groot Team mainnet labels Apr 12, 2023
@gfukushima gfukushima self-assigned this Apr 12, 2023
Comment on lines 185 to 192
LOG.info("FOREST mode detected, using pessimistic DB.");
segmentedStorage =
new PessimisticRocksDBColumnarKeyValueStorage(
rocksDBConfiguration,
segmentsForVersion,
ignorableSegments,
metricsSystem,
rocksDBMetricsFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be done just for databaseVersion 1 in the switch statement as that indicates the db format is forest. Then the isForestStorageFormat wouldn't be needed either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created that flag on purpose cause it took me some time to understand that DBversion actually is related to forest or bonsai. I think the usage of numbers to identify version is fine. But giving some more context to the code so next devs to touch don't spend time trying to understand what this version means.
In my first draft I wasted some time piping the StorageFormat through the plugin API because I didn't know that database version represented that same information.

@gfukushima gfukushima marked this pull request as ready for review April 14, 2023 08:05
@non-fungible-nelson
Copy link
Contributor

Can you explain the benefits of these modes/this PR?

I think a review from @garyschulte at some point be useful as well (not urgent prior to the next release).

@garyschulte
Copy link
Contributor

The main benefit is that it simplifies concurrency for forest mode. Bonsai relies on Snapshots, which require OptimisticTransactionDb.

For some reason Optimistic causes transaction locking timeouts for forest mode. We could spend time on forest to discover why, but if we can avoid the issue by reverting toTransactionDb instead, that is a win.

I think there is value in having the ability to configure both modes with the rocksdb plugin, so that neither storage format forces the other mode to use a specific transaction mode.

@gfukushima
Copy link
Contributor Author

gfukushima commented Apr 14, 2023

@non-fungible-nelson It is pretty much impossible to sync a node currently using Forest (fast/snap/checkpoint). The worldstate(ws) download pipeline gets a lot of locking timeouts like Gary said and halts. We tried different approachs to avoid the ws pipeline to break (mostly some retries logics). Eventually switching Forest back to Pessimistic mode puts Forest back on track to get the the initial sync working.

@gfukushima
Copy link
Contributor Author

I think there is value in having the ability to configure both modes with the rocksdb plugin, so that neither storage format forces the other mode to use a specific transaction mode.

@garyschulte
I actually thought about introducing a new flag at the plugin level since this is actually related to the plugin itself and not the stoage-format we're using but eventually this would allow users to make no-functional combinations such as bonsai and pessimistic (which we probably don't want to).
We could possibly tie the TxDB mode with data-storage-format at the CLI level with some flags validations.

Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

LGTM, minor suggestions about naming and adapter split.

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
…actionDB

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

javadoc - needs a find/replace for pessimistic

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
@gfukushima gfukushima requested a review from garyschulte April 17, 2023 06:27
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

LGTM, just one more nitpick about class naming

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

🚢

@gfukushima gfukushima merged commit d54a1bf into hyperledger:main Apr 19, 2023
elenduuche pushed a commit to elenduuche/besu that referenced this pull request Aug 16, 2023
…yperledger#5328)

* Refactor to make RocksDBColumnarKeyValueStorage abstract and extend it to optimistic and pessimistic. Atm Forest has a concurrency level that does not cope well with the OptimisticTransactionDB and RocksDB ends up raising a lot of Busy when committing RocksDBTransactions.
A TransactionDB will do conflict checking for all write operations (Put, Delete and Merge), including writes performed outside a Transaction according to RocksDB. This does impact the times we see when syncing so likely not the final solution for Forest. 
Bonsai should continue using OptimisticTransactionDB.

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
…yperledger#5328)

* Refactor to make RocksDBColumnarKeyValueStorage abstract and extend it to optimistic and pessimistic. Atm Forest has a concurrency level that does not cope well with the OptimisticTransactionDB and RocksDB ends up raising a lot of Busy when committing RocksDBTransactions.
A TransactionDB will do conflict checking for all write operations (Put, Delete and Merge), including writes performed outside a Transaction according to RocksDB. This does impact the times we see when syncing so likely not the final solution for Forest. 
Bonsai should continue using OptimisticTransactionDB.

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mainnet TeamGroot GH issues worked on by Groot Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle RocksDB.Busy exception in the worldstate download pipeline
5 participants