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

Refactor and test journal pruning class #482

Merged
merged 10 commits into from Jun 1, 2018
Merged

Conversation

AlexandraRoatis
Copy link
Contributor

Description

Please include a brief summary of the change that this pull request proposes. Include any relevant motivation and context. List any dependencies required for this change.

  • made the JournalPruneDataSource.java independent of the block and block header classes
  • improved and corrected synchronization
  • removed locks from stateDatabase since the only class accessing it is the JournalPruneDataSource
  • further unit tests for the journal prune functionality

Related to issues #54 and #298.

Note: this PR builds on top of #478.

The PR in #478 should be reviewed and merged first. After which this PR can be rebased to master-pre-merge branch.

Type of change

Insert x into the following checkboxes to confirm (eg. [x]):

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

Testing

Please describe the tests you used to validate this pull request. Provide any relevant details for test configurations as well as any instructions to reproduce these results.

  • full test suite and unit tests submitted as part of this PR

Verification

Insert x into the following checkboxes to confirm (eg. [x]):

  • I have self-reviewed my own code and conformed to the style guidelines of this project.
  • New and existing tests pass locally with my changes.
  • I have added tests for my fix or feature.
  • I have made appropriate changes to the corresponding documentation.
  • My code generates no new warnings.
  • Any dependent changes have been made.

@AlexandraRoatis AlexandraRoatis added the enhancement New feature or request label May 14, 2018
@AlexandraRoatis AlexandraRoatis added this to the v0.2.7 - Island Peak milestone May 14, 2018
if (!enabled) {
return;
}
ByteArrayWrapper hash = new ByteArrayWrapper(blockHash);
Copy link
Collaborator

Choose a reason for hiding this comment

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

use ByteArrayWrapper.wrap() intead of new ByteArrayWrapper()

try {
if (!enabled) {
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we check enable before the writelock?

enabled = e;

Copy link
Collaborator

Choose a reason for hiding this comment

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

use atomicboolean for the variable - enabled, then don't need lock in this method also check enabled before the other methods before writelock.

return src.get(key);
} catch (Exception e) {
throw e;
} finally {
Copy link
Collaborator

Choose a reason for hiding this comment

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

for the following throws(including this) , add an error log before throw if no outside classed catch these exceptions.

@AlexandraRoatis
Copy link
Contributor Author

rebased the branch to include changed to #478

@AlexandraRoatis AlexandraRoatis mentioned this pull request May 18, 2018
10 tasks
@qoire
Copy link
Contributor

qoire commented May 21, 2018

General question about the reference counts: Is it possible to remove the DB read that happens when we initialize a ref in incRef()?

We only seem to use it in removing fork blocks, so I believe we can do a check if absolutely necessary in that scenario but otherwise we can ignore it.

@AlexandraRoatis
Copy link
Contributor Author

Looking into the above refactoring I discovered a bug relating to the reference count. Working on it now.

@AlexandraRoatis
Copy link
Contributor Author

AlexandraRoatis commented May 22, 2018

Corrected the bug. Refactoring the reference to check for presence in the database only at rollback does not work because the pruning can no longer distinguish between inserts to be reverted (on side chain) and inserts to be kept (main chain). Check behavior for block b2 key k5 in pruningTest_wFork_onCurrentLevel and block b1 key k4 in pruningTest_wFork_onPastLevel.

Note: If you want, the refactoring can be done with the caveat that keys like the ones above will be kept in the database despite having outlived their utility. This means trading db access at run time for space taken up by stray keys that could not be deleted due to the missing functionality.

@qoire
Copy link
Contributor

qoire commented May 22, 2018

LGTM

@AlexandraRoatis AlexandraRoatis mentioned this pull request May 24, 2018
@AionJayT AionJayT merged commit 8326973 into db-journal-prune Jun 1, 2018
@AionJayT AionJayT mentioned this pull request Jun 14, 2018
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants