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

Exchanges integration storers #2244

Merged
merged 32 commits into from
Aug 28, 2020
Merged

Conversation

andreibancioiu
Copy link
Collaborator

@andreibancioiu andreibancioiu commented Aug 26, 2020

  1. After restarting a node, GetFromEpoch could not access persisters older than NumActivePersisters.
  • Fix: when CleanOldEpochsData is unset, then open all persisters (and close old ones, as before)
  • Fix: call setIsClosed() when closing the persisters
  1. In the PR 2226, I've mistakenly disabled epoch by tx hash indexing (and thus get tx by hash API wouldn't work for older epochs). Re-made now the link to epoch, by making MiniblockHashByTxHashStorage Static. Put transactions is fast (1 put per transaction), get 1 transaction is slower (3 reads).

  2. Index genesis block (for hyperblock nonce 1).

  3. Fixed path for EpochByHashStorage. FilePath = "EpochByHash", it was empty due to PR 2226.

  4. Fixed edge-case for saving hyperblock coordinates of cross-epoch (committed in 42, notarized in 43) transactions. Using putInEpoch primitive.

  5. Rename "fullHistory" to "db lookup extensions".

How to test

1 and 2 - wait a few epochs, stop some observers, start them again, query older transactions and older (hyper)blocks.

3 - Query hyperblock 1 (by nonce, by hash). Query shard blocks 0 (by nonce, by hash). Compare with Explorer.

4 - Assert that DB folders structure in Static is nice.

5 - A bit harder to test manually - we have unit tests though.

6 - Inspect config.toml and node/db's structure.

Note that, for tests, I've set:

RoundsPerEpoch = 20
FullHistory.Enabled = true

@andreibancioiu andreibancioiu marked this pull request as ready for review August 26, 2020 22:55
miiu96
miiu96 previously approved these changes Aug 27, 2020
cmd/node/config/config.toml Outdated Show resolved Hide resolved
cmd/node/config/config.toml Outdated Show resolved Hide resolved
storage/pruning/pruningStorer.go Outdated Show resolved Hide resolved
@@ -340,6 +348,7 @@ func (ps *PruningStorer) GetFromEpoch(key []byte, epoch uint32) ([]byte, error)
}

persister, err := ps.persisterFactory.Create(pd.path)
// Question for review: save reference on persister data?
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, I do not think we will need the old closed reference.

@@ -310,6 +316,8 @@ func (ps *PruningStorer) Close() error {
log.Error("cannot close persister", err)
closedSuccessfully = false
}
// Question for review - all good here?
persister.setIsClosed(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -350,6 +359,8 @@ func (ps *PruningStorer) GetFromEpoch(key []byte, epoch uint32) ([]byte, error)
if err != nil {
log.Debug("persister.Close()", "error", err.Error())
}
// Question for review: all good here?
pd.setIsClosed(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -400,6 +412,8 @@ func (ps *PruningStorer) GetBulkFromEpoch(keys [][]byte, epoch uint32) (map[stri
if err != nil {
log.Debug("persister.Close()", "error", err.Error())
}
// Question for review - all good here?
pd.setIsClosed(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -517,6 +532,8 @@ func (ps *PruningStorer) HasInEpoch(key []byte, epoch uint32) error {
if err != nil {
log.Debug("persister.Close()", "error", err.Error())
}
// Question for review - all good here?
pd.setIsClosed(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

func createShallowPersisterDataForEpoch(args *StorerArgs, epoch uint32, shardIdStr string) *persisterData {
filePath := createPersisterPathForEpoch(args, epoch, shardIdStr)

p := &persisterData{
Copy link
Contributor

Choose a reason for hiding this comment

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

return directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@@ -245,11 +245,16 @@ func (ps *PruningStorer) Put(key, data []byte) error {
log.Debug("active persister not found",
"epoch", ps.epochForPutOperation,
"used", persisterToUse.epoch)

// Question for review: isn't this a critical error?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is critical because otherwise you'd save data in a persister which is not for the desired epoch

Copy link
Contributor

Choose a reason for hiding this comment

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

If we return error here, the node won't advance: this will keep the DB as consistent as possible. If we not, the node will advance, but the data might not be stored inside

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Understood. Left as it were - to prevent breaking something unforeseen. However, let me know if I should change instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

this case didn't happen because the epochForPutOperation is set on CommitBlock so there are very small chances that the persister for the specified epoch doesn't exist. can remain like this for now

bogdan-rosianu
bogdan-rosianu previously approved these changes Aug 27, 2020
core/dblookupext/historyRepository.go Show resolved Hide resolved
node/nodeTransactions_test.go Outdated Show resolved Hide resolved
storage/factory/pruningStorerFactory.go Outdated Show resolved Hide resolved
storage/pruning/pruningStorer.go Outdated Show resolved Hide resolved
@@ -245,11 +245,16 @@ func (ps *PruningStorer) Put(key, data []byte) error {
log.Debug("active persister not found",
"epoch", ps.epochForPutOperation,
"used", persisterToUse.epoch)

// Question for review: isn't this a critical error?
Copy link
Contributor

Choose a reason for hiding this comment

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

If we return error here, the node won't advance: this will keep the DB as consistent as possible. If we not, the node will advance, but the data might not be stored inside

storage/pruning/pruningStorer.go Show resolved Hide resolved
iulianpascalau
iulianpascalau previously approved these changes Aug 27, 2020
storage/pruning/pruningStorer.go Outdated Show resolved Hide resolved
cmd/node/config/config.toml Outdated Show resolved Hide resolved
return err
}

log.Info("indexGenesisBlocks(): historyRepo.RecordBlock", "shard", shard, "hash", genesisBlockHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

is ok this log.Info ? maybe debug ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, I wanted it to be more obvious (since it was missing before).

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System tests passed.

@LucianMincu LucianMincu merged commit 252085f into development Aug 28, 2020
@LucianMincu LucianMincu deleted the exchanges-integration-storers branch August 28, 2020 10:51
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.

None yet

6 participants