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

[FAB-17039] Skip retrieving pvtdata from transient store if txid is empty (bp #2183) #2201

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions gossip/privdata/dataretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,27 @@ func (dr *dataRetriever) CollectionRWSet(digests []*protosgossip.PvtDataDigest,
// if there is an error getting info from the ledger, we need to try to read from transient store
return nil, false, errors.Wrap(err, "wasn't able to read ledger height")
}
if height <= blockNum {

// The condition may be true for either commit or reconciliation case when another peer sends a request to retrieve private data.
// For the commit case, get the private data from the transient store because the block has not been committed.
// For the reconciliation case, this peer is further behind the ledger height than the peer that requested for the private data.
// In this case, the ledger does not have the requested private data. Also, the data cannot be queried in the transient store,
// as the txID in the digest will be missing.
if height <= blockNum { // Check whenever current ledger height is equal or below block sequence num.
dr.logger.Debug("Current ledger height ", height, "is below requested block sequence number",
blockNum, "retrieving private data from transient store")
}

if height <= blockNum { // Check whenever current ledger height is equal or below block sequence num.
results := make(Dig2PvtRWSetWithConfig)
for _, dig := range digests {
// skip retrieving from transient store if txid is not available
if dig.TxId == "" {
dr.logger.Infof("Skip querying transient store for chaincode %s, collection name %s, block number %d, sequence in block %d, "+
"as the txid is missing, perhaps because it is a reconciliation request",
dig.Namespace, dig.Collection, blockNum, dig.SeqInBlock)

continue
}

filter := map[string]ledger.PvtCollFilter{
dig.Namespace: map[string]bool{
dig.Collection: true,
Expand Down Expand Up @@ -191,7 +204,7 @@ func (dr *dataRetriever) fromTransientStore(dig *protosgossip.PvtDataDigest, fil
colConfigs, found := rws.CollectionConfigs[dig.Namespace]
if !found {
dr.logger.Error("No collection config was found for chaincode", dig.Namespace, "collection name",
dig.Namespace, "txID", dig.TxId)
dig.Collection, "txID", dig.TxId)
continue
}

Expand Down