Skip to content

Commit 63affe8

Browse files
committed
fix
1 parent a3b1b0b commit 63affe8

6 files changed

Lines changed: 89 additions & 86 deletions

File tree

iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodePipeMessages.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,67 +25,67 @@ public final class DataNodePipeMessages {
2525

2626
public static final String CLOSING_DELETION_RESOURCE_MANAGER_FOR =
2727
"Closing deletion resource manager for {}...";
28-
public static final String DAL_THREAD_STILL_DOESN_T_EXIT_AFTER =
29-
"DAL Thread {} still doesn't exit after 30s";
3028
public static final String DELETIONMANAGER_CURRENT_DAL_DIR_IS_DELETED_SUCCESSFULLY =
3129
"DeletionManager-{}: current DAL dir {} is deleted successfully";
3230
public static final String DELETIONMANAGER_CURRENT_DAL_DIR_IS_NOT_INITIALIZED =
3331
"DeletionManager-{}: current DAL dir {} is not initialized, no need to delete.";
3432
public static final String DELETIONMANAGER_CURRENT_WAITING_IS_INTERRUPTED_MAY_BECAUSE =
35-
"DeletionManager-{}: current waiting is interrupted. May because current application is "
36-
+ "down. ";
33+
"DeletionManager-{}: waiting was interrupted, possibly because the application is "
34+
+ "shutting down.";
3735
public static final String DELETIONMANAGER_DELETE_DELETION_FILE_IN_DIR =
38-
"DeletionManager-{} delete deletion file in {} dir...";
36+
"DeletionManager-{}: deleted deletion file {}.";
3937
public static final String DELETIONMANAGER_FAILED_TO_DELETE_FILE_IN_DIR =
40-
"DeletionManager-{} failed to delete file in {} dir, please manually check!";
38+
"DeletionManager-{}: failed to delete files under {}, please check manually!";
4139
public static final String DELETIONRESOURCE_HAS_BEEN_RELEASED_TRIGGER_A_REMOVE =
42-
"DeletionResource {} has been released, trigger a remove of DAL...";
40+
"DeletionResource {} has been released; triggering DAL cleanup.";
4341
public static final String DELETION_PERSIST_CANNOT_CREATE_FILE_PLEASE_CHECK =
44-
"Deletion persist: Cannot create file {}, please check your file system manually.";
42+
"Deletion persist: failed to create file {}; please check the file system manually.";
4543
public static final String DELETION_PERSIST_CANNOT_WRITE_TO_MAY_CAUSE =
46-
"Deletion persist: Cannot write to {}, may cause data inconsistency.";
44+
"Deletion persist: failed to write to {}; data may become inconsistent.";
4745
public static final String DELETION_PERSIST_CURRENT_BATCH_FSYNC_DUE_TO =
48-
"Deletion persist-{}: current batch fsync due to timeout";
46+
"Deletion persist-{}: fsync current batch due to timeout";
4947
public static final String DELETION_PERSIST_CURRENT_FILE_HAS_BEEN_CLOSED =
5048
"Deletion persist-{}: current file has been closed";
5149
public static final String DELETION_PERSIST_SERIALIZE_DELETION_RESOURCE =
52-
"Deletion persist-{}: serialize deletion resource {}";
50+
"Deletion persist-{}: serializing deletion resource {}";
5351
public static final String DELETION_PERSIST_STARTING_TO_PERSIST_CURRENT_WRITING =
54-
"Deletion persist-{}: starting to persist, current writing: {}";
52+
"Deletion persist-{}: starting to persist, current file: {}";
5553
public static final String DELETION_PERSIST_SWITCHING_TO_A_NEW_FILE =
56-
"Deletion persist-{}: switching to a new file, current writing: {}";
54+
"Deletion persist-{}: switched to a new file, current file: {}";
5755
public static final String DELETION_RESOURCE_MANAGER_FOR_HAS_BEEN_SUCCESSFULLY =
5856
"Deletion resource manager for {} has been successfully closed!";
5957
public static final String DETECT_FILE_CORRUPTED_WHEN_RECOVER_DAL_DISCARD =
60-
"Detect file corrupted when recover DAL-{}, discard all subsequent DALs...";
58+
"Detected a corrupted file while recovering DAL-{}; discarding all subsequent DALs.";
6159
public static final String FAILED_TO_INITIALIZE_DELETIONRESOURCEMANAGER =
6260
"Failed to initialize DeletionResourceManager";
6361
public static final String FAILED_TO_READ_DELETION_FILE_MAY_BECAUSE =
64-
"Failed to read deletion file {}, possibly because this file was corrupted while being written.";
62+
"Failed to read deletion file {}; it may have been corrupted while being written.";
6563
public static final String FAILED_TO_RECOVER_DELETIONRESOURCEMANAGER =
6664
"Failed to recover DeletionResourceManager";
6765
public static final String FAIL_TO_ALLOCATE_DELETIONBUFFER_GROUP_S_BUFFER =
68-
"Fail to allocate deletionBuffer-group-{}'s buffer because out of memory.";
66+
"Failed to allocate deletionBuffer-group-{}'s buffer because memory is insufficient.";
6967
public static final String FAIL_TO_CLOSE_CURRENT_LOGGING_FILE_WHEN =
70-
"Fail to close current logging file when closing";
68+
"Failed to close current logging file while closing";
7169
public static final String FAIL_TO_REGISTER_DELETIONRESOURCE_INTO_DELETIONBUFFER_BECAUSE =
72-
"Fail to register DeletionResource into deletionBuffer-{} because this buffer is closed.";
70+
"Failed to register DeletionResource into deletionBuffer-{} because the buffer is closed.";
7371
public static final String INTERRUPTED_WHEN_WAITING_FOR_ALL_DELETIONS_FLUSHED =
74-
"Interrupted when waiting for all deletions flushed.";
72+
"Interrupted while waiting for all deletions to be flushed.";
73+
public static final String INTERRUPTED_WHILE_WAITING_FOR_DAL_THREAD_TO_EXIT =
74+
"Interrupted while waiting for the DAL thread of dataRegion {} to exit.";
7575
public static final String INTERRUPTED_WHEN_WAITING_FOR_RESULT =
76-
"Interrupted when waiting for result.";
76+
"Interrupted while waiting for result.";
7777
public static final String INTERRUPTED_WHEN_WAITING_FOR_TAKING_DELETIONRESOURCE_FROM =
78-
"Interrupted when waiting for taking DeletionResource from blocking queue to serialize.";
79-
public static final String INTERRUPTED_WHEN_WAITING_FOR_TAKING_WALENTRY_FROM =
80-
"Interrupted when waiting for taking WALEntry from blocking queue to serialize.";
78+
"Interrupted while taking a DeletionResource from the blocking queue for serialization.";
79+
public static final String INTERRUPTED_WHEN_WAITING_FOR_POLLING_DELETIONRESOURCE_FROM =
80+
"Interrupted while polling a DeletionResource from the blocking queue for serialization.";
8181
public static final String INVALID_DELETION_PROGRESS_INDEX = "Invalid deletion progress index: ";
8282
public static final String PERSISTTHREAD_DID_NOT_TERMINATE_WITHIN_S =
83-
"persistThread did not terminate within {}s";
83+
"Persist thread did not terminate within {}s";
8484
public static final String READ_DELETION_FILE_MAGIC_VERSION =
85-
"Read deletion file-{} magic version: {}";
85+
"Read deletion file {} magic version: {}";
8686
public static final String READ_DELETION_FROM_FILE = "Read deletion: {} from file {}";
8787
public static final String UNABLE_TO_CREATE_IOTCONSENSUSV2_DELETION_DIR_AT =
88-
"Unable to create iotConsensusV2 deletion dir at {}";
88+
"Unable to create IoTConsensusV2 deletion directory at {}";
8989

9090
// ===================== AGENT =====================
9191

iotdb-core/datanode/src/main/i18n/zh/org/apache/iotdb/db/i18n/DataNodePipeMessages.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,61 @@ public final class DataNodePipeMessages {
2424
// ===================== CONSENSUS =====================
2525

2626
public static final String CLOSING_DELETION_RESOURCE_MANAGER_FOR = "正在关闭 {} 的删除资源管理器...";
27-
public static final String DAL_THREAD_STILL_DOESN_T_EXIT_AFTER = "DAL 线程 {} 在 30 秒后仍未退出";
2827
public static final String DELETIONMANAGER_CURRENT_DAL_DIR_IS_DELETED_SUCCESSFULLY =
2928
"DeletionManager-{}:当前 DAL 目录 {} 已成功删除";
3029
public static final String DELETIONMANAGER_CURRENT_DAL_DIR_IS_NOT_INITIALIZED =
3130
"DeletionManager-{}:当前 DAL 目录 {} 未初始化,无需删除。";
3231
public static final String DELETIONMANAGER_CURRENT_WAITING_IS_INTERRUPTED_MAY_BECAUSE =
33-
"DeletionManager-{}:当前等待被中断,可能是因为当前应用已停止。";
32+
"DeletionManager-{}:等待被中断,可能是因为应用正在关闭。";
3433
public static final String DELETIONMANAGER_DELETE_DELETION_FILE_IN_DIR =
35-
"DeletionManager-{}:正在删除目录 {} 中的删除文件...";
34+
"DeletionManager-{}:已删除删除文件 {}";
3635
public static final String DELETIONMANAGER_FAILED_TO_DELETE_FILE_IN_DIR =
37-
"DeletionManager-{}:删除目录 {} 中的文件失败,请手动检查!";
36+
"DeletionManager-{}:删除 {} 下的文件失败,请手动检查!";
3837
public static final String DELETIONRESOURCE_HAS_BEEN_RELEASED_TRIGGER_A_REMOVE =
39-
"DeletionResource {} 已释放,触发移除 DAL...";
38+
"DeletionResource {} 已释放,触发 DAL 清理。";
4039
public static final String DELETION_PERSIST_CANNOT_CREATE_FILE_PLEASE_CHECK =
41-
"Deletion persist:无法创建文件 {},请手动检查文件系统。";
40+
"Deletion persist:创建文件 {} 失败,请手动检查文件系统。";
4241
public static final String DELETION_PERSIST_CANNOT_WRITE_TO_MAY_CAUSE =
43-
"Deletion persist:无法写入 {},可能导致数据不一致。";
42+
"Deletion persist:写入 {} 失败,可能导致数据不一致。";
4443
public static final String DELETION_PERSIST_CURRENT_BATCH_FSYNC_DUE_TO =
45-
"Deletion persist-{}:当前批次因超时执行 fsync";
44+
"Deletion persist-{}:因超时对当前批次执行 fsync";
4645
public static final String DELETION_PERSIST_CURRENT_FILE_HAS_BEEN_CLOSED =
4746
"Deletion persist-{}:当前文件已关闭";
4847
public static final String DELETION_PERSIST_SERIALIZE_DELETION_RESOURCE =
49-
"Deletion persist-{}:序列化删除资源 {}";
48+
"Deletion persist-{}:正在序列化删除资源 {}";
5049
public static final String DELETION_PERSIST_STARTING_TO_PERSIST_CURRENT_WRITING =
51-
"Deletion persist-{}:开始持久化,当前写入文件:{}";
50+
"Deletion persist-{}:开始持久化,当前文件:{}";
5251
public static final String DELETION_PERSIST_SWITCHING_TO_A_NEW_FILE =
53-
"Deletion persist-{}:切换到新文件,当前写入文件:{}";
52+
"Deletion persist-{}:已切换到新文件,当前文件:{}";
5453
public static final String DELETION_RESOURCE_MANAGER_FOR_HAS_BEEN_SUCCESSFULLY =
5554
"{} 的删除资源管理器已成功关闭!";
5655
public static final String DETECT_FILE_CORRUPTED_WHEN_RECOVER_DAL_DISCARD =
57-
"恢复 DAL-{} 时检测到文件损坏,将丢弃后续所有 DAL...";
56+
"恢复 DAL-{} 时检测到文件损坏,将丢弃后续所有 DAL";
5857
public static final String FAILED_TO_INITIALIZE_DELETIONRESOURCEMANAGER =
5958
"初始化 DeletionResourceManager 失败";
6059
public static final String FAILED_TO_READ_DELETION_FILE_MAY_BECAUSE =
61-
"读取删除文件 {} 失败,原因可能是该文件写入时已损坏。";
60+
"读取删除文件 {} 失败,该文件可能在写入时已损坏。";
6261
public static final String FAILED_TO_RECOVER_DELETIONRESOURCEMANAGER =
6362
"恢复 DeletionResourceManager 失败";
6463
public static final String FAIL_TO_ALLOCATE_DELETIONBUFFER_GROUP_S_BUFFER =
65-
"分配 deletionBuffer-group-{} 的缓冲区失败,原因:内存不足。";
66-
public static final String FAIL_TO_CLOSE_CURRENT_LOGGING_FILE_WHEN = "关闭时无法关闭当前日志文件";
64+
"分配 deletionBuffer-group-{} 的缓冲区失败,内存不足。";
65+
public static final String FAIL_TO_CLOSE_CURRENT_LOGGING_FILE_WHEN = "关闭过程中关闭当前日志文件失败";
6766
public static final String FAIL_TO_REGISTER_DELETIONRESOURCE_INTO_DELETIONBUFFER_BECAUSE =
68-
"向 deletionBuffer-{} 注册 DeletionResource 失败,原因:该缓冲区已关闭。";
69-
public static final String INTERRUPTED_WHEN_WAITING_FOR_ALL_DELETIONS_FLUSHED = "等待所有删除操作刷盘时被中断。";
67+
"向 deletionBuffer-{} 注册 DeletionResource 失败,因为该缓冲区已关闭。";
68+
public static final String INTERRUPTED_WHEN_WAITING_FOR_ALL_DELETIONS_FLUSHED =
69+
"等待所有删除操作刷盘时被中断。";
70+
public static final String INTERRUPTED_WHILE_WAITING_FOR_DAL_THREAD_TO_EXIT =
71+
"等待 dataRegion {} 的 DAL 线程退出时被中断。";
7072
public static final String INTERRUPTED_WHEN_WAITING_FOR_RESULT = "等待结果时被中断。";
7173
public static final String INTERRUPTED_WHEN_WAITING_FOR_TAKING_DELETIONRESOURCE_FROM =
7274
"等待从阻塞队列中取出 DeletionResource 进行序列化时被中断。";
73-
public static final String INTERRUPTED_WHEN_WAITING_FOR_TAKING_WALENTRY_FROM =
74-
"等待从阻塞队列中取出 WALEntry 进行序列化时被中断。";
75+
public static final String INTERRUPTED_WHEN_WAITING_FOR_POLLING_DELETIONRESOURCE_FROM =
76+
"等待从阻塞队列中轮询 DeletionResource 进行序列化时被中断。";
7577
public static final String INVALID_DELETION_PROGRESS_INDEX = "无效的删除进度索引:";
76-
public static final String PERSISTTHREAD_DID_NOT_TERMINATE_WITHIN_S = "persistThread 在 {} 秒内未终止";
78+
public static final String PERSISTTHREAD_DID_NOT_TERMINATE_WITHIN_S = "持久化线程未在 {} 秒内终止";
7779
public static final String READ_DELETION_FILE_MAGIC_VERSION =
78-
"读取删除文件-{} 的 magic version:{}";
79-
public static final String READ_DELETION_FROM_FILE = "从文件 {} 读取删除操作:{}";
80+
"读取删除文件 {} 的 magic version:{}";
81+
public static final String READ_DELETION_FROM_FILE = "读取删除操作:{},来自文件 {}";
8082
public static final String UNABLE_TO_CREATE_IOTCONSENSUSV2_DELETION_DIR_AT =
8183
"无法在 {} 创建 IoTConsensusV2 删除目录";
8284

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/consensus/deletion/DeletionResource.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444
/**
4545
* DeletionResource is designed for IoTConsensusV2 to manage the lifecycle of all deletion
46-
* operations including realtime deletion and historical deletion. In order to be compatible with
47-
* user pipe framework, IoTConsensusV2 will use {@link PipeDeleteDataNodeEvent}
46+
* operations including real-time deletion and historical deletion. In order to be compatible with
47+
* the user pipe framework, IoTConsensusV2 will use {@link PipeDeleteDataNodeEvent}.
4848
*/
4949
public class DeletionResource implements PersistentResource {
5050
private static final Logger LOGGER = LoggerFactory.getLogger(DeletionResource.class);
@@ -54,7 +54,7 @@ public class DeletionResource implements PersistentResource {
5454
private final ConsensusGroupId consensusGroupId;
5555
private volatile Status currentStatus;
5656

57-
// it's safe to use volatile here to make this reference thread-safe.
57+
// It is safe to use volatile here to make this reference thread-safe.
5858
@SuppressWarnings("squid:S3077")
5959
private volatile Exception cause;
6060

@@ -119,17 +119,17 @@ public ProgressIndex getProgressIndex() {
119119
}
120120

121121
/**
122-
* Only the default implementation is provided here, which will not be called in practice, but is
123-
* only used to implement the interface
122+
* This default implementation is provided only to implement the interface and should not be
123+
* called in practice.
124124
*/
125125
@Override
126126
public long getFileStartTime() {
127127
return 0;
128128
}
129129

130130
/**
131-
* Only the default implementation is provided here, which will not be called in practice, but is
132-
* only used to implement the interface
131+
* This default implementation is provided only to implement the interface and should not be
132+
* called in practice.
133133
*/
134134
@Override
135135
public long getFileEndTime() {

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/consensus/deletion/DeletionResourceManager.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void initAndRecover() throws IOException {
8888
recoverLock.lock();
8989
try {
9090
if (!storageDir.exists()) {
91-
// Init
91+
// Initialize the storage directory.
9292
if (!storageDir.mkdirs()) {
9393
LOGGER.warn(
9494
DataNodePipeMessages.UNABLE_TO_CREATE_IOTCONSENSUSV2_DELETION_DIR_AT, storageDir);
@@ -142,7 +142,7 @@ public DeletionResource registerDeletionResource(AbstractDeleteDataNode deleteDa
142142
deleteDataNode,
143143
key ->
144144
new DeletionResource(deleteDataNode, this::removeDeletionResource, dataRegionId));
145-
// register a persist task for current deletionResource
145+
// Register a persist task for the current DeletionResource.
146146
deletionBuffer.registerDeletionResource(deletionResource);
147147
return deletionResource;
148148
}
@@ -208,11 +208,11 @@ private synchronized void removeDeletionResource(DeletionResource deletionResour
208208
path.getFileName().toString(), currentProgressIndex))
209209
.sorted(this::compareFileProgressIndex)
210210
.toArray(Path[]::new);
211-
// File name represents the max progressIndex in its previous file. If currentProgressIndex is
212-
// larger than a fileName's progressIndex, it means that the file before this file has been
213-
// fully synchronized and can be deleted.
214-
// So here we cannot guarantee that the last file can be deleted, we can only guarantee that
215-
// the first n-1 files can be deleted (if the length of deletionPaths is n)
211+
// The file name represents the max ProgressIndex in the previous file. If
212+
// currentProgressIndex is larger than a file name's ProgressIndex, the file before this file
213+
// has been fully synchronized and can be deleted.
214+
// The last file is not guaranteed to be deletable here, so only the first n - 1 files can be
215+
// deleted when deletionPaths has n entries.
216216
for (int i = 0; i < deletionPaths.length - 1; i++) {
217217
File fileToDelete = deletionPaths[i].toFile();
218218
FileUtils.deleteFileOrDirectory(fileToDelete);
@@ -225,7 +225,8 @@ private synchronized void removeDeletionResource(DeletionResource deletionResour
225225
LOGGER.warn(
226226
DataNodePipeMessages.DELETIONMANAGER_FAILED_TO_DELETE_FILE_IN_DIR,
227227
dataRegionId,
228-
storageDir);
228+
storageDir,
229+
e);
229230
}
230231
}
231232

@@ -235,7 +236,7 @@ private int compareFileProgressIndex(Path file1, Path file2) {
235236
String fileName2 = file2.getFileName().toString();
236237
Matcher matcher1 = pattern.matcher(fileName1);
237238
Matcher matcher2 = pattern.matcher(fileName2);
238-
// Definitely match. Because upper caller has filtered fileNames.
239+
// Must match because the caller has filtered file names.
239240
if (matcher1.matches() && matcher2.matches()) {
240241
int fileRebootTimes1 = Integer.parseInt(matcher1.group(REBOOT_TIME));
241242
long fileMemTableFlushOrderId1 = Long.parseLong(matcher1.group(MEM_TABLE_FLUSH_ORDER));
@@ -260,7 +261,7 @@ private boolean isFileProgressCoveredByGivenProgress(
260261

261262
Pattern pattern = Pattern.compile(DELETION_FILE_NAME_PATTERN);
262263
Matcher matcher = pattern.matcher(fileName);
263-
// Definitely match. Because upper caller has filtered fileNames.
264+
// Must match because the caller has filtered file names.
264265
if (matcher.matches()) {
265266
int fileRebootTimes = Integer.parseInt(matcher.group(REBOOT_TIME));
266267
long fileMemTableFlushOrderId = Long.parseLong(matcher.group(MEM_TABLE_FLUSH_ORDER));
@@ -302,7 +303,7 @@ public static DeletionResourceManager getInstance(int groupId) {
302303
});
303304
}
304305

305-
// Only when consensus protocol is IoTConsensusV2, will this class be initialized.
306+
// This class is initialized only when the consensus protocol is IoTConsensusV2.
306307
public static void build() {
307308
if (DataRegionConsensusImpl.getInstance() instanceof IoTConsensusV2) {
308309
DeletionResourceManagerHolder.build();

0 commit comments

Comments
 (0)