1996fanrui commented on code in PR #23922:
URL: https://github.com/apache/flink/pull/23922#discussion_r1430885170
##########
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBStateBackendConfigTest.java:
##########
@@ -359,6 +365,58 @@ public void testDbPathRelativePaths() throws Exception {
rocksDbBackend.setDbStoragePath("relative/path");
}
+ @Test
+ @Timeout(value = 60)
+ public void testCleanRelocatedDbLogs() throws Exception {
+ final File folder = tempFolder.newFolder();
+ final File relocatedDBLogDir = tempFolder.newFolder("db_logs");
+ final File logFile = new File(relocatedDBLogDir, "taskManager.log");
+ Files.createFile(logFile.toPath());
+ System.setProperty("log.file", logFile.getAbsolutePath());
+
+ Configuration conf = new Configuration();
+ conf.set(RocksDBConfigurableOptions.LOG_LEVEL,
InfoLogLevel.DEBUG_LEVEL);
+ conf.set(RocksDBConfigurableOptions.LOG_FILE_NUM, 4);
+ conf.set(RocksDBConfigurableOptions.LOG_MAX_FILE_SIZE,
MemorySize.parse("1kb"));
+ final EmbeddedRocksDBStateBackend rocksDbBackend =
+ new EmbeddedRocksDBStateBackend().configure(conf,
getClass().getClassLoader());
+ final String dbStoragePath = new
Path(folder.toURI().toString()).toString();
+ rocksDbBackend.setDbStoragePath(dbStoragePath);
+
+ final MockEnvironment env = getMockEnvironment(tempFolder.newFolder());
+ RocksDBKeyedStateBackend<Integer> keyedBackend =
+ createKeyedStateBackend(rocksDbBackend, env,
IntSerializer.INSTANCE);
+ // clear unused file
+ FileUtils.deleteFileOrDirectory(logFile);
Review Comment:
We don't need to clean the `taskManager.log`, right?
If so, we can check that only rocksdb log is cleaned. (We should ensure
rocksdb doesn't clean other logs.)
##########
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBStateBackendConfigTest.java:
##########
@@ -359,6 +365,58 @@ public void testDbPathRelativePaths() throws Exception {
rocksDbBackend.setDbStoragePath("relative/path");
}
+ @Test
+ @Timeout(value = 60)
+ public void testCleanRelocatedDbLogs() throws Exception {
+ final File folder = tempFolder.newFolder();
+ final File relocatedDBLogDir = tempFolder.newFolder("db_logs");
+ final File logFile = new File(relocatedDBLogDir, "taskManager.log");
+ Files.createFile(logFile.toPath());
+ System.setProperty("log.file", logFile.getAbsolutePath());
+
+ Configuration conf = new Configuration();
+ conf.set(RocksDBConfigurableOptions.LOG_LEVEL,
InfoLogLevel.DEBUG_LEVEL);
+ conf.set(RocksDBConfigurableOptions.LOG_FILE_NUM, 4);
+ conf.set(RocksDBConfigurableOptions.LOG_MAX_FILE_SIZE,
MemorySize.parse("1kb"));
+ final EmbeddedRocksDBStateBackend rocksDbBackend =
+ new EmbeddedRocksDBStateBackend().configure(conf,
getClass().getClassLoader());
+ final String dbStoragePath = new
Path(folder.toURI().toString()).toString();
+ rocksDbBackend.setDbStoragePath(dbStoragePath);
+
+ final MockEnvironment env = getMockEnvironment(tempFolder.newFolder());
+ RocksDBKeyedStateBackend<Integer> keyedBackend =
+ createKeyedStateBackend(rocksDbBackend, env,
IntSerializer.INSTANCE);
+ // clear unused file
+ FileUtils.deleteFileOrDirectory(logFile);
+
+ File instanceBasePath = keyedBackend.getInstanceBasePath();
+ File instanceRocksDBPath =
+
RocksDBKeyedStateBackendBuilder.getInstanceRocksDBPath(instanceBasePath);
+
+ // avoid tests without relocate.
+ Assume.assumeTrue(instanceRocksDBPath.getAbsolutePath().length() <=
255 - "_LOG".length());
Review Comment:
Could we ensure the relocation always take effect in current test?
If we cannot ensure it, this test will be ignored, and we can't found this
bug if the log clean logic is broken in the future.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]