You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "horizonzy (via GitHub)" <gi...@apache.org> on 2023/03/24 10:14:07 UTC

[GitHub] [pulsar] horizonzy opened a new pull request, #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

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

   <!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/wiki/proposals/PIP.md -->
   The fork pr: https://github.com/horizonzy/pulsar/pull/12
   
   
   ### Motivation
   After #13833, we change the signature of LedgerOffloaderFactory#create.
   
   Before: no offloaderStats.
   ```
       default T create(OffloadPoliciesImpl offloadPolicies,
                        Map<String, String> userMetadata,
                        SchemaStorage schemaStorage,
                        OrderedScheduler scheduler)
               throws IOException {
           return create(offloadPolicies, userMetadata, scheduler);
       }
   ```
   After: add offloaderStats.
   ```
       default T create(OffloadPoliciesImpl offloadPolicies,
                        Map<String, String> userMetadata,
                        SchemaStorage schemaStorage,
                        OrderedScheduler scheduler,
                        LedgerOffloaderStats offloaderStats)
               throws IOException {
           return create(offloadPolicies, userMetadata, scheduler, offloaderStats);
       }
   ```
   
   And in PulsarService#createManagedLedgerOffloader line_1402, it changes the way to create an offloader.
   
   Before: no offloaderStats
   ```
                       return offloaderFactory.create(
                           offloadPolicies,
                           ImmutableMap.of(
                               LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(),
                               LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha(),
                               LedgerOffloader.METADATA_PULSAR_CLUSTER_NAME.toLowerCase(), config.getClusterName()
                           ),
                           schemaStorage,
                           getOffloaderScheduler(offloadPolicies));
   ```
   
   After: add offloaderStats
   ```
   return offloaderFactory.create(
                           offloadPolicies,
                           ImmutableMap.of(
                               LedgerOffloader.METADATA_SOFTWARE_VERSION_KEY.toLowerCase(), PulsarVersion.getVersion(),
                               LedgerOffloader.METADATA_SOFTWARE_GITSHA_KEY.toLowerCase(), PulsarVersion.getGitSha(),
                               LedgerOffloader.METADATA_PULSAR_CLUSTER_NAME.toLowerCase(), config.getClusterName()
                           ),
                           schemaStorage, getOffloaderScheduler(offloadPolicies), this.offloaderStats);
   ```
   
   
   But some users may use the old version LedgerOffloaderFactory in the offloader nar, when pulsar load the offloader nar, it will use the LedgerOffloaderFactory in the offloader nar, the LedgerOffloaderFactory#create has no param `offloaderStats`. Then it will throw an exception as follows:
   ```
   2023-03-23T23:59:42,947 - ERROR - [main:PulsarService@918] - Failed to start Pulsar service: java.lang.AbstractMethodError: Receiver class io.streamnative.tieredstorage.pulsar.PulsarOffloaderFactory does not define or inherit an implementation of the resolved method 'abstract org.apache.bookkeeper.mledger.LedgerOffloader create(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl, java.util.Map, org.apache.bookkeeper.common.util.OrderedScheduler, org.apache.bookkeeper.mledger.LedgerOffloaderStats)' of interface org.apache.bookkeeper.mledger.LedgerOffloaderFactory.
   org.apache.pulsar.broker.PulsarServerException: java.lang.AbstractMethodError: Receiver class io.streamnative.tieredstorage.pulsar.PulsarOffloaderFactory does not define or inherit an implementation of the resolved method 'abstract org.apache.bookkeeper.mledger.LedgerOffloader create(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl, java.util.Map, org.apache.bookkeeper.common.util.OrderedScheduler, org.apache.bookkeeper.mledger.LedgerOffloaderStats)' of interface org.apache.bookkeeper.mledger.LedgerOffloaderFactory.
   	at org.apache.pulsar.broker.PulsarService.createManagedLedgerOffloader(PulsarService.java:1422) ~[classes/:?]
   	at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:780) ~[classes/:?]
   	at org.apache.pulsar.PulsarBrokerStarter$BrokerStarter.start(PulsarBrokerStarter.java:276) ~[classes/:?]
   	at org.apache.pulsar.PulsarBrokerStarter.main(PulsarBrokerStarter.java:356) ~[classes/:?]
   ```
   
   So we should make LedgerOffloaderFactory#create compatible with the previous version, and revert the origin signature to LedgerOffloaderFactory for compatibility.
   
   
   After this PR, the user upgrades the `managed-ledger` dependency(LedgerOffloaderFactory is defined in `managed-ledger`). So the user offloader nar LedgerOffloaderFactory has both methods. One is with offloaderStats, another one is without offloaderStats.
   
   If the pulsar is the old version, it loads the offloader nar, and using LedgerOffloaderFactory#create without offloadStats to create offloader. It works.
   
   If the pulsar is the new version, it loads the offloader nar, and using LedgerOffloaderFactory#create with offloadStats to create the offloader. It also works.
   
   
   
   <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
   
   ### Modifications
   
   <!-- Describe the modifications you've done. -->
   
   ### 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:
   
   <!-- 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: <!-- 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] Technoboy- commented on pull request #19913: [fix][broker]Make LedgerOffloaderFactory can load the old nar.

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#issuecomment-1539509938

   > @codelipenghui @Technoboy- @poorbarcode I think this PR needs to be cherry-picked to branch-2.11 because it's for backporting the old interface.
   
   Done


