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

AKI-672: Call repository close on main instance #1126

Merged
merged 1 commit into from
Mar 6, 2020
Merged

Conversation

AlexandraRoatis
Copy link
Contributor

Type of change

  • Bug fix.
  • New feature.
  • Enhancement.
  • Unit test.
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

@AlexandraRoatis AlexandraRoatis added the bug Something isn't working label Mar 5, 2020
@AlexandraRoatis AlexandraRoatis added this to the 1.4.1 milestone Mar 5, 2020
@AlexandraRoatis AlexandraRoatis requested a review from AionJayT March 5, 2020 22:57
@AlexandraRoatis AlexandraRoatis self-assigned this Mar 5, 2020
@@ -2186,6 +2187,14 @@ public synchronized void setBestBlock(Block block) {

@Override
public synchronized void close() {
while (repository.isSnapshot()) {
popState();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the kernel flush the DB before the shutdown process? If the answer is no, why we do popState?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main repository instance is stashed when the snapshot is created. If the current repository is a snapshot that means the main one is in the stack. So we need to pop the stack until we get to the main repository instance that contains access too all the databases that must be closed.
If the close was called under normal circumstances the repository was already flushed. If it was called due to an error (like a VM issue) then flushing may store corrupt data, so it shouldn't be done.

When the close method is called due to a critical error the databases
that are not copied into a snapshot may remain open. This is because
during execution the main repository can be stashed while a snapshot
is used for the block import.
@AlexandraRoatis AlexandraRoatis force-pushed the AKI-672 branch 2 times, most recently from 7eb7561 to c1b66dd Compare March 6, 2020 18:22
@AlexandraRoatis AlexandraRoatis merged commit c1b66dd into master Mar 6, 2020
@AlexandraRoatis AlexandraRoatis deleted the AKI-672 branch March 6, 2020 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants