-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-6647 KafkaStreams.cleanUp creates .lock file in directory it tries to clean #5650
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,27 +88,6 @@ public void shouldCreateTaskStateDirectory() { | |
assertTrue(taskDirectory.isDirectory()); | ||
} | ||
|
||
@Test | ||
public void shouldLockTaskStateDirectory() throws IOException { | ||
final TaskId taskId = new TaskId(0, 0); | ||
final File taskDirectory = directory.directoryForTask(taskId); | ||
|
||
directory.lock(taskId); | ||
|
||
try ( | ||
final FileChannel channel = FileChannel.open( | ||
new File(taskDirectory, StateDirectory.LOCK_FILE_NAME).toPath(), | ||
StandardOpenOption.CREATE, StandardOpenOption.WRITE) | ||
) { | ||
channel.tryLock(); | ||
fail("shouldn't be able to lock already locked directory"); | ||
} catch (final OverlappingFileLockException e) { | ||
// pass | ||
} finally { | ||
directory.unlock(taskId); | ||
} | ||
} | ||
|
||
@Test | ||
public void shouldBeTrueIfAlreadyHoldsLock() throws IOException { | ||
final TaskId taskId = new TaskId(0, 0); | ||
|
@@ -140,17 +119,18 @@ public void shouldNotLockDeletedDirectory() throws IOException { | |
@Test | ||
public void shouldLockMulitpleTaskDirectories() throws IOException { | ||
final TaskId taskId = new TaskId(0, 0); | ||
final File task1Dir = directory.directoryForTask(taskId); | ||
final File task1Dir = directory.stateDir(); | ||
final TaskId taskId2 = new TaskId(1, 0); | ||
final File task2Dir = directory.directoryForTask(taskId2); | ||
final File task2Dir = directory.stateDir(); | ||
|
||
|
||
try ( | ||
final FileChannel channel1 = FileChannel.open( | ||
new File(task1Dir, StateDirectory.LOCK_FILE_NAME).toPath(), | ||
new File(task1Dir, taskId + StateDirectory.LOCK_FILE_NAME).toPath(), | ||
StandardOpenOption.CREATE, | ||
StandardOpenOption.WRITE); | ||
final FileChannel channel2 = FileChannel.open(new File(task2Dir, StateDirectory.LOCK_FILE_NAME).toPath(), | ||
final FileChannel channel2 = FileChannel.open( | ||
new File(task2Dir, taskId2 + StateDirectory.LOCK_FILE_NAME).toPath(), | ||
StandardOpenOption.CREATE, | ||
StandardOpenOption.WRITE) | ||
) { | ||
|
@@ -196,15 +176,14 @@ public void shouldCleanUpTaskStateDirectoriesThatAreNotCurrentlyLocked() throws | |
directory.directoryForTask(new TaskId(2, 0)); | ||
|
||
List<File> files = Arrays.asList(appDir.listFiles()); | ||
assertEquals(3, files.size()); | ||
assertEquals(1, files.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this? Shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will dig some more on these tests once Guozhang confirms the plan. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was due to the specification of StandardOpenOption.DELETE_ON_CLOSE to FileChannel.open call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mjsax There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for late reply. It was a little crazy the last weeks and I did not find time earlier. I cannot remember why we want to add the DELETE_ON_CLOSE option? Can you refresh my mind? Also, I am not sure why this option reduced the file count? I understand that the task directories are actually not created any longer, however, we moved both lock files up the hierarchy and thus the count should not change? Also, did you see this older comment: #5650 (comment) For a clean upgrade path, addressing this issue is important. |
||
|
||
time.sleep(1000); | ||
directory.cleanRemovedTasks(0); | ||
|
||
files = Arrays.asList(appDir.listFiles()); | ||
assertEquals(2, files.size()); | ||
assertTrue(files.contains(new File(appDir, task0.toString()))); | ||
assertTrue(files.contains(new File(appDir, task1.toString()))); | ||
files = Arrays.asList(directory.stateDir().listFiles()); | ||
// lock files have been cleaned | ||
assertEquals(0, files.size()); | ||
} finally { | ||
directory.unlock(task0); | ||
directory.unlock(task1); | ||
|
@@ -358,4 +337,4 @@ public void shouldCleanupAllTaskDirectoriesIncludingGlobalOne() { | |
files = Arrays.asList(appDir.listFiles()); | ||
assertEquals(0, files.size()); | ||
} | ||
} | ||
} |
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.
Why do we remove this test? Seems, we should update the
FileChannel
here to use the new lock file name?