-
Notifications
You must be signed in to change notification settings - Fork 969
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
Use ConditionalWork for history replay in catchup #2194
Use ConditionalWork for history replay in catchup #2194
Conversation
7800db1
to
e1cd566
Compare
if (mWorkStarted && !mConditionedWork->isDone()) | ||
{ | ||
mConditionedWork->crankWork(); | ||
return false; |
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.
Does that mean that aborting started ConditionalWork is not possible?
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.
Not sure what you mean: onAbort
returns whether Work is done aborting or not, so that BasicWork can proceed appropriately. ConditionalWork
will keep getting scheduled to run onAbort
until mConditionedWork
is done aborting. At that point, ConditionalWork
is safe to abort itself.
// Conditioned work was aborted | ||
REQUIRE(conditionedWork->getState() == BasicWork::State::WORK_ABORTED); | ||
// Dependent work was never started (internally, in PENDING state, | ||
// enforced by its destructor) |
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 you mean constructor here?
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.
No, I mean destructor, which asserts that BasicWork is in proper state.
src/work/test/WorkTests.cpp
Outdated
{ | ||
clock.crank(); | ||
} | ||
CHECK(conditionedWork->getState() == BasicWork::State::WORK_WAITING); |
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.
That looks redundant.
src/catchup/ApplyCheckpointWork.cpp
Outdated
mHdrIn.close(); | ||
mTxIn.close(); | ||
mFilesOpen = false; | ||
} | ||
|
||
void | ||
ApplyLedgerChainWork::openCurrentInputFiles() | ||
ApplyCheckpointWork::openCurrentInputFiles() |
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.
Could be renamed to openInputFiles. If this only works on one checkpoint there is only one set of files, so "current" is redundant.
@@ -45,7 +45,6 @@ BatchWork::doWork() | |||
} | |||
|
|||
addMoreWorkIfNeeded(); | |||
mApp.getCatchupManager().logAndUpdateCatchupStatus(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.
Nice!
src/catchup/ApplyCheckpointWork.h
Outdated
LedgerRange const mRange; | ||
uint32_t mCurrSeq; | ||
uint32_t mCheckpoint; | ||
// Apply checkpoint until given ledger. Otherwise, apply checkpoint in full |
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.
pick a name that clarifies that this is a ledger number
src/catchup/ApplyCheckpointWork.h
Outdated
LedgerHeaderHistoryEntry& lastApplied); | ||
~ApplyLedgerChainWork() = default; | ||
ApplyCheckpointWork(Application& app, TmpDir const& downloadDir, | ||
uint32_t checkpoint, uint32_t boundary = 0); |
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 don't like the use of 0 like this in a low level class as it's quite error prone.
I think it's probably better to keep a LedgerRange
here, and force the caller to make a decision on what the upper range is.
This PR then just needs to enforce that that LedgerRange has the following properties:
- low is a checkpoint
- doesn't span multiple checkpoints
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.
Agreed that it's safer, updated.
20e3508
to
2063642
Compare
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.
let's move all calls to logAndUpdateCatchupStatus
from the hierarchy into CatchupWork::doWork
src/catchup/ApplyCheckpointWork.cpp
Outdated
{ | ||
return State::WORK_SUCCESS; | ||
mApp.getCatchupManager().logAndUpdateCatchupStatus(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.
I'd call logAndUpdateCatchupStatus
regardless (before the if) - it seems arbitrary to only call it if result is 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.
I would also move the done
case to its own it (probably done first) as to make the code easier to read (else will be deciding between running or failure)
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.
done.
2063642
to
ad674d6
Compare
r+ ad674d6 |
…_work Use ConditionalWork for history replay in catchup Reviewed-by: MonsieurNicolas
Resolves #1951