Skip to content

MINOR: AbstractSegments should not swallow exceptions#21636

Merged
mjsax merged 2 commits intoapache:trunkfrom
mjsax:minor-abstract-segment-should-not-swallow
Mar 6, 2026
Merged

MINOR: AbstractSegments should not swallow exceptions#21636
mjsax merged 2 commits intoapache:trunkfrom
mjsax:minor-abstract-segment-should-not-swallow

Conversation

@mjsax
Copy link
Copy Markdown
Member

@mjsax mjsax commented Mar 5, 2026

Reviewers: TengYao Chi frankvicky@apache.org, Chia-Ping Tsai
chia7712@gmail.com

public abstract class AbstractRocksDBWindowStoreTest extends AbstractWindowBytesStoreTest {

private static final String STORE_NAME = "rocksDB window store";
private static final String STORE_NAME = "rocksDB-windowstore";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related -- but avoiding spaces sound like a good idea


// remove local store image
Utils.delete(baseDir);
Utils.delete(new File(baseDir, STORE_NAME));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We delete a directory "too high" in the hierarchy, and thus when we later try to create a segment we cannot, because the parent directory does not exist.

final File oldSegment = new File(storeDirectoryPath + File.separator + storeName + "-" + formatter.format(new Date(segmentId * segmentInterval)));
//noinspection ResultOfMethodCallIgnored
Files.createFile(oldSegment.toPath());
Files.createDirectory(oldSegment.toPath());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Segments are directories -- if we create it here as a file, we later fail trying to create it as directory (create dir passed if dir already exists)

Copy link
Copy Markdown
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm feeling a bit nitpicky today

Arrays.stream(list)
.map(segment -> segmentIdFromSegmentName(segment, dir))
.sorted() // open segments in the id order
.filter(segmentId -> segmentId >= 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it would be better to apply filter before sort

throw new ProcessorStateException(String.format("dir %s doesn't exist and cannot be created for segments %s", dir, name));
}
final File dir = new File(context.stateDir(), name);
if (dir.exists()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we ensure the dir is a directory rather than regular file?

@mjsax mjsax merged commit 830d440 into apache:trunk Mar 6, 2026
20 checks passed
@mjsax mjsax deleted the minor-abstract-segment-should-not-swallow branch March 6, 2026 06:34
nicktelford pushed a commit to nicktelford/kafka that referenced this pull request Mar 6, 2026
Reviewers: TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai
 <chia7712@gmail.com>
gabriellefu pushed a commit to gabriellefu/kafka that referenced this pull request Mar 30, 2026
Reviewers: TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai
 <chia7712@gmail.com>
Shekharrajak pushed a commit to Shekharrajak/kafka that referenced this pull request Mar 31, 2026
Reviewers: TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai
 <chia7712@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants