Skip to content
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] Fix config replicationStartAt does not work when set it to earliest #23719

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,9 @@ The max allowed delay for delayed delivery (in milliseconds). If the broker rece
@FieldContext(
category = CATEGORY_SERVER,
dynamic = true,
doc = "The position that replication task start at, it can be set to earliest or latest (default).")
doc = "The position that replication task start at, it can be set to earliest or latest (default). Note: do"
+ " not use \"MessageId.earliest\" because its value is \"-1:-1:-1\", which does not equals"
+ " \"earliest\"")
poorbarcode marked this conversation as resolved.
Show resolved Hide resolved
private String replicationStartAt = "latest";

@FieldContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2066,9 +2066,13 @@ CompletableFuture<Void> startReplicator(String remoteCluster) {
final CompletableFuture<Void> future = new CompletableFuture<>();

String name = PersistentReplicator.getReplicatorName(replicatorPrefix, remoteCluster);
String replicationStartAt = getBrokerService().getPulsar().getConfiguration().getReplicationStartAt();
final InitialPosition initialPosition;
if (MessageId.earliest.toString()
.equalsIgnoreCase(getBrokerService().getPulsar().getConfiguration().getReplicationStartAt())) {
// "MessageId.earliest.toString()" is "-1:-1:-1", which is not suggested, just guarantee compatibility with the
// previous version.
// "InitialPosition.Earliest.name()" is "Earliest", which is suggested.
if (MessageId.earliest.toString().equalsIgnoreCase(replicationStartAt)
|| InitialPosition.Earliest.name().equalsIgnoreCase(replicationStartAt)) {
initialPosition = InitialPosition.Earliest;
} else {
initialPosition = InitialPosition.Latest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,9 @@ public void testConfigReplicationStartAt() throws Exception {
disableReplication(topic1);

// 2.Update config: start at "earliest".
admin1.brokers().updateDynamicConfiguration("replicationStartAt", MessageId.earliest.toString());
admin1.brokers().updateDynamicConfiguration("replicationStartAt", "earliest");
Awaitility.await().untilAsserted(() -> {
pulsar1.getConfiguration().getReplicationStartAt().equalsIgnoreCase("earliest");
assertEquals(pulsar1.getConfiguration().getReplicationStartAt(), "earliest");
});

final String topic2 = BrokerTestUtil.newUniqueName("persistent://" + ns1 + "/tp_");
Expand Down
Loading