Skip to content

HBASE-30517: Non-COMPLETE backups can be used in Point-In-Time Restore with a custom backup location - #8835

Open
kgeisz wants to merge 2 commits into
apache:masterfrom
kgeisz:HBASE-30517-filter-out-non-COMPLETE-backups
Open

kgeisz wants to merge 2 commits into
apache:masterfrom
kgeisz:HBASE-30517-filter-out-non-COMPLETE-backups

Conversation

@kgeisz

@kgeisz kgeisz commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/HBASE-30517

AI Usage

Code changes assisted by Claude Opus 4.6.

Summary

The AbstractPitrRestoreHandler class has two implementations - DefaultPitrRestoreHandler and CustomBackupLocationPitrRestoreHandler. Both of these classes implement the getBackupMetadata() method. The DefaultPitrRestoreHandler class correctly filters out backups that don't have a COMPLETE state. However, CustomBackupLocationPitrRestoreHandler's implementation of this method does not do this.

The changes in this PR ensure only COMPLETE backups are used when performing a Point-In-Time Restore on backups with a custom backup location.

@kgeisz kgeisz changed the title Non-COMPLETE backups can be used in Point-In-Time Restore with a custom backup location HBASE-30517: Non-COMPLETE backups can be used in Point-In-Time Restore with a custom backup location Nov 3, 2026
@VladRodionov

Copy link
Copy Markdown
Contributor

PR Review by ChatGPT 5.6 Sol

Review Summary

The PR addresses a valid correctness issue: incomplete backups must not be selected for Point-in-Time Restore (PITR).

However, I have two concerns with the proposed implementation, including a potential regression in custom backup location support.

1. [Blocking] Custom backup locations now depend on the current cluster's BackupSystemTable

CustomBackupLocationPitrRestoreHandler.java

Previously, the custom-location handler discovered backup images directly from filesystem manifests. With this change, each image must also have a corresponding BackupInfo entry in the current cluster's BackupSystemTable, with state COMPLETE.

This introduces a dependency that may break an important use case:

  1. Cluster A creates a complete backup in an external filesystem location.
  2. The backup is moved or made accessible to Cluster B.
  3. Cluster B attempts PITR using the custom backup location.
  4. Cluster B's BackupSystemTable does not contain the backup ID.
  5. The handler silently excludes the backup.

The backup manifest is designed to preserve the metadata needed for restoration, including support for relocated backups. Requiring the current cluster's system table to contain the original backup record appears inconsistent with this design.

Recommendation: Preserve filesystem-based backup discovery without introducing a mandatory dependency on the current cluster's BackupSystemTable.

Ideally, backup completeness should be verifiable from filesystem metadata, perhaps through an explicit completion marker written only after successful backup finalization.

If this requires a larger change, we should at least clarify the intended compatibility guarantees and add a regression test covering backups created on another cluster or moved to a different location.

2. [Major] IOException must not be silently interpreted as an incomplete backup

CustomBackupLocationPitrRestoreHandler.java — isComplete()

The current implementation catches IOException from readBackupInfo() and returns false.

This conflates three different conditions:

  • The backup exists but is not complete.
  • The backup metadata does not exist.
  • The system table cannot be read due to an I/O failure.

A temporary I/O failure could silently exclude otherwise valid backup images, potentially producing misleading PITR errors.

Recommendation: Propagate IOException rather than silently treating it as an incomplete backup. The default PITR handler already propagates metadata access errors, and the custom handler should follow the same approach.

Since the stream predicate cannot directly throw a checked exception, replacing the stream with a conventional loop would simplify the implementation.

3. [Major] Missing compatibility regression tests

TestCustomBackupLocationPitrRestoreHandler.java

The new tests cover filtering by backup state, missing metadata entries, and I/O failures. However, they primarily validate the newly introduced behavior rather than preserving existing functionality.

In particular, the test asserting that an image with no corresponding BackupInfo should be filtered out effectively codifies the compatibility concern described above.

Recommendation: Add a test verifying that a complete backup discovered through a custom filesystem location remains usable when the current cluster does not have its original system-table metadata, provided the required PITR metadata and WALs are available.

4. [Minor] Repeated system-table lookups

The handler performs a separate readBackupInfo() lookup for every discovered backup image.

For a location containing many images, this results in N individual metadata lookups. If the system-table dependency is retained, consider retrieving the relevant backup history in a batch and filtering against an in-memory map.

This is a minor optimization and not a merge blocker.


Conclusion

I agree with the objective of preventing incomplete backups from being selected for PITR. However, the implementation introduces a potentially breaking dependency between custom-location restoration and the current cluster's system-table metadata.

I recommend addressing the custom-location compatibility issue and IOException handling before merging.

The central architectural question is whether a backup stored in an external filesystem location should remain independently restorable without requiring its original BackupSystemTable records. The existing manifest-based design suggests that it should.

…e with a custom backup location

Change-Id: I22290330a3811e4e63744fc43e3016f29f447a56
Change-Id: I9f9f29a8a767be0623ef134adcbb09cdfe85ecfa
@kgeisz
kgeisz force-pushed the HBASE-30517-filter-out-non-COMPLETE-backups branch from 4d1b956 to c225b44 Compare November 25, 2026 14:31
@taklwu
taklwu requested a balanced review from Copilot November 25, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the custom-location restore metadata filtering change.

No open issues 🎉

What changed in this PR

Addresses HBASE-30517 by filtering custom-location point-in-time restore metadata using backup completion markers, without relying on the current cluster’s backup system table.

Changes:

  • Excludes custom-location backups without completion markers and propagates marker-check I/O errors.
  • Adds metadata-retrieval logging to both restore handlers.
  • Adds shared filtering tests and custom-location tests covering filesystem markers, error propagation, and system-table independence.
File Description
hbase-backup/​src/​test/​java/​org/​apache/​hadoop/​hbase/​backup/​impl/​TestDefaultPitrRestoreHandler.java Tests completion-state filtering in the default handler.
hbase-backup/​src/​test/​java/​org/​apache/​hadoop/​hbase/​backup/​impl/​TestCustomBackupLocationPitrRestoreHandler.java Tests marker filtering, I/O errors, system-table independence, and on-disk markers.
hbase-backup/​src/​test/​java/​org/​apache/​hadoop/​hbase/​backup/​impl/​TestAbstractPitrRestoreHandlerGetBackupMetadata.java Provides shared fixtures and completion-filtering tests for both handlers.
hbase-backup/​src/​main/​java/​org/​apache/​hadoop/​hbase/​backup/​impl/​DefaultPitrRestoreHandler.java Logs metadata retrieval; retains existing completion-state filtering.
hbase-backup/​src/​main/​java/​org/​apache/​hadoop/​hbase/​backup/​impl/​CustomBackupLocationPitrRestoreHandler.java Filters backups by completion marker and logs retrieval and skipped backups.

Review effort: Balanced

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.

3 participants