pdolif opened a new pull request, #25434: URL: https://github.com/apache/pulsar/pull/25434
Fixes #25390 ### Motivation The test `ManagedCursorPropertiesTest.testUpdateCursorPropertiesConcurrent` is flaky. The test performs 3 property updates concurrently. It happens that an update is lost, and then the test fails. It seems the changes in #22411 introduced the flakiness. Before the PR, the order of lines in `ManagedCursorImpl.computeCursorProperties()` was: ```java final Stat lastCursorLedgerStat = ManagedCursorImpl.this.cursorLedgerStat; Map<String, String> newProperties = updateFunction.apply(ManagedCursorImpl.this.cursorProperties); ... ledger.getStore().asyncUpdateCursorInfo(...) ``` In the PR, it was changed to: ```java Map<String, String> newProperties = updateFunction.apply(ManagedCursorImpl.this.cursorProperties); ... final Stat lastCursorLedgerStat = ManagedCursorImpl.this.cursorLedgerStat; ledger.getStore().asyncUpdateCursorInfo(...) ``` `cursorLedgerStat` contains the version that is used when updating in the MetadataStore and that is checked against the current version of the stored data. If the `cursorLedgerStat`/version is read after the `newProperties` are calculated, an update applied on outdated cursor properties may succeed. If the order is changed back again, and the `cursorLedgerStat`/version is read before `newProperties` are calculated, this should not happen anymore. ### Modifications This PR changes back the order to what it was before #22411. The test introduced in #22411 still passes. ### Verifying this change - [x] Make sure that the change passes the CI checks. This change is already covered by existing tests. ### Does this pull request potentially affect one of the following parts: <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> *If the box was checked, please highlight the changes* - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: https://github.com/pdolif/pulsar/pull/22 -- 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]
