-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker]Make LedgerOffloaderFactory can load the old nar. #19913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix][broker]Make LedgerOffloaderFactory can load the old nar. #19913
Conversation
| Map<String, String> userMetadata, | ||
| OrderedScheduler scheduler) | ||
| throws IOException { | ||
| return create(offloadPolicies, userMetadata, scheduler, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, Is it possible to throw a NullPointerEx using the variable offloaderStats?
Lines 226 to 228 in 55523ac
| long cost = System.nanoTime() - startReadTime; | |
| this.offloaderStats.recordReadLedgerLatency(topicName, cost, TimeUnit.NANOSECONDS); | |
| semaphore.acquire(); |
Such as line-227 above or other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
@poorbarcode Could you help to review it again, thanks! |
| Map<String, String> userMetadata, | ||
| OrderedScheduler scheduler, | ||
| LedgerOffloaderStats offloaderStats) | ||
| throws IOException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this method T create(offloadPolicies, userMetadata, scheduler, offloaderStats), the changes in #13833 can not guarantee forward compatibility, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 offloaderStatsnon-default.
- we should make the method without
new nar & new brokerI think it will work.
All things are good.
| Map<String, String> userMetadata, | ||
| OrderedScheduler scheduler, | ||
| LedgerOffloaderStats offloaderStats) | ||
| throws IOException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 offloaderStatsnon-default.
- we should make the method without
new nar & new brokerI think it will work.
All things are good.
|
@codelipenghui @Technoboy- @poorbarcode I think this PR needs to be cherry-picked to branch-2.11 because it's for backporting the old interface. |
After #13833, we change the signature of LedgerOffloaderFactory#create. 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. Modifications: Make LedgerOffloaderFactory can load the old nar.
Done |
The fork pr: horizonzy#12
Motivation
After #13833, we change the signature of LedgerOffloaderFactory#create.
Before: no offloaderStats.
After: add offloaderStats.
And in PulsarService#createManagedLedgerOffloader line_1402, it changes the way to create an offloader.
Before: no offloaderStats
After: add 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: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-ledgerdependency(LedgerOffloaderFactory is defined inmanaged-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.
Modifications
Verifying this change
(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:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: