-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(log): optimize open db log #5385
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
feat(log): optimize open db log #5385
Conversation
chainbase/src/main/java/org/tron/common/storage/leveldb/LevelDbDataSourceImpl.java
Outdated
Show resolved
Hide resolved
chainbase/src/main/java/org/tron/common/storage/leveldb/LevelDbDataSourceImpl.java
Outdated
Show resolved
Hide resolved
6c43e7f
to
66cba65
Compare
} | ||
} catch (IOException e) { | ||
if (e.getMessage().contains("Corruption:")) { | ||
throw new RuntimeException(String.format("Can't initialize database: %s, please delete " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not throw an exception here. If you do not know what to do, please refer https://github.com/tronprotocol/java-tron/blob/develop/framework/src/main/java/org/tron/core/db/Manager.java#L572. And, please keep the changes to the RocksDB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not throw an exception here. If you do not know what to do, please refer https://github.com/tronprotocol/java-tron/blob/develop/framework/src/main/java/org/tron/core/db/Manager.java#L572. And, please keep the changes to the RocksDB.
Just exit when open db fail is ok.@halibobo1205
865ea1b
to
41536aa
Compare
chainbase/src/main/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImpl.java
Show resolved
Hide resolved
} | ||
} catch (IOException e) { | ||
if (e.getMessage().contains("Corruption:")) { | ||
logger.error("Database {} corrupted, please delete database directory({}) " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please refer https://github.com/tronprotocol/java-tron/blob/develop/framework/src/main/java/org/tron/core/db/Manager.java#L572
@halibobo1205 Just print the same message as L572? Or just exit when any exception is caught?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Exit when any db exception is caught
- Give a tip just like L572 when db is corrupted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Exit when any db exception is caught
- Give a tip just like L572 when db is corrupted.
@halibobo1205 done.
Add suggestion when open db fail.
41536aa
to
3dacceb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, fix the CI check
@@ -107,6 +109,13 @@ public void testReset() { | |||
Args.getInstance().getOutputDirectory(), "test_reset"); | |||
dataSource.resetDb(); | |||
assertEquals(0, dataSource.allKeys().size()); | |||
assertEquals("LEVELDB", dataSource.getEngine()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test to cover this PR, do not add tests that is not relevant in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test to cover this PR, do not add tests that is not relevant in this PR
done. @halibobo1205
@@ -97,6 +99,13 @@ public void testReset() { | |||
Args.getInstance().getOutputDirectory(), "test_reset"); | |||
dataSource.resetDb(); | |||
assertEquals(0, dataSource.allKeys().size()); | |||
assertEquals("ROCKSDB", dataSource.getEngine()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments as above
done. @halibobo1205
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## develop #5385 +/- ##
==========================================
Coverage 60.92% 60.92%
- Complexity 9231 9238 +7
==========================================
Files 839 839
Lines 50029 50038 +9
Branches 5574 5576 +2
==========================================
+ Hits 30479 30487 +8
- Misses 17165 17169 +4
+ Partials 2385 2382 -3
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
e968b90
to
d860a4e
Compare
d860a4e
to
6f082a8
Compare
What does this PR do?
Add suggestion when open db fail.
Why are these changes required?
To improve user-friendliness.