-
Notifications
You must be signed in to change notification settings - Fork 198
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
Conversation
storage/pruning/pruningStorer.go
Outdated
@@ -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? |
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.
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) |
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.
👍
storage/pruning/pruningStorer.go
Outdated
@@ -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) |
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.
👍
storage/pruning/pruningStorer.go
Outdated
@@ -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) |
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.
👍
storage/pruning/pruningStorer.go
Outdated
@@ -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) |
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.
👍
storage/pruning/pruningStorer.go
Outdated
func createShallowPersisterDataForEpoch(args *StorerArgs, epoch uint32, shardIdStr string) *persisterData { | ||
filePath := createPersisterPathForEpoch(args, epoch, shardIdStr) | ||
|
||
p := &persisterData{ |
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.
return directly?
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.
Fixed.
storage/pruning/pruningStorer.go
Outdated
@@ -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? |
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.
I think it is critical because otherwise you'd save data in a persister which is not for the desired epoch
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.
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
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.
Understood. Left as it were - to prevent breaking something unforeseen. However, let me know if I should change instead.
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.
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
…ookupext Rename "fullHistory" to "db lookup extensions"
storage/pruning/pruningStorer.go
Outdated
@@ -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? |
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.
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
…ork/elrond-go into exchanges-integration-storers
return err | ||
} | ||
|
||
log.Info("indexGenesisBlocks(): historyRepo.RecordBlock", "shard", shard, "hash", genesisBlockHash) |
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.
is ok this log.Info ? maybe debug ?
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.
Indeed, I wanted it to be more obvious (since it was missing before).
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.
System tests passed.
GetFromEpoch
could not access persisters older thanNumActivePersisters
.CleanOldEpochsData
is unset, then open all persisters (and close old ones, as before)setIsClosed()
when closing the persistersIn the PR 2226, I've mistakenly disabled
epoch by tx hash
indexing (and thusget tx by hash
API wouldn't work for older epochs). Re-made now the link to epoch, by makingMiniblockHashByTxHashStorage
Static. Put transactions is fast (1 put per transaction), get 1 transaction is slower (3 reads).Index genesis block (for hyperblock nonce 1).
Fixed path for EpochByHashStorage.
FilePath = "EpochByHash"
, it was empty due to PR 2226.Fixed edge-case for saving hyperblock coordinates of cross-epoch (committed in 42, notarized in 43) transactions. Using
putInEpoch
primitive.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
andnode/db
's structure.Note that, for tests, I've set: