Reidddddd commented on code in PR #3813:
URL: https://github.com/apache/bookkeeper/pull/3813#discussion_r1118461347
##########
stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java:
##########
@@ -382,7 +382,9 @@ private synchronized void completeAllocation(LedgerHandle
lh) {
allocatePath, DistributedLogConstants.EMPTY_BYTES, (int)
version.getLongVersion());
ZKVersionedSetOp commitOp = new ZKVersionedSetOp(zkSetDataOp, this);
tryObtainTxn.addOp(commitOp);
- setPhase(Phase.HANDING_OVER);
+ if (this.phase != Phase.ALLOCATED) {
Review Comment:
> It is common to get here when phase is ALLOCATED see here
>
>
https://github.com/apache/bookkeeper/blob/e6722848e0a599f215e68e1340196c9dfe8e906e/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java#L432
>
> or you can get to here from this path
>
>
https://github.com/apache/bookkeeper/blob/e6722848e0a599f215e68e1340196c9dfe8e906e/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java#L287
>
> maybe it is clearer to not use "!=" but to explicitly enumerate the
"phases" in which you are allowed to transition to `HANDING_OVER` .
>
> Could you please change the condition to a "positive" condition ? also we
could add assertions and fail in case we reach to this point in an unexpected
case
>
> if using the phase is not enough to discriminate the reason why to set
HANDING_OVER maybe we could change the signature of this method and pass the
expected "nextPhase" or something like that
https://github.com/apache/bookkeeper/blob/e6722848e0a599f215e68e1340196c9dfe8e906e/stream/distributedlog/core/src/main/java/org/apache/distributedlog/bk/SimpleLedgerAllocator.java#L287
Do you feel this piece is weird?
ERROR, HANDLING_OVER, HANDED_OVER will lead to exception, so only ALLOCATING
and ALLOCATED will pass the check, then the
**completeAllocation(allocatedLh);**, will change the ALLOCATING/ALLOCATED to
HANDLING_OVER.
I'm not familiar with the codes, but is the state machine buggy? Normally, I
feel should be like this:
HANDLING_OVER > HANDED_OVER > ALLOCATING > ALLOCATED, all these 4 states can
point to ERROR. But when i went through the codes, seems it is not, just as I
mentioned.
Are you suggesting to a big changes? (mine is too simple)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]