You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/11 12:11:33 UTC

[GitHub] [pulsar] liangyepianzhou opened a new pull request, #18437: [fix][test] fix flaky test testRecoverSequenceId

liangyepianzhou opened a new pull request, #18437:
URL: https://github.com/apache/pulsar/pull/18437

   Fixes: https://github.com/apache/pulsar/issues/18396
   
   ### Motivation
   The logic we expected:
    1. Set `maxEntriesPerLedger` = 3
    2. Write three messages into `MlTransactionLog`, such as [3:0] [3:1] [3:2]
    3. Call `rollCurrentLedgerIfFull` to close the old ledger and create a new ledger
    4. ManagedLedger call `maybeUpdateCursorBeforeTrimmingConsumedLedger` in the `createComplete` of ManagedLedger
    5. The cursor position of the transaction log will be update to the earliest position in the new ledger, such as [5: -1]
    6. The expired ledger (ledgerId = 3) will be deleted in `internalTrimLedgers`.
   
   But there is a scheduled task to do flushCursors.
   https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java#L203-L204
   
   Which will call `internalAsyncMarkDelete` and then update the cursor position to [3:2].
   
   https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L1938-L1048
   
   https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L2066
   
   And then the expired ledger (ledger id = 3) can not be deleted in `internalTrimLedgers`.
   https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L2570-L2593
   
   ### Modifications
   There is a `markDeleteLimiter.tryAcquire()` called before `internalAsyncMarkDelete`, we can mock it to make it aways return false.
   https://github.com/apache/pulsar/blob/master/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L1938-L1048
   
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   *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
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `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: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] codecov-commenter commented on pull request #18437: [fix][test] fix flaky test testRecoverSequenceId

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18437:
URL: https://github.com/apache/pulsar/pull/18437#issuecomment-1311635494

   # [Codecov](https://codecov.io/gh/apache/pulsar/pull/18437?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#18437](https://codecov.io/gh/apache/pulsar/pull/18437?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6373180) into [master](https://codecov.io/gh/apache/pulsar/commit/2e878e8aac869bc4500e9d32e5c78bfc5c86614b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2e878e8) will **decrease** coverage by `3.52%`.
   > The diff coverage is `16.66%`.
   
   > :exclamation: Current head 6373180 differs from pull request most recent head c4636ee. Consider uploading reports for the commit c4636ee to get more accurate results
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/pulsar/pull/18437/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/pulsar/pull/18437?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18437      +/-   ##
   ============================================
   - Coverage     40.04%   36.52%   -3.53%     
   + Complexity     8625     1934    -6691     
   ============================================
     Files           687      208     -479     
     Lines         67436    14383   -53053     
     Branches       7221     1570    -5651     
   ============================================
   - Hits          27007     5253   -21754     
   + Misses        37411     8545   -28866     
   + Partials       3018      585    -2433     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `36.52% <16.66%> (-3.53%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/18437?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../java/org/apache/pulsar/client/impl/ClientCnx.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudENueC5qYXZh) | `30.16% <ø> (+30.16%)` | :arrow_up: |
   | [...a/org/apache/pulsar/client/impl/TableViewImpl.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1RhYmxlVmlld0ltcGwuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ar/client/impl/conf/ProducerConfigurationData.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL2NvbmYvUHJvZHVjZXJDb25maWd1cmF0aW9uRGF0YS5qYXZh) | `84.70% <ø> (+84.70%)` | :arrow_up: |
   | [.../transaction/TransactionCoordinatorClientImpl.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3RyYW5zYWN0aW9uL1RyYW5zYWN0aW9uQ29vcmRpbmF0b3JDbGllbnRJbXBsLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...va/org/apache/pulsar/client/impl/ConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NvbnN1bWVySW1wbC5qYXZh) | `15.09% <12.50%> (+15.09%)` | :arrow_up: |
   | [...g/apache/pulsar/client/impl/schema/AvroSchema.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9BdnJvU2NoZW1hLmphdmE=) | `80.70% <100.00%> (+80.70%)` | :arrow_up: |
   | [...che/bookkeeper/mledger/impl/ManagedCursorImpl.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci9pbXBsL01hbmFnZWRDdXJzb3JJbXBsLmphdmE=) | | |
   | [...rg/apache/bookkeeper/mledger/impl/OpReadEntry.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci9pbXBsL09wUmVhZEVudHJ5LmphdmE=) | | |
   | [...va/org/apache/bookkeeper/mledger/util/Futures.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci91dGlsL0Z1dHVyZXMuamF2YQ==) | | |
   | [.../org/apache/pulsar/broker/admin/AdminResource.java](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9BZG1pblJlc291cmNlLmphdmE=) | | |
   | ... and [637 more](https://codecov.io/gh/apache/pulsar/pull/18437/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #18437: [fix][test] fix flaky test testRecoverSequenceId

Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #18437:
URL: https://github.com/apache/pulsar/pull/18437#discussion_r1027020167


##########
pulsar-transaction/coordinator/src/test/java/org/apache/pulsar/transaction/coordinator/MLTransactionMetadataStoreTest.java:
##########
@@ -181,6 +185,18 @@ public void testRecoverSequenceId(boolean isUseManagedLedgerProperties) throws E
         transactionMetadataStore.init(new TransactionRecoverTrackerImpl()).get();
 
         Awaitility.await().until(transactionMetadataStore::checkIfReady);
+        if (isUseManagedLedgerProperties) {
+            //Mock a rateLimiter to avoid the internalMarkDelete call onCursorMarkDeletePositionUpdated
+            Field cursorField = MLTransactionLogImpl.class.getDeclaredField("cursor");
+            cursorField.setAccessible(true);
+            ManagedCursor cursor = (ManagedCursor) cursorField.get(mlTransactionLog);
+            Field rateLimiterFiled = ManagedCursorImpl.class.getDeclaredField("markDeleteLimiter");
+            rateLimiterFiled.setAccessible(true);
+
+            RateLimiter rateLimiter = mock(RateLimiter.class);
+            doReturn(false).when(rateLimiter).tryAcquire();
+            rateLimiterFiled.set(cursor, rateLimiter);
+        }

Review Comment:
   Good suggestion!



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] Technoboy- closed pull request #18437: [fix][test] fix flaky test testRecoverSequenceId