-- 
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] horizonzy commented on pull request #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "horizonzy (via GitHub)" <gi...@apache.org>.
horizonzy commented on PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#issuecomment-1491187929

   @poorbarcode Could you help to review it again, thanks!


-- 
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 #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#discussion_r1152689729


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java:
##########
@@ -42,20 +42,39 @@
     boolean isDriverSupported(String driverName);
 
     /**
-     * Create a ledger offloader with the provided configuration, user-metadata and scheduler.
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
      *
      * @param offloadPolicies offload policies
      * @param userMetadata user metadata
      * @param scheduler scheduler
      * @return the offloader instance
      * @throws IOException when fail to create an offloader
      */
+    default T create(OffloadPoliciesImpl offloadPolicies,
+             Map<String, String> userMetadata,
+             OrderedScheduler scheduler)
+            throws IOException {
+        return create(offloadPolicies, userMetadata, scheduler, null);

Review Comment:
   After this change, Is it possible to throw a NullPointerEx using the variable `offloaderStats`?
   



-- 
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] hangc0276 commented on pull request #19913: [fix][broker]Make LedgerOffloaderFactory can load the old nar.

Posted by "hangc0276 (via GitHub)" <gi...@apache.org>.
hangc0276 commented on PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#issuecomment-1514525158

   @codelipenghui @Technoboy- @poorbarcode I think this PR needs to be cherry-picked to branch-2.11 because it's for backporting the old interface.


-- 
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 #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#discussion_r1152689729


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java:
##########
@@ -42,20 +42,39 @@
     boolean isDriverSupported(String driverName);
 
     /**
-     * Create a ledger offloader with the provided configuration, user-metadata and scheduler.
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
      *
      * @param offloadPolicies offload policies
      * @param userMetadata user metadata
      * @param scheduler scheduler
      * @return the offloader instance
      * @throws IOException when fail to create an offloader
      */
+    default T create(OffloadPoliciesImpl offloadPolicies,
+             Map<String, String> userMetadata,
+             OrderedScheduler scheduler)
+            throws IOException {
+        return create(offloadPolicies, userMetadata, scheduler, null);

Review Comment:
   After this change, Is it possible to throw a NullPointerEx using the variable `offloaderStats`?
   
   https://github.com/apache/pulsar/blob/55523ac8f31fd6d54aacba326edef1f53028877e/tiered-storage/file-system/src/main/java/org/apache/bookkeeper/mledger/offload/filesystem/impl/FileSystemManagedLedgerOffloader.java#L226-L228
   
   Such as line-227 above or other places.
   



-- 
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] horizonzy commented on a diff in pull request #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "horizonzy (via GitHub)" <gi...@apache.org>.
horizonzy commented on code in PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#discussion_r1154051212


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java:
##########
@@ -42,20 +42,37 @@
     boolean isDriverSupported(String driverName);
 
     /**
-     * Create a ledger offloader with the provided configuration, user-metadata and scheduler.
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
      *
      * @param offloadPolicies offload policies
      * @param userMetadata user metadata
      * @param scheduler scheduler
      * @return the offloader instance
      * @throws IOException when fail to create an offloader
      */
+    T create(OffloadPoliciesImpl offloadPolicies,
+             Map<String, String> userMetadata,
+             OrderedScheduler scheduler)
+            throws IOException;
+
+
+    /**
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
+     *
+     * @param offloadPolicies offload policies
+     * @param userMetadata user metadata
+     * @param scheduler scheduler
+     * @param offloaderStats offloaderStats
+     * @return the offloader instance
+     * @throws IOException when fail to create an offloader
+     */
     T create(OffloadPoliciesImpl offloadPolicies,
              Map<String, String> userMetadata,
              OrderedScheduler scheduler,
              LedgerOffloaderStats offloaderStats)
         throws IOException;

Review Comment:
   Yes.



