ISSUE-2770: Code refactor calling ledgerExists two times.#2903
ISSUE-2770: Code refactor calling ledgerExists two times.#2903jadireddi wants to merge 1 commit intoapache:masterfrom
Conversation
| if (!interleavedLedgerStorage.ledgerExists(ledgerId)) { | ||
| EntryKeyValue kv = memTable.getLastEntry(ledgerId); | ||
| if (null == kv) { | ||
| return interleavedLedgerStorage.ledgerExists(ledgerId); |
There was a problem hiding this comment.
I have seen this patch before.
Maybe there is already another open PR
My question is...
Why this code was written the way it is?
In order to deal with some possible race condition ?
@merlimat do you know?
There was a problem hiding this comment.
Is there any case that line 145 returns false, but line 148 returns true?
| if (!interleavedLedgerStorage.ledgerExists(ledgerId)) { | ||
| EntryKeyValue kv = memTable.getLastEntry(ledgerId); | ||
| if (null == kv) { | ||
| return interleavedLedgerStorage.ledgerExists(ledgerId); |
There was a problem hiding this comment.
As the comment said, checking the skip list is an O(logN) operation compared to the O(1) for the ledgerCache.
My thought that means the memTable.getLastEntry(ledgerId) is time consuming operation. After checking that, the ledgerCache may be filled so we check it again.
|
Remove it to the next release because I think it needs more people to confirm. |
|
fix old workflow,please see #3455 for detail |
Changes
SortedLedgerStorage's method
ledgerExists, is being called two times to check for the ledger exists or not. Refactored to call only once.Master Issue: #2770