Posted by GitBox <gi...@apache.org>.
Technoboy- closed pull request #18437: [fix][test] fix flaky test testRecoverSequenceId
URL: https://github.com/apache/pulsar/pull/18437


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] Technoboy- merged pull request #18437: [fix][test] fix flaky test testRecoverSequenceId

Posted by GitBox <gi...@apache.org>.
Technoboy- merged PR #18437:
URL: https://github.com/apache/pulsar/pull/18437


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] poorbarcode commented on a diff in pull request #18437: [fix][test] fix flaky test testRecoverSequenceId

Posted by GitBox <gi...@apache.org>.
poorbarcode commented on code in PR #18437:
URL: https://github.com/apache/pulsar/pull/18437#discussion_r1026153145


##########
pulsar-transaction/coordinator/src/test/java/org/apache/pulsar/transaction/coordinator/MLTransactionMetadataStoreTest.java:
##########
@@ -181,6 +185,18 @@ public void testRecoverSequenceId(boolean isUseManagedLedgerProperties) throws E
         transactionMetadataStore.init(new TransactionRecoverTrackerImpl()).get();
 
         Awaitility.await().until(transactionMetadataStore::checkIfReady);
+        if (isUseManagedLedgerProperties) {
+            //Mock a rateLimiter to avoid the internalMarkDelete call onCursorMarkDeletePositionUpdated
+            Field cursorField = MLTransactionLogImpl.class.getDeclaredField("cursor");
+            cursorField.setAccessible(true);
+            ManagedCursor cursor = (ManagedCursor) cursorField.get(mlTransactionLog);
+            Field rateLimiterFiled = ManagedCursorImpl.class.getDeclaredField("markDeleteLimiter");
+            rateLimiterFiled.setAccessible(true);
+
+            RateLimiter rateLimiter = mock(RateLimiter.class);
+            doReturn(false).when(rateLimiter).tryAcquire();
+            rateLimiterFiled.set(cursor, rateLimiter);
+        }

Review Comment:
   We can just ensure the new ledger has been created instead of the old ledger has been deleted, so we can avoid this new logic which avoids mark delete. @congbobo184  How are you feeling?



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org