Skip to content

receive: ignore lost+found directory when scanning tenant dirs#8801

Open
ogulcanaydogan wants to merge 2 commits intothanos-io:mainfrom
ogulcanaydogan:fix/receiver-ignore-lost-found
Open

receive: ignore lost+found directory when scanning tenant dirs#8801
ogulcanaydogan wants to merge 2 commits intothanos-io:mainfrom
ogulcanaydogan:fix/receiver-ignore-lost-found

Conversation

@ogulcanaydogan
Copy link
Copy Markdown

What

Skip any directory named lost+found when MultiTSDB.Open() and
MultiTSDB.RemoveLockFilesIfAny() scan the data directory for tenants.

Why

The ext4 filesystem creates a lost+found directory at the root of
every partition. When a receiver's --tsdb.path is the filesystem
mount point, both scan loops treat lost+found as a tenant name and
attempt to open or clean a TSDB for it, producing spurious errors on
startup.

A name-based skip is the simplest cross-platform fix. Checking the
inode or filesystem type would require platform-specific syscalls and
adds complexity without meaningful safety benefit, since a tenant
legitimately named lost+found is not a realistic concern.

Test

TestMultiTSDB/open_ignores_lost+found_directory creates a lost+found
directory in the data dir, calls Open(), and asserts no tenant was
registered for that name.

Fixes #8798

The ext4 filesystem places a lost+found directory at the root of every
partition. If a Thanos receiver's data directory is the mount point,
Open() and RemoveLockFilesIfAny() would attempt to open or clean a TSDB
for a tenant named "lost+found", producing spurious errors.

Skip any directory entry named "lost+found" in both code paths.

Fixes thanos-io#8798

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
Comment thread pkg/receive/multitsdb.go Outdated
if !f.IsDir() {
continue
}
if f.Name() == "lost+found" {
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.

Could you convert this into a constant and write a comment describing why it is ignored and why this was chosen instead of the other options? Basically, copy/paste what you wrote in the description.

Per reviewer feedback, replace the "lost+found" string literal with a
named constant and document why the directory is skipped and why a
name-based check was chosen over inode or filesystem-type inspection.

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
@pull-request-size pull-request-size Bot added size/M and removed size/S labels May 4, 2026
@ogulcanaydogan
Copy link
Copy Markdown
Author

Extracted the string into a lostFoundDir constant and added a comment with the full rationale. Both call sites now reference the constant.

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.

Thanos receiver should ignore "lost+found" directory

2 participants