GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][broker] PIP-428: Fix corrupted topic policies issues with sequential topic policy updates by lhotari · Pull Request #24427 · apache/pulsar

Conversation

@lhotari

@lhotari lhotari commented Jun 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fixes #24393
Fixes #21303

Motivation

There's a long time issue where topic policies get corrupted as a result of sequential or concurrent topic policy updates.
This PR contains the implementation of
"PIP-428: Change TopicPoliciesService interface to fix consistency issues". Please refer to the PIP document at https://github.com/apache/pulsar/blob/master/pip/pip-428.md for the broader context.

Modifications

  • Check the PIP-428 document for an overview.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Technoboy- reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@lhotari lhotari added this to the 4.1.0 milestone Jun 18, 2025
@lhotari
lhotari requested review from BewareMyPower, codelipenghui, dao-jun, liangyepianzhou, merlimat, nodece and poorbarcode June 18, 2025 20:12
@lhotari lhotari self-assigned this Jun 18, 2025
@lhotari lhotari added the ready-to-test label Jun 18, 2025
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Jun 18, 2025
@lhotari lhotari mentioned this pull request Jun 18, 2025
[Bug] Applying Pulsar Topic Policies fails when multiple policies are updated in a short period of time #24393
Closed
2 of 3 tasks
@lhotari
lhotari requested a review from gaoran10 June 18, 2025 20:20
@lhotari lhotari mentioned this pull request Jun 18, 2025
[pip] PIP-428: Change TopicPoliciesService interface to fix consistency issues #24428
Merged
1 of 4 tasks
@codecov-commenter

codecov-commenter commented Jun 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.30702% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.31%. Comparing base (95dcb58) to head (a4d3924).
⚠️ Report is 35 commits behind head on master.

Files with missing lines Patch % Lines
.../service/SystemTopicBasedTopicPoliciesService.java 83.33% 17 Missing and 10 partials ⚠️
...pulsar/broker/admin/impl/PersistentTopicsBase.java 90.55% 0 Missing and 22 partials ⚠️
...che/pulsar/common/policies/data/TopicPolicies.java 80.95% 3 Missing and 5 partials ⚠️
...sar/common/policies/data/SubscriptionPolicies.java 50.00% 1 Missing and 1 partial ⚠️
...rg/apache/pulsar/broker/service/BrokerService.java 0.00% 0 Missing and 1 partial ⚠️
...ar/common/policies/data/InactiveTopicPolicies.java 50.00% 1 Missing ⚠️
...lsar/common/policies/data/PersistencePolicies.java 50.00% 1 Missing ⚠️
...pache/pulsar/common/policies/data/PublishRate.java 50.00% 1 Missing ⚠️
...pulsar/common/policies/data/RetentionPolicies.java 50.00% 1 Missing ⚠️
...che/pulsar/common/policies/data/SubscribeRate.java 50.00% 1 Missing ⚠️
... and 2 more
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24427      +/-   ##
============================================
+ Coverage     73.74%   74.31%   +0.57%     
- Complexity    33174    33224      +50     
============================================
  Files          1857     1885      +28     
  Lines        146500   146943     +443     
  Branches      16835    16927      +92     
============================================
+ Hits         108041   109208    +1167     
+ Misses        29828    29034     -794     
- Partials       8631     8701      +70     
Flag Coverage Δ
inttests 26.66% <21.71%> (?)
systests 22.72% <7.67%> (?)
unittests 73.80% <84.86%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...he/pulsar/broker/service/TopicPoliciesService.java 96.15% <ø> (+12.82%) ⬆️
...rg/apache/pulsar/broker/service/BrokerService.java 83.94% <0.00%> (ø)
...ar/common/policies/data/InactiveTopicPolicies.java 50.00% <50.00%> (ø)
...lsar/common/policies/data/PersistencePolicies.java 83.33% <50.00%> (-3.04%) ⬇️
...pache/pulsar/common/policies/data/PublishRate.java 71.42% <50.00%> (-2.26%) ⬇️
...pulsar/common/policies/data/RetentionPolicies.java 81.81% <50.00%> (-3.19%) ⬇️
...che/pulsar/common/policies/data/SubscribeRate.java 73.68% <50.00%> (-2.79%) ⬇️
...ar/common/policies/data/impl/BacklogQuotaImpl.java 91.66% <50.00%> (-2.46%) ⬇️
...ar/common/policies/data/impl/DispatchRateImpl.java 95.45% <50.00%> (-4.55%) ⬇️
...sar/common/policies/data/SubscriptionPolicies.java 40.00% <50.00%> (+40.00%) ⬆️
... and 3 more

