Skip to content

Commit 1594e91

Browse files
hangc0276srinath-ctds
authored andcommitted
[fix][broker] Fix cluster level OffloadedReadPriority to bookkeeper-first does not work (apache#24151)
### Motivation When we set cluster level `managedLedgerDataReadPriority` to `bookkeeper-first` in conf/broker.conf https://github.com/apache/pulsar/blob/f2618c15bb5a9f3fcb577068584df5d0e2e4f335/conf/broker.conf#L1262-L1264 Then use the command `bin/pulsar-admin namespaces set-offload-threshold -s 0 <namespace>` to set the offload threshold in namespace level to trigger topic offload automatically. However, the broker side will create an empty OffloadPolicy when setting the offload threshold https://github.com/apache/pulsar/blob/f2618c15bb5a9f3fcb577068584df5d0e2e4f335/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L2174-L2176 However, the empty OffloadPolicy will set the `OffloadedReadPriority` to `TIERED_STORAGE_FIRST` in namespace level. https://github.com/apache/pulsar/blob/f2618c15bb5a9f3fcb577068584df5d0e2e4f335/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/OffloadPoliciesImpl.java#L98-L99 The namespace level offload policy has higher priority than broker level offload policy, and it makes setting broker-level `OffloadedReadPriority` to `bookkeeper-first` doesn't work ### Modifications Change OffloadPolicy's default OffloadedReadPriority to `null` to allow broker-level offload policy can take affect. (cherry picked from commit 153fce9) (cherry picked from commit 02257c8)
1 parent 6921a49 commit 1594e91

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/OffloadPoliciesImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ public class OffloadPoliciesImpl implements Serializable, OffloadPolicies {
9494
"managedLedgerOffloadAutoTriggerSizeThresholdBytes";
9595
public static final String DELETION_LAG_NAME_IN_CONF_FILE = "managedLedgerOffloadDeletionLagMs";
9696
public static final String DATA_READ_PRIORITY_NAME_IN_CONF_FILE = "managedLedgerDataReadPriority";
97-
public static final OffloadedReadPriority DEFAULT_OFFLOADED_READ_PRIORITY =
98-
OffloadedReadPriority.TIERED_STORAGE_FIRST;
97+
public static final OffloadedReadPriority DEFAULT_OFFLOADED_READ_PRIORITY = null;
9998

10099
// common config
101100
@Configuration

pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/OffloadPoliciesTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import static org.apache.pulsar.common.policies.data.OffloadPoliciesImpl.EXTRA_CONFIG_PREFIX;
2222
import static org.testng.Assert.assertEquals;
23+
import static org.testng.Assert.assertNull;
24+
2325
import java.io.DataInputStream;
2426
import java.io.File;
2527
import java.io.IOException;
@@ -472,4 +474,13 @@ public void testToProperties() throws Exception {
472474
offloadPolicies.setManagedLedgerExtraConfigurations(extraConfiguration);
473475
assertEquals(offloadPolicies, OffloadPoliciesImpl.create(offloadPolicies.toProperties()));
474476
}
477+
478+
@Test
479+
public void testDefaultOffloadPolicies() {
480+
OffloadPoliciesImpl offloadPolicies = new OffloadPoliciesImpl();
481+
assertNull(offloadPolicies.getManagedLedgerOffloadedReadPriority());
482+
assertNull(offloadPolicies.getManagedLedgerOffloadDeletionLagInMillis());
483+
assertNull(offloadPolicies.getManagedLedgerOffloadThresholdInSeconds());
484+
assertNull(offloadPolicies.getManagedLedgerOffloadThresholdInBytes());
485+
}
475486
}

0 commit comments

Comments
 (0)