-- 
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 #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- closed pull request #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.
URL: https://github.com/apache/pulsar/pull/19913


-- 
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 merged pull request #19913: [fix][broker]Make LedgerOffloaderFactory can load the old nar.

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode merged PR #19913:
URL: https://github.com/apache/pulsar/pull/19913


-- 
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] horizonzy closed pull request #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "horizonzy (via GitHub)" <gi...@apache.org>.
horizonzy closed pull request #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.
URL: https://github.com/apache/pulsar/pull/19913


-- 
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] horizonzy commented on a diff in pull request #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "horizonzy (via GitHub)" <gi...@apache.org>.
horizonzy commented on code in PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#discussion_r1152699146


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java:
##########
@@ -42,20 +42,39 @@
     boolean isDriverSupported(String driverName);
 
     /**
-     * Create a ledger offloader with the provided configuration, user-metadata and scheduler.
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
      *
      * @param offloadPolicies offload policies
      * @param userMetadata user metadata
      * @param scheduler scheduler
      * @return the offloader instance
      * @throws IOException when fail to create an offloader
      */
+    default T create(OffloadPoliciesImpl offloadPolicies,
+             Map<String, String> userMetadata,
+             OrderedScheduler scheduler)
+            throws IOException {
+        return create(offloadPolicies, userMetadata, scheduler, null);

Review Comment:
   Thanks for your reminder. Here we shouldn't make the method default. This method won't invoke in pulsar directly. In the pulsar master branch, it only invokes the method with the param `offloaderStats`. This method is compatible with the nar package, let the user implements by themselves.
   



-- 
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 #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#discussion_r1154037265


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java:
##########
@@ -42,20 +42,37 @@
     boolean isDriverSupported(String driverName);
 
     /**
-     * Create a ledger offloader with the provided configuration, user-metadata and scheduler.
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
      *
      * @param offloadPolicies offload policies
      * @param userMetadata user metadata
      * @param scheduler scheduler
      * @return the offloader instance
      * @throws IOException when fail to create an offloader
      */
+    T create(OffloadPoliciesImpl offloadPolicies,
+             Map<String, String> userMetadata,
+             OrderedScheduler scheduler)
+            throws IOException;
+
+
+    /**
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
+     *
+     * @param offloadPolicies offload policies
+     * @param userMetadata user metadata
+     * @param scheduler scheduler
+     * @param offloaderStats offloaderStats
+     * @return the offloader instance
+     * @throws IOException when fail to create an offloader
+     */
     T create(OffloadPoliciesImpl offloadPolicies,
              Map<String, String> userMetadata,
              OrderedScheduler scheduler,
              LedgerOffloaderStats offloaderStats)
         throws IOException;

Review Comment:
   Since this method `T create(offloadPolicies, userMetadata, scheduler, offloaderStats),` the changes in https://github.com/apache/pulsar/pull/13833 can not guarantee forward compatibility, right?



-- 
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 #19913: [fix][broker]Make LedgerOffloaderFactory compatible with old version.

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #19913:
URL: https://github.com/apache/pulsar/pull/19913#discussion_r1155096375


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java:
##########
@@ -42,20 +42,37 @@
     boolean isDriverSupported(String driverName);
 
     /**
-     * Create a ledger offloader with the provided configuration, user-metadata and scheduler.
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
      *
      * @param offloadPolicies offload policies
      * @param userMetadata user metadata
      * @param scheduler scheduler
      * @return the offloader instance
      * @throws IOException when fail to create an offloader
      */
+    T create(OffloadPoliciesImpl offloadPolicies,
+             Map<String, String> userMetadata,
+             OrderedScheduler scheduler)
+            throws IOException;
+
+
+    /**
+     * Create a ledger offloader with the provided configuration, user-metadata, scheduler and offloaderStats.
+     *
+     * @param offloadPolicies offload policies
+     * @param userMetadata user metadata
+     * @param scheduler scheduler
+     * @param offloaderStats offloaderStats
+     * @return the offloader instance
+     * @throws IOException when fail to create an offloader
+     */
     T create(OffloadPoliciesImpl offloadPolicies,
              Map<String, String> userMetadata,
              OrderedScheduler scheduler,
              LedgerOffloaderStats offloaderStats)
         throws IOException;

Review Comment:
   There are four scenarios:
   - `old nar & old broker`: I think it will work. 
   - `old nar & new broker`: It will not work, and we do not guarantee forward compatibility. So it is okay.
   - `new nar & old broker`: The broker will call the method without `@param offloaderStats.` I think it will work.
     - we should make the method without `@param offloaderStats` non-default.
   - `new nar & new broker` I think it will work.
   
   All things are good.



-- 
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