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][test] Fix OneWayReplicatorSchemaValidationEnforcedTest racing the replicator's remote topic creation by lhotari · Pull Request #26382 · apache/pulsar

Conversation

@lhotari

@lhotari lhotari commented Aug 19, 2026

Copy link
Copy Markdown
Member

Motivation

testReplicationWithAvroSchemaWithSchemaValidationEnforced creates the topic in the local cluster (r1) first and only then in the remote cluster (r2):

// create the topic and schema in the local cluster (r1)
admin1.topics().createNonPartitionedTopic(topicName);
admin1.schemas().createSchema(topicName, myClassSchema.getSchemaInfo());
// create the topic and schema in the remote cluster (r2)
admin2.topics().createNonPartitionedTopic(topicName);   // <-- fails

Creating the topic on r1 starts the replicator, and the replicator creates the missing topic on the remote cluster itself, via GeoPersistentReplicator#createRemoteTopicIfDoesNotExist:

https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/GeoPersistentReplicator.java#L112

The test's own admin2.topics().createNonPartitionedTopic(...) therefore races that create and fails with:

org.apache.pulsar.client.admin.PulsarAdminException$ConflictException: This topic already exists
	at org.apache.pulsar.client.admin.internal.TopicsImpl.createNonPartitionedTopic(TopicsImpl.java:322)
	at org.apache.pulsar.broker.service.OneWayReplicatorSchemaValidationEnforcedTest.testReplicationWithAvroSchemaWithSchemaValidationEnforced(...)

The broker request log shows the sequence plainly — the r2 topic is created by the replicator's admin client (204), and the test's own create then gets 409:

PUT /admin/v2/persistent/.../tp_...  204   (r1, the test)
PUT /admin/v2/persistent/.../tp_...  204   (r2, the replicator)
PUT /admin/v2/persistent/.../tp_...  409   (r2, the test)  <-- "This topic already exists"

The race has been latent since the test was added. #25437 then added testReplicationReconnectWithSchemaValidationEnforced to the same class; TestNG runs the new test first, and it leaves the two-cluster fixture warm, so the older test now loses the race consistently — it fails on every local attempt, in ~0.1s.

Modifications

Create the topic and schema on the remote cluster (r2) before creating them on the local cluster (r1), so the replicator finds the remote topic already present and there is nothing to race.

This is a reordering only: the test still creates the topic and schema on both clusters before producing, and every assertion is unchanged.

createTopicToRemoteClusterForReplication is deliberately left at its default. The other test in the class only creates the topic on r1 and relies on the replicator creating it on r2, so turning that off would break it.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, namely OneWayReplicatorSchemaValidationEnforcedTest itself.

Before this change the class fails 1 of 2 tests; after it, it passed 3 runs out of 3:

./gradlew :pulsar-broker:test -PexcludedTestGroups='' --tests "OneWayReplicatorSchemaValidationEnforcedTest"

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
  • The metrics
  • Anything that affects deployment

Sorry, something went wrong.

Uh oh!

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

All reactions
@lhotari
[fix][test] Fix OneWayReplicatorSchemaValidationEnforcedTest racing t…
c62b351
…he replicator's remote topic creation

### Motivation

`testReplicationWithAvroSchemaWithSchemaValidationEnforced` creates the topic in the local
cluster (r1) first and only then in the remote cluster (r2). Creating it on r1 starts the
replicator, and the replicator creates the missing topic on the remote cluster itself, via
`GeoPersistentReplicator#createRemoteTopicIfDoesNotExist`. The test's own
`admin2.topics().createNonPartitionedTopic(...)` therefore races that create and fails with
`PulsarAdminException$ConflictException: This topic already exists`.

The race has been latent since the test was added. apache#25437 then added
`testReplicationReconnectWithSchemaValidationEnforced` to the same class; TestNG runs it first,
and it leaves the two-cluster fixture warm, so the older test now loses the race consistently.
On a local run it fails on every attempt, in ~0.1s.

### Modifications

Create the topic and schema on the remote cluster (r2) before creating them on the local cluster
(r1), so the replicator finds the remote topic already present and there is nothing to race.
This is a reordering only: the test still creates topic and schema on both clusters before
producing, and every assertion is unchanged.

`createTopicToRemoteClusterForReplication` is deliberately left at its default. The other test in
the class only creates the topic on r1 and relies on the replicator creating it on r2, so turning
that off would break it.

### Verifying this change

This change is already covered by existing tests.

`OneWayReplicatorSchemaValidationEnforcedTest` fails 1 of 2 tests before this change and passes
3 runs out of 3 after it:

```
./gradlew :pulsar-broker:test -PexcludedTestGroups='' --tests "OneWayReplicatorSchemaValidationEnforcedTest"
```

### Does this pull request potentially affect one of the following parts:

- [ ] 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
@lhotari lhotari added the ready-to-test label Aug 19, 2026
@lhotari
lhotari requested review from Technoboy-, dao-jun, merlimat and nodece August 19, 2026 07:45
nodece
nodece approved these changes Aug 19, 2026
View reviewed changes
@nodece
nodece merged commit bbc02f0 into apache:master Aug 19, 2026
43 checks passed

Uh oh!

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

@lhotari lhotari added release/4.2.5 release/4.0.14 labels Aug 19, 2026
@lhotari lhotari added this to the 5.0.0-M2 milestone Aug 19, 2026
lhotari added a commit that referenced this pull request Aug 19, 2026
@lhotari
[fix][test] Fix OneWayReplicatorSchemaValidationEnforcedTest racing t…
953fa10
…he replicator's remote topic creation (#26382)

(cherry picked from commit bbc02f0)
@lhotari lhotari added the cherry-picked/branch-4.2 label Aug 19, 2026
lhotari added a commit that referenced this pull request Aug 19, 2026
@lhotari
[fix][test] Fix OneWayReplicatorSchemaValidationEnforcedTest racing t…
d03a05b
…he replicator's remote topic creation (#26382)

(cherry picked from commit bbc02f0)
@lhotari lhotari added the cherry-picked/branch-4.0 label Aug 19, 2026
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 28, 2026
@lhotari @nodece
[fix][test] Fix OneWayReplicatorSchemaValidationEnforcedTest racing t…
db9452e
…he replicator's remote topic creation (apache#26382)

(cherry picked from commit bbc02f0)
Radiancebobo pushed a commit to Radiancebobo/pulsar that referenced this pull request Oct 8, 2026
@lhotari hechengbo
[fix][test] Fix OneWayReplicatorSchemaValidationEnforcedTest racing t…
0d6ca53
…he replicator's remote topic creation (apache#26382)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nodece nodece nodece approved these changes
@merlimat merlimat Awaiting requested review from merlimat
@dao-jun dao-jun Awaiting requested review from dao-jun
@Technoboy- Technoboy- Awaiting requested review from Technoboy-

Uh oh!

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

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 ready-to-test release/4.0.14 release/4.2.5

Projects

None yet

Milestone

5.0.0-M2

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@lhotari @nodece
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.