[
https://issues.apache.org/jira/browse/QPID-6541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14543700#comment-14543700
]
Lorenz Quack commented on QPID-6541:
------------------------------------
Looks good.
One small improvement: I think line 1078 and 1079 can be removed and
enqueueImmediately in line 1071 should be initialized to false.
Here is my reasoning for the above:
- _recovering is guaranteed to follow this progression: RECOVERING ->
COMPLETING_RECOVERY -> RECOVERED
- just before line 1074 we know that _enqueuingWhileRecovering > 0 but don't
know anything about _recovering
- now we consider the state at that moment in three different cases:
1) _recovering == RECOVERED
because of _recovering's guaranteed progression we can never enter the if
statement in 1074
2) _recovering == COMPLETING_RECOVERY
again because of the guaranteed progression of _recovery we can never
enter the if statement in 1074
3) _recovering == RECOVERING
this means the _recovering.compareAndSet(RECOVERING, COMPLETING_RECOVERY)
in line 1121 has not yet executed and more importantly now thread has exited
the while loop in 1123. furthermore no thread can exit that loop because we
know (see above) that _enqueuingWhileRecovering > 0 until we safely added the
request to the _postRecoveryQueue and decrement _enqueuingWhileRecovering. Now
enqueueFromPostRecoveryQueue can take care of it.
In case you agree with my assessment I'll attach the small patch.
> [Java Broker] In rare cases it is possible for newly arrived messages to be
> enqueued ahead of recovering messages in asynchronous recovery
> ------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: QPID-6541
> URL: https://issues.apache.org/jira/browse/QPID-6541
> Project: Qpid
> Issue Type: Bug
> Components: Java Broker
> Reporter: Rob Godfrey
> Assignee: Lorenz Quack
> Fix For: 6.0 [Java]
>
>
> There is a possibility that a message is enqueued just as recovery is
> completing leading to an out of order enqueue. This can be prevented by
> being more careful about checking state while moving from "recovering" to
> "recovered"
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]