Skip to content

[Bug] Local backup snapshots are indexed only by label and can collide across databases #65798

Description

@wenzhenghu

Search before asking

  • I had searched in the issues 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<String, BackupJob> 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

  • I agree to follow this projects Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions