Repository navigation
Fix tier folder recovery and DiskFull status after configuration reload #19161
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
Merged
jt2594838
merged 7 commits into
apache:master
from
hongzhi-gao:fix/tier-manager-full-disk-recovery
Nov 10, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
50afd13
Preserve tier folder slots after disk-full initialization
hongzhi-gao 80898ef
Serialize retries of failed tier managers with folder reset
hongzhi-gao 290a5dc
Keep DiskFull until current directory checks recover
hongzhi-gao a7f7f5c
Add integration coverage for disk-full folder recovery
hongzhi-gao fc46afc
Trigger CI rerun
hongzhi-gao 378f1a0
Trigger CI rerun
hongzhi-gao cfd1dce
Refresh reloadable folder recovery checks
hongzhi-gao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDiskFullFolderRecoveryIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.iotdb.db.it; | ||
|
|
||
| import org.apache.iotdb.commons.conf.IoTDBConstant; | ||
| import org.apache.iotdb.it.env.EnvFactory; | ||
| import org.apache.iotdb.it.framework.IoTDBTestRunner; | ||
| import org.apache.iotdb.itbase.category.LocalStandaloneIT; | ||
|
|
||
| import org.awaitility.Awaitility; | ||
| import org.junit.AfterClass; | ||
| import org.junit.Assert; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| import java.io.File; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import java.sql.Connection; | ||
| import java.sql.ResultSet; | ||
| import java.sql.Statement; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import static org.apache.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; | ||
|
|
||
| @RunWith(IoTDBTestRunner.class) | ||
| @Category({LocalStandaloneIT.class}) | ||
| public class IoTDBDiskFullFolderRecoveryIT { | ||
| private static final String DATABASE = "root.disk_full_folder_recovery"; | ||
| private static final String FULL_THRESHOLD = "0.9999999999999999"; | ||
| private static final String NORMAL_THRESHOLD = "0.05"; | ||
|
|
||
| @BeforeClass | ||
| public static void setUp() throws Exception { | ||
| EnvFactory.getEnv().initClusterEnvironment(); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void tearDown() { | ||
| EnvFactory.getEnv().cleanClusterEnvironment(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testNewTsFileAfterFullDirectoryReloadAndRecovery() throws Exception { | ||
| int dataNodeId = EnvFactory.getEnv().getConfigNodeWrapperList().size(); | ||
| File dataDirectory = new File(EnvFactory.getEnv().getDataNodeWrapper(0).getDataPath()); | ||
| Assert.assertTrue(dataDirectory.mkdirs() || dataDirectory.isDirectory()); | ||
| Assert.assertTrue(dataDirectory.getTotalSpace() > 0); | ||
| Assert.assertTrue( | ||
| (double) dataDirectory.getFreeSpace() / dataDirectory.getTotalSpace() | ||
| < Double.parseDouble(FULL_THRESHOLD)); | ||
|
|
||
| try (Connection connection = EnvFactory.getEnv().getConnection(); | ||
| Statement statement = connection.createStatement()) { | ||
| statement.execute("CREATE DATABASE " + DATABASE); | ||
| statement.execute("CREATE TIMESERIES " + DATABASE + ".d1.s1 WITH DATATYPE=INT64"); | ||
| try { | ||
| // The first reload installs the threshold; the second rebuilds FolderManagers under it. | ||
| setDataNodeConfiguration( | ||
| statement, dataNodeId, "disk_space_warning_threshold", FULL_THRESHOLD); | ||
| setDataNodeConfiguration(statement, dataNodeId, "enable_partial_insert", "true"); | ||
| awaitDataNodeStatus(statement, dataNodeId, "ReadOnly", "DiskFull"); | ||
|
|
||
| // A successful reload of the same configuration must not clear the full-disk status. | ||
| setDataNodeConfiguration(statement, dataNodeId, "enable_partial_insert", "true"); | ||
| Assert.assertEquals("ReadOnly", getDataNodeStatus(statement, dataNodeId)); | ||
| } finally { | ||
| setDataNodeConfiguration( | ||
| statement, dataNodeId, "disk_space_warning_threshold", NORMAL_THRESHOLD); | ||
| } | ||
|
|
||
| awaitDataNodeStatus(statement, dataNodeId, "Running", null); | ||
| statement.execute("INSERT INTO " + DATABASE + ".d1(time,s1) VALUES(1,1)"); | ||
| statement.execute("FLUSH"); | ||
|
|
||
| try (ResultSet resultSet = statement.executeQuery("SELECT s1 FROM " + DATABASE + ".d1")) { | ||
| Assert.assertTrue(resultSet.next()); | ||
| Assert.assertEquals(1, resultSet.getLong("Time")); | ||
| Assert.assertEquals(1, resultSet.getLong(DATABASE + ".d1.s1")); | ||
| Assert.assertFalse(resultSet.next()); | ||
| } | ||
| Assert.assertTrue(hasSequenceTsFile()); | ||
| } | ||
| } | ||
|
|
||
| private static void setDataNodeConfiguration( | ||
| Statement statement, int nodeId, String key, String value) throws Exception { | ||
| statement.execute("SET CONFIGURATION \"" + key + "\"=\"" + value + "\" ON " + nodeId); | ||
| } | ||
|
|
||
| private static void awaitDataNodeStatus( | ||
| Statement statement, int nodeId, String expectedStatus, String expectedReason) { | ||
| Awaitility.await() | ||
| .atMost(30, TimeUnit.SECONDS) | ||
| .until( | ||
| () -> { | ||
| try (ResultSet resultSet = statement.executeQuery("SHOW DATANODES")) { | ||
| while (resultSet.next()) { | ||
| if (resultSet.getInt("NodeID") == nodeId) { | ||
| if (!expectedStatus.equals(resultSet.getString("Status"))) { | ||
| return false; | ||
| } | ||
| return expectedReason == null | ||
| || expectedReason.equals(resultSet.getString("StatusReason")); | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
|
|
||
| private static String getDataNodeStatus(Statement statement, int nodeId) throws Exception { | ||
| try (ResultSet resultSet = statement.executeQuery("SHOW DATANODES")) { | ||
| while (resultSet.next()) { | ||
| if (resultSet.getInt("NodeID") == nodeId) { | ||
| return resultSet.getString("Status"); | ||
| } | ||
| } | ||
| } | ||
| Assert.fail("DataNode not found: " + nodeId); | ||
| return null; | ||
| } | ||
|
|
||
| private static boolean hasSequenceTsFile() throws Exception { | ||
| Path sequenceDirectory = | ||
| Paths.get( | ||
| EnvFactory.getEnv().getDataNodeWrapper(0).getDataPath(), | ||
| IoTDBConstant.SEQUENCE_FOLDER_NAME, | ||
| DATABASE); | ||
| if (!Files.exists(sequenceDirectory)) { | ||
| return false; | ||
| } | ||
| try (Stream<Path> paths = Files.walk(sequenceDirectory)) { | ||
| return paths.anyMatch(path -> path.toString().endsWith(TSFILE_SUFFIX)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Refresh non-tier data-directory recovery checks on reload
With this clearing step removed, checks from ordinary FolderManagers also survive a successful reload, but only TierManager checks follow the new configuration. For example, SnapshotLoader.createLinksFromSnapshotDirToDataDirWithoutLog() constructs a plain FolderManager from getLocalDataDirs(). If construction fails while the old data disk is full, DirectoryStrategy.setFolders() registers a callback over List.copyOf(oldDirs). After dn_data_dirs adds a free disk, new tier and snapshot-loading managers can use that disk, while the discarded snapshot manager's callback still checks only the full old disk. Even after the aggregate disk-space check passes, tryRecoverFromDiskFull() therefore keeps the whole DataNode in ReadOnly(DiskFull). Please refresh or retire checks owned by these reloadable data-directory consumers as well, while preserving independent sources such as WAL. A regression should cover failed snapshot-manager construction, adding a free data directory through reload, and subsequent heartbeat recovery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch. Fixed in cfd1dce: SnapshotLoader, LoadStagingDirs, and LoadUtil now check their current configured directories for DiskFull recovery, while independent sources such as WAL remain registered. The new SnapshotLoaderDiskFullReloadTest covers failed snapshot FolderManager construction, adding a writable data directory, and the heartbeat recovery check (tryRecoverFromDiskFull). It also verifies that an unavailable WAL source still keeps the node ReadOnly. The focused tests passed.