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

pass unreconciled missing pvtdata to pvtdata store (backport to release-2.2) #1886

Merged

Conversation

denyeart
Copy link
Contributor

Type of change

  • Bug fix

Description

  • Pass unreconciled missing pvtdata to pvtdata store so that it can be deprioritized from subsequent reconciliation attempts (commit3)
  • Refactor tests (commit2)
  • Deprioritized missing private data will be re-attempted every deprioritizedDataReconcilerInterval (commit1)

Signed-off-by: David Enyeart enyeart@us.ibm.com

Signed-off-by: Senthil Nathan N <cendhu@gmail.com>
Signed-off-by: Senthil Nathan N <cendhu@gmail.com>
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
Signed-off-by: Senthil Nathan N <cendhu@gmail.com>
@denyeart denyeart requested a review from a team as a code owner September 16, 2020 21:01
Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

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

Though, its a back-port but I have a few comment that are applicable to the merged PRs in the master as well. They can be addressed in the master and back ported as well.

deprioritizedDataReconcilerInterval := 60 * time.Minute
if viper.IsSet("ledger.pvtdataStore.deprioritizedDataReconcilerInterval") {
deprioritizedDataReconcilerInterval = viper.GetDuration("ledger.pvtdataStore.deprioritizedDataReconcilerInterval")
fmt.Println(deprioritizedDataReconcilerInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover

"ledger.pvtdataStore.collElgProcMaxDbBatchSize": 50000,
"ledger.pvtdataStore.collElgProcDbBatchesInterval": 10000,
"ledger.pvtdataStore.purgeInterval": 1000,
"ledger.pvtdataStore.deprioritizedDataReconcilerInterval": "60m",
Copy link
Contributor

Choose a reason for hiding this comment

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

In the test for explicit configs, better to use a value that is different from the default. Else, hard to verify whether the explicit is being picked up or the default one.

assertMissingDataInfo(t, store, expectedDeprioMissingDataInfo, 2)

require.True(t, store.accessDeprioMissingDataAfter.After(expectedNextAccessDeprioMissingDataTime))
assertMissingDataInfo(t, store, expectedPrioMissingDataInfo, 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is dependent on the config value for DeprioritizedDataReconcilerInterval. For this test, it's better to set that explicitly in line 202.

Comment on lines +250 to +254
store.accessDeprioMissingDataAfter = time.Now()
expectedNextAccessDeprioMissingDataTime := time.Now().Add(store.deprioritizedDataReconcilerInterval)
assertMissingDataInfo(t, store, expectedDeprioMissingDataInfo, 2)

require.True(t, store.accessDeprioMissingDataAfter.After(expectedNextAccessDeprioMissingDataTime))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that using multiple times time.now could cause this check to be flaky on platforms that provide low resolution time. On the other hand, performing equality check is not possible without introducing an interface. I guess that it will be better to be on a safer side and subtract small duration manually before doing the comparison.
e.g.,

  • line 250 can become store.accessDeprioMissingDataAfter = time.Now().Add(-time.Second) to ensure that line 252 passes.
  • Reduce time by a second in 251

In general, in this segment of the code, too many time related variable makes it hard to read. Can you see if the variable names can be shortened.

Comment on lines +250 to +254
store.accessDeprioMissingDataAfter = time.Now()
expectedNextAccessDeprioMissingDataTime := time.Now().Add(store.deprioritizedDataReconcilerInterval)
assertMissingDataInfo(t, store, expectedDeprioMissingDataInfo, 2)

require.True(t, store.accessDeprioMissingDataAfter.After(expectedNextAccessDeprioMissingDataTime))
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears a half check... I guess that better to add a check for the other bound - e.g.,
require.False(t,
store.accessDeprioMissingDataAfter.After(
time.Now().Add(time.Second).Add(store.deprioritizedDataReconcilerInterval))

Comment on lines +76 to +79
// verify missing pvtdata info
require.Equal(t, uint64(2), blk.Block.Header.Number)
h.verifyBlockAndPvtDataSameAs(2, blk)
h.verifyMissingPvtDataSameAs(int(2), expectedMissingPvtDataInfo)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems redundant, as it was verified in the setup function.

Comment on lines +151 to +154
require.Equal(t, uint64(2), blk.Block.Header.Number)
h.verifyBlockAndPvtDataSameAs(2, blk)
h.verifyMissingPvtDataSameAs(int(2), expectedMissingPvtDataInfo)

Copy link
Contributor

Choose a reason for hiding this comment

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

same as above


h.commitPvtDataOfOldBlocks(nil, expectedMissingPvtDataInfo)
for i := 0; i < 5; i++ {
h.verifyMissingPvtDataSameAs(int(2), ledger.MissingPvtDataInfo{})
Copy link
Contributor

Choose a reason for hiding this comment

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

why not int(int(2)) :-) at a couple of other places as well.

# The reconciler would retry deprioritized missing data after every
# deprioritizedDataReconcilerInterval (unit: minutes). Note that the
# interval needs to be greater than the reconcileSleepInterval
deprioritizedDataReconcilerInterval: 60m
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have preferred to keep this config close to reconcileSleepInterval for usability and we could have a check in the code and print a warning if this is relatively smaller than that. However, that would criss-cross in the code unless we make reconciler control this and pass explicitly the category in the call... Per the current code, I am not sure what else can we do, so we can keep this as is.

@denyeart
Copy link
Contributor Author

Comments addressed in #1890 (master) and will be backported as well.

@manish-sethi manish-sethi merged commit a5a6acd into hyperledger:release-2.2 Sep 17, 2020
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

3 participants