merlimat opened a new pull request #11886:
URL: https://github.com/apache/pulsar/pull/11886
### Motivation
Fixes the flakiness in `ZKSessionTest.testReacquireLocksAfterSessionLost`
test:
```
Error:
testReacquireLocksAfterSessionLost(org.apache.pulsar.metadata.ZKSessionTest)
Time elapsed: 22.547 s <<< FAILURE!
java.lang.AssertionError: expected [Reconnected] but found [null]
at org.testng.Assert.fail(Assert.java:99)
at org.testng.Assert.failNotEquals(Assert.java:1037)
at org.testng.Assert.assertEqualsImpl(Assert.java:140)
at org.testng.Assert.assertEquals(Assert.java:122)
at org.testng.Assert.assertEquals(Assert.java:617)
at
org.apache.pulsar.metadata.ZKSessionTest.testReacquireLocksAfterSessionLost(ZKSessionTest.java:126)
```
The root cause for the test failing is that, when the session is forcefully
expired, we're also getting a watch triggered for the deletion of the ephemeral
node. That means that, depending on the timing of the watch, we can end up
trying to revalidate the lock while we're not connected to ZK.
When that happens, we should expire the lock, instead we only expire it if
we get a BadVersion on the put operation, which means that someone else took
the lock over.
This way, we can retry the validation when we're finally reconnected to ZK.
--
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]