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

Revise the approach for setting level_compaction_dynamic_level_bytes #8037

Merged

Conversation

ahamlat
Copy link
Contributor

@ahamlat ahamlat commented Dec 16, 2024

PR description

We noticed with the upgrade from RocksDB from 8.3.2 to 9.7.3 that the defaults on LeveledCompaction are changed to reduce space amplification. This changes triggered big compactions depending on the nodes when opening RocksDB databse. This is related to change in the value of this parameter level_compaction_dynamic_level_bytes, changed from false to true.
This PR modify the logic for determining level_compaction_dynamic_level_bytes

  1. If a node is already sync'd and validating : we keep the existing configuration (level_compaction_dynamic_level_bytes=false if the node is not upgraded yet to 24.12.0, 24.12.1 or 24.12.2) (i.e no compaction)
  2. If the node is already ugraded to 24.12.0, 24.12.1 or 24.12.2, we keep the existing configuration, i.e level_compaction_dynamic_level_bytes=true, as the compaction already happened
  3. If the node is a new node, sync'ing from scratch, we apply directly the default configuration, i.e : level_compaction_dynamic_level_bytes=true

Tested with success :

  1. A node already sync'ed and not upgraded keeps level_compaction_dynamic_level_bytes set to false (no compaction)
  2. A node already sync'ed and upgraded keeps level_compaction_dynamic_level_bytes set to true (compaction already happened, so no more overhead)
  3. A node sync'ing from scratch, start with the recommended configuration, level_compaction_dynamic_level_bytes set to true

To detect similar issues in the future, we added a warning log if database opening exceeds 60 seconds.

{"@timestamp":"2024-12-16T15:35:11,767","level":"INFO","thread":"main","class":"DatabaseMetadata","message":"Lookup database metadata file in data directory: /data/besu","throwable":""}
{"@timestamp":"2024-12-16T15:35:11,791","level":"INFO","thread":"main","class":"RocksDBKeyValueStorageFactory","message":"Existing database at /data/besu. Metadata versionedStorageFormat=BaseVersionedStorageFormat{format=BONSAI, version=3}. Processing WAL...","throwable":""}
{"@timestamp":"2024-12-16T15:36:11,980","level":"WARN","thread":"pool-2-thread-1","class":"RocksDBOpener","message":"Opening RocksDB database is taking longer than 60 seconds... This may be due to prolonged RocksDB compaction. Please wait until the end of the compaction. No action is needed from the user.","throwable":""}
{"@timestamp":"2024-12-16T15:37:13,740","level":"INFO","thread":"main","class":"FlatDbStrategyProvider","message":"Flat db mode found FULL","throwable":""}

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

…ime to open the database

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@ahamlat ahamlat changed the title Display a warn log when Opening RocksDB takes more than 60 seconds Warn log when opening RocksDB takes more than 60 seconds Dec 16, 2024
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@ahamlat ahamlat changed the title Warn log when opening RocksDB takes more than 60 seconds Revise the approach for setting level_compaction_dynamic_level_bytes Dec 17, 2024
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
@ahamlat ahamlat marked this pull request as ready for review December 17, 2024 14:57
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.

nice. changelog entry?

@ahamlat ahamlat merged commit 8c451c1 into hyperledger:main Dec 18, 2024
43 checks passed
daniellehrner pushed a commit to daniellehrner/besu that referenced this pull request Dec 18, 2024
…yperledger#8037)

* Create a RocksDB opener that display a warning if it takes too much time to open the database
* Change the strategy levelCompactionDynamicLevelBytes is set

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
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.

4 participants