[BESU-888] fix RocksDBException during sweeping #929
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Karim TAAM karim.t2am@gmail.com
PR description
Fix RocksDBException during sweeping
The issue comes from an error in the closing of WriteOptions (RocksDBColumnarKeyValueStorage)
When we call
new WriteOptions()
this will create a structure https://github.com/influxdata/rocksdb/blob/7adff3eb33001c471c48cdcadf1b55462920b123/options.go#L64When we call
WriteOptions->close()
this will free the structure createdhttps://github.com/influxdata/rocksdb/blob/7adff3eb33001c471c48cdcadf1b55462920b123/options.go#L242
The test reveals a bug regarding the calls to WriteOptions close() methods
besu/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBColumnarKeyValueStorageTest.java
Line 63 in b87a635
Scenario
1 - Create a WriteOption for the RocksDBColumnarKeyValueStorage instance (optionA)
final SegmentedKeyValueStorage<ColumnFamilyHandle> store = createSegmentedStore();
2 - Create a new transaction with a new WriteOption specific to it (optionB)
final Transaction<ColumnFamilyHandle> tx = store.startTransaction();
3 - Commits the transaction and releases the wrong instance of WriteOption (optionA+optionB)
tx.commit();
4 - Call the
tryDelete
method which uses the WriteOption instance of the RocksDbTransaction class. Problem this instance of WriteOption has been released and therefore may have random valuesstore.tryDelete(fooSegment, key)
How to fix
Do not release the WriteOption (optionA) during a transaction commit but when the RocksDBColumnarKeyValueStorage instance is closed
Adding a test that performed more than 1000 times the tests and it works. Without the fix it often fails very quickly