Skip to content

[server]: remove orphan files and directories when tablet starts up#3388

Open
gyang94 wants to merge 1 commit into
apache:mainfrom
gyang94:fix-ts-orphan-files
Open

[server]: remove orphan files and directories when tablet starts up#3388
gyang94 wants to merge 1 commit into
apache:mainfrom
gyang94:fix-ts-orphan-files

Conversation

@gyang94
Copy link
Copy Markdown
Contributor

@gyang94 gyang94 commented May 27, 2026

Purpose

Linked issue: close #3387

Brief change log

Two changes, one in each cleanup path:

1. ReplicaManager: handle NoneReplica with deleteLocal=true

When the NoneReplica branch receives deleteLocal=true, look up the bucket in LogManager.currentLogs. If present, the log tablet was loaded at startup but never registered in allReplicas — it is an orphan. Drop the log via logManager.dropLog(), delete the sibling KV tablet directory (via kvManager.dropKv() if loaded, otherwise direct FileUtils.deleteDirectory), update disk usage accounting, and record the parent directory for empty-dir cleanup.

This handles the partition deletion scenario.

2. LogManager: clean up empty parent directories in SchemaNotExistException handler

After the existing handler deletes log-N/ and kv-N/, check whether the parent directory is empty and delete it. For partitioned tables, also check the grandparent (table directory). For non-partitioned tables, the grandparent is the database directory and must NOT be deleted. This is safe under parallel loadAllLogs execution — deleteDirectoryQuietly tolerates races.

This handles the table deletion scenario.

Tests

API and Format

Documentation

@gyang94 gyang94 changed the title fix: remote orphan files and directories when tablet starts up [server]: remove orphan files and directories when tablet starts up May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[server] TabletServer leaves orphan replica directories after restart during table/partition deletion

1 participant