Skip to content

[Bug]: File-per-key ScanMeta double-counts rescans and aborts on malformed files #2982

Description

@feichai0017

Bug Report

On current main, StorageBackendAdaptor::ScanMeta() is not safe as a recovery operation.

Two related problems are visible in the current implementation:

  1. Every scan increments the member counters total_keys and total_size without resetting or recomputing them. FileStorage::ReRegisterOffloadedObjects() reruns ScanMeta() on the same backend after master metadata loss, so repeated recovery scans inflate the usage counters.
  2. Each regular file is passed directly to struct_pb::from_pb(). The decoder throws on malformed/truncated input, but ScanMeta() does not catch per-record exceptions. A single partial or corrupted cache file can therefore abort startup or repeated master-recovery scans.

The existing adaptor test avoids calling ScanMeta() twice on one instance specifically to avoid double-counting, which leaves the production rescan path uncovered.

Expected behavior

A successful full scan should replace the recovered usage totals rather than accumulate them, and one malformed cache file should be logged and skipped without preventing valid files from being re-registered.

Before submitting...

  • Searched existing issues and open PRs for rescan accounting and malformed file handling.

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