From b372e9031e3f43adc831947332a6852680e750db Mon Sep 17 00:00:00 2001 From: Xiangying Meng <55571188+liangyepianzhou@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:09:27 +0800 Subject: [PATCH] [improve][conf] Change the default value of readOnlyModeOnAnyDiskFullEnabled to true (#4520) * [improve][conf] Change the default value of readOnlyModeOnAnyDiskFullEnabled to true --- .../java/org/apache/bookkeeper/conf/ServerConfiguration.java | 4 ++-- .../org/apache/bookkeeper/bookie/LedgerDirsManagerTest.java | 4 ++-- .../java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java | 1 + conf/bk_server.conf | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java index cb731060c4c..01848882c55 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java @@ -2462,12 +2462,12 @@ public ServerConfiguration setReadOnlyModeOnAnyDiskFullEnabled(boolean enabled) } /** - * Get whether read-only mode is enable when any disk is full. The default is false. + * Get whether read-only mode is enable when any disk is full. The default is true. * * @return boolean */ public boolean isReadOnlyModeOnAnyDiskFullEnabled() { - return getBoolean(READ_ONLY_MODE_ON_ANY_DISK_FULL_ENABLED, false); + return getBoolean(READ_ONLY_MODE_ON_ANY_DISK_FULL_ENABLED, true); } /** diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerDirsManagerTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerDirsManagerTest.java index d6e01cec457..f46390e3328 100644 --- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerDirsManagerTest.java +++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerDirsManagerTest.java @@ -414,7 +414,7 @@ public void testLedgerDirsMonitorHandlingWithMultipleLedgerDirectories() throws // one dir usagespace above storagethreshold, another dir below storagethreshold // should still be writable setUsageAndThenVerify(curDir1, nospace + 0.02f, curDir2, nospace - 0.05f, mockDiskChecker, - mockLedgerDirsListener, false); + mockLedgerDirsListener, true); // should remain readonly setUsageAndThenVerify(curDir1, nospace + 0.05f, curDir2, nospace + 0.02f, mockDiskChecker, @@ -438,7 +438,7 @@ public void testLedgerDirsMonitorHandlingWithMultipleLedgerDirectories() throws // overall diskusage is less than lwm // should goto readwrite setUsageAndThenVerify(curDir1, lwm - 0.17f, curDir2, nospace + 0.03f, mockDiskChecker, mockLedgerDirsListener, - false); + true); assertEquals("Only one LedgerDir should be writable", 1, dirsManager.getWritableLedgerDirs().size()); // bring both the dirs below lwm diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java index d3aa1ed7ad2..ad03102c868 100644 --- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java +++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java @@ -103,6 +103,7 @@ public void testBookieShouldServeAsReadOnly() throws Exception { public void testBookieShouldTurnWritableFromReadOnly() throws Exception { killBookie(0); baseConf.setReadOnlyModeEnabled(true); + baseConf.setReadOnlyModeOnAnyDiskFullEnabled(false); baseConf.setDiskCheckInterval(Integer.MAX_VALUE); startNewBookie(); LedgerHandle ledger = bkc.createLedger(2, 2, DigestType.MAC, diff --git a/conf/bk_server.conf b/conf/bk_server.conf index 53ce8fe4d02..1dfb8215245 100644 --- a/conf/bk_server.conf +++ b/conf/bk_server.conf @@ -181,8 +181,8 @@ extraServerComponents= # If "readOnlyModeOnAnyDiskFullEnabled=true" then on any ledger disks full, bookie will be converted # to read-only mode and serve only read requests. When all disks recovered, # the bookie will be converted to read-write mode.Otherwise it will obey the `readOnlyModeEnabled` behavior. -# By default this will be disabled. -# readOnlyModeOnAnyDiskFullEnabled=false +# By default this will be enable. +# readOnlyModeOnAnyDiskFullEnabled=true ############################################################################# ## Netty server settings