[Bug] Local backup snapshots are indexed only by label and can collide across databases
- Dominant language
- Java
- Stars
- 15.9k
- Forks
- 3.9k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 520
Description
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
### Version
- master
- branch-3.1
### Whats Wrong?
Local backup snapshots are indexed in FE memory only by the bare snapshot label.
The current implementation keeps local snapshots in `BackupHandler.localSnapshots` as `Map` and `getSnapshot` RPC also looks up the snapshot only by `request.label_name`.
As a result, local snapshots from different databases can collide when they use the same label:
- creating a later local snapshot with the same label can overwrite the previous one in FE memory;
- `getSnapshot` may return the snapshot from another database;
- eviction or removal may also affect the wrong snapshot entry.
This is not just a path naming issue. Although local staging directories include `label + "__" + createTime` and remote job-info files include timestamps, the in-
### Seakup key is still only the bare label.
### What You Expected?
Local backup snapshots should be uniquely identified by database scope, for example `(dbId, label)` or an equivalent key that matches the SQL semantics of `db.label`.
`getSnapshot` should use the database dimension from the request when resolving a local snapshot, instead of looking up by bare label only.
### How to Reproduce?
1. Create database `db1` and database `db2`.
2. Create one local backup snapshot in `db1` with label `same_label`.
3. Create another local backup snapshot in `db2` with the same label `same_label`.
4. Call the local snapshot retrieval path for `db1.same_label` and `db2.same_label`.
Expected:
Each database resolves its own local snapshot.
Actual:
The FE local snapshot map is keyed only by `label`, so one snapshot can overwrite the other and the lookup can resolve the wrong snapshot.
### Anything Else?
Relevant code paths:
- `fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java`
- `fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java`
- `fe/fe-core/src/main/java/org/apache/doris/analysis/AbstractBackupStmt.java`
- `fe/fe-core/src/main/java/org/apache/doris/analysis/LabelName.java`
This issue is intentionally tracked separately from the recent staging-directory cleanup changes, because it is a distinct correctness problem and should be fixed in a focused PR.
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this projects Code of Conduct
Contributor guide
Research direction
Start with fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java and trace the local snapshot map and getSnapshot path through FrontendServiceImpl.java. Read AbstractBackupStmt.java and LabelName.java to understand database-qualified snapshot semantics, then reproduce the db1/db2 same-label scenario. Done means each database resolves, evicts, and removes its own local snapshot without collisions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100