... and 212 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari lhotari changed the title [WIP][fix][broker] Fix corrupted topic policies issues with sequential topic policy updates [fix][broker] Fix corrupted topic policies issues with sequential topic policy updates Jun 24, 2025
@lhotari
Fix corrupted topic policies issue with topic policy updates
d4ad9ee
@lhotari
lhotari force-pushed the lh-fix-topic-policy-mutations branch from 0312bf6 to d4ad9ee Compare August 12, 2025 06:38
@lhotari lhotari mentioned this pull request Aug 13, 2025
[fix] [broker] Ensure policy cache is updated before updateTopicPoliciesAsync returns. #21030
Closed
2 of 15 tasks
@lhotari
Merge remote-tracking branch 'origin/master' into lh-fix-topic-policy…
0418884
…-mutations
@BewareMyPower BewareMyPower changed the title [fix][broker] Fix corrupted topic policies issues with sequential topic policy updates [fix][broker] PIP-428: Fix corrupted topic policies issues with sequential topic policy updates Aug 25, 2025
BewareMyPower
BewareMyPower reviewed Aug 25, 2025
View reviewed changes
Comment thread ...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

BewareMyPower
BewareMyPower reviewed Aug 25, 2025
View reviewed changes
Comment thread ...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

BewareMyPower
BewareMyPower reviewed Aug 25, 2025
View reviewed changes
Comment thread ...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

BewareMyPower
BewareMyPower reviewed Aug 25, 2025
View reviewed changes
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

lhotari added 5 commits August 25, 2025 11:24
@lhotari
Merge remote-tracking branch 'origin/master' into lh-fix-topic-policy…
0c9ccb4
…-mutations
@lhotari
Address review comment about "retentionToSet == null" parameter
bd277b4
@lhotari
Address review comment in internalRemoveEntryFilters about the skipUp…
88887f7
…dateWhenTopicPolicyDoesntExist parameter
@lhotari
Address review comment about sendTopicPolicyEventInternal's deleteAsync
188a64d
@lhotari
Address review feedback about calling notifyListener
765cb27
Technoboy-
Technoboy- reviewed Aug 25, 2025
View reviewed changes
Comment thread ...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Technoboy-
Technoboy- reviewed Aug 25, 2025
View reviewed changes
Comment thread ...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@coderzc coderzc added the type/PIP label Aug 25, 2025
lhotari added 3 commits August 25, 2025 16:10
@lhotari
Address review feedback about invalidating writer when there's an exc…
1601441
…eption
@lhotari
Rename parameter name for better clarity
263f702
@lhotari
Add comment about invalidating the cached writer
1e69ada
@lhotari
lhotari requested a review from Technoboy- August 25, 2025 13:13
Technoboy-
Technoboy- approved these changes Aug 25, 2025
View reviewed changes
lhotari added 3 commits August 25, 2025 16:58
@lhotari
Avoid looking up listeners twice
9cdc06e
@lhotari
Fix PIP-422 keepGlobalPolicies
d0718d8
@lhotari
Fix invalid test OneWayReplicatorUsingGlobalZKTest.testDeletePartitio…
a4d3924
…nedTopic

- it was relying on previously invalid behavior
@lhotari
lhotari merged commit e5e7981 into apache:master Aug 26, 2025
@lhotari lhotari added the release/4.0.7 label Aug 28, 2025
@lhotari

lhotari commented Aug 28, 2025

Copy link
Copy Markdown
Member Author

dev mailing list thread to cherry-pick to branch-4.0: https://lists.apache.org/thread/ljnhcm4pgl933kc75ftgz9yzmy03rdqg

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotari added a commit that referenced this pull request Aug 28, 2025
@lhotari
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
f9c3845
…ntial topic policy updates (#24427)

(cherry picked from commit e5e7981)
@lhotari lhotari added the cherry-picked/branch-4.0 label Aug 28, 2025
@lhotari lhotari mentioned this pull request Aug 28, 2025
[Bug] OneWayReplicatorTest/OneWayReplicatorUsingGlobalZKTest.testDeleteRemoteTopicByGlobalPolicy fails in branch-4.0 #24670
Closed
2 of 3 tasks
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 28, 2025
@lhotari @manas-ctds
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
32ed9bf
…ntial topic policy updates (apache#24427)

(cherry picked from commit e5e7981)
(cherry picked from commit f9c3845)
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Sep 10, 2025
@lhotari @Technoboy-
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
7ae63e5
…ntial topic policy updates (apache#24427)

(cherry picked from commit e5e7981)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 12, 2025
@lhotari @srinath-ctds
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
0dc8580
…ntial topic policy updates (apache#24427)

(cherry picked from commit e5e7981)
(cherry picked from commit f9c3845)
nborisov pushed a commit to nborisov/pulsar that referenced this pull request Sep 12, 2025
@lhotari Nikolai Borisov
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
21a788c
…ntial topic policy updates (apache#24427)

(cherry picked from commit e5e7981)
@nodece

nodece commented Sep 17, 2025

Copy link
Copy Markdown
Member

@lhotari This PR fixes NullPointerException:

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.atomic.AtomicInteger.incrementAndGet()" because the return value of "java.util.Map.get(Object)" is null

  at org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService.addOwnedNamespaceBundleAsync(SystemTopicBasedTopicPoliciesService.java:405) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService$2.onLoad(SystemTopicBasedTopicPoliciesService.java:509) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.notifyNamespaceBundleOwnershipListener(NamespaceService.java:1322) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.onNamespaceBundleOwned(NamespaceService.java:1285) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.OwnershipCache.lambda$tryAcquiringOwnership$3(OwnershipCache.java:218) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:684) ~[?:?]

  at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:662) ~[?:?]

  at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2168) ~[?:?]

  at org.apache.pulsar.broker.namespace.OwnershipCache.tryAcquiringOwnership(OwnershipCache.java:216) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.searchForCandidateBroker(NamespaceService.java:631) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.lambda$findBrokerServiceUrl$10(NamespaceService.java:466) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]

  at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]

  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]

  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]

  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

  at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.124.Final.jar:4.1.124.Final]

  at java.lang.Thread.run(Thread.java:840) ~[?:?]

Do you consider fixing this on the branch-3.0?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari

lhotari commented Sep 17, 2025

Copy link
Copy Markdown
Member Author

Do you consider fixing this on the branch-3.0?

@nodece please propose on the mailing list

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodece

nodece commented Sep 18, 2025

Copy link
Copy Markdown
Member

@lhotari, It seems that fixing the NullPointerException may be sufficient.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodece

nodece commented Sep 18, 2025

Copy link
Copy Markdown
Member

I submitted #24758 to the branch-3.0.

lhotari reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
@lhotari @KannarFr
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
ea11e13
…ntial topic policy updates (apache#24427)
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
@lhotari @walkinggo
[fix][broker] PIP-428: Fix corrupted topic policies issues with seque…
0a1abca
…ntial topic policy updates (apache#24427)
Demogorgon314 added a commit to Demogorgon314/kop that referenced this pull request Apr 15, 2026
@Demogorgon314
Fix build issue caused by upstream interface changes (streamnative#1447)
d10867d
### Motivation

apache/pulsar#24623:
Updated:
```
public static EntryImpl create(Position position, ByteBuf data)
```
to 
```
public static EntryImpl create(Position position, ByteBuf data, int expectedReadCount)
```

apache/pulsar#24427: 
Updated: 
```
CompletableFuture<Void> updateTopicPoliciesAsync(TopicName topicName, TopicPolicies policies);
```
to
```
    CompletableFuture<Void> updateTopicPoliciesAsync(TopicName topicName,
                                                     boolean isGlobalPolicy,
                                                     boolean skipUpdateWhenTopicPolicyDoesntExist,
                                                     Consumer<TopicPolicies> policyUpdater);
```

### Modifications

Fix build issue caused by upstream interface changes
This was referenced Oct 23, 2026
[fix][broker] fix topic policy is updated incorrectly when continuously use pulsar-admin to set policy #21026
Closed
[Bug] Topic policy is updated incorrectly when continuously use pulsar-admin to set policy #21024
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@BewareMyPower BewareMyPower BewareMyPower approved these changes
@Technoboy- Technoboy- Technoboy- approved these changes
@merlimat merlimat Awaiting requested review from merlimat
@codelipenghui codelipenghui Awaiting requested review from codelipenghui
@nodece nodece Awaiting requested review from nodece
@dao-jun dao-jun Awaiting requested review from dao-jun
@poorbarcode poorbarcode Awaiting requested review from poorbarcode
@liangyepianzhou liangyepianzhou Awaiting requested review from liangyepianzhou
@gaoran10 gaoran10 Awaiting requested review from gaoran10

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@lhotari lhotari

Labels

cherry-picked/branch-4.0 doc-not-needed Your PR changes do not impact docs ready-to-test release/4.0.7 type/PIP

Projects

None yet

Milestone

4.1.0

Development

Successfully merging this pull request may close these issues.

[Bug] Applying Pulsar Topic Policies fails when multiple policies are updated in a short period of time [Bug] Thread safety issues with topic policy mutations

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@lhotari @codecov-commenter @nodece @Technoboy- @BewareMyPower @coderzc
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.