Repository navigation
Conversation
…fter a backup succeeds Change-Id: I0036051387ec1e19d92843cde53c6f8fe5626035
Thanks for picking this up! Using a marker file next to 1. A failed marker write can wipe a backup that's already committedIn
So a transient error can leave the system table saying COMPLETE (or ask for a repair) while the data is gone. Two options:
2. Failure cleanup and repair don't remove the marker
3. Backups taken before this changeOnce #8835 filters on the marker, every backup taken before the upgrade drops out of PITR on other clusters. We should decide how to handle that, either here or explicitly in #8835 or the JIRA: a fallback, a tool that writes markers for existing COMPLETE backups, or at least a release note. Smaller items
One note for the record: during a merge's phase 2, the merged directory briefly has no marker between the rename to tmp and |
Change-Id: Ief5b3f3995344cf79fad2d81190d51b05a2c9771
|
Yet another one review from a different AI God :). Code Review: HBASE-30526 — Backup Completion MarkerPR: [apache/hbase#8845](#8845) SummaryThis PR addresses the primary architectural concern raised during the review of HBASE-30517: determining whether a backup is complete without relying on the originating cluster's Introducing a The implementation is small, and the additional tests cover marker creation for several backup types. However, the proposed changes introduce concerns around backup finalization, failure recovery, and the consistency of the completion marker with the actual backup state. 1. [Blocking] Marker creation failure can invalidate an already completed backupFile: The marker is written after: BackupSystemTable.deleteSnapshot(conn);
backupManager.updateBackupInfo(backupInfo);
HBackupFileSystem.writeBackupCompleteMarker(
conf, backupInfo.getBackupRootDir(), backupInfo.getBackupId());At this point, the backup state has already been persisted as If This creates several risks:
Recommendation: The completion marker should be integrated into the backup commit protocol, with explicitly defined failure semantics. At minimum, marker creation must not trigger destructive rollback after backup metadata has been committed and its recovery snapshot removed. One possibility is to create the marker before the irreversible finalization steps, provided that all subsequent failure paths reliably remove it. Another is to treat marker creation failures as a separate recoverable finalization error. The correct solution depends on the desired durability guarantee: if marker existence is authoritative evidence of a completed backup, its lifecycle must be coordinated with backup commit and rollback operations. 2. [Blocking] Cleanup must remove stale completion markersFiles: The new marker is created directly under the backup ID directory: However, the existing backup cleanup logic was designed before this file existed. In particular, If a backup fails after marker creation, or a recovery operation rolls back a previously marked backup, the marker may survive while the actual backup data is removed or incomplete. This would violate the fundamental invariant required by HBASE-30517:
Recommendation: Ensure the marker is deleted during all applicable backup failure, rollback, and repair paths. Consider introducing centralized helpers for marker creation, deletion, and existence checks rather than distributing marker lifecycle management across several components. A failed or rolled-back backup must not retain a completion marker. 3. [Major] Marker creation is not atomicFile: The implementation uses: fs.create(markerPath, true).close();There are two concerns:
A failure during file creation or closing may leave a marker whose existence does not reliably indicate that finalization succeeded. Because the file is empty and the intended consumer will presumably check only for its existence, there is no way to distinguish a successfully committed marker from a partially created one. Recommendation: Consider a temporary-file-and-rename protocol:
This provides a stronger publication boundary on filesystems supporting atomic rename. For object stores, the implementation must account for the specific filesystem's rename semantics; rename should not be assumed atomic universally. Also consider whether overwriting an existing completion marker should be permitted. Backup IDs should normally be unique, so an existing marker might indicate an unexpected state rather than something to overwrite. 4. [Major] Compatibility with existing backups is unresolvedRelated PR: HBASE-30517 (#8835) Backups created before this change will not contain If HBASE-30517 subsequently treats marker existence as a mandatory condition for backup selection, previously created backups may disappear from custom-location PITR discovery, even though they remain valid and restorable. This could become a backward-compatibility regression during rolling upgrades, cluster migrations, or disaster recovery. Recommendation: Define an explicit compatibility policy before relying on the marker for backup discovery. Possible approaches include:
Blindly treating every legacy backup without a marker as incomplete is not acceptable without acknowledging the compatibility impact. 5. [Major] Missing negative and recovery testsFiles: Backup test classes The PR adds assertions verifying that the completion marker exists after successful full, incremental, and continuous backups. These are useful positive tests, but the most important correctness property is the opposite: An incomplete or failed backup must never have a valid completion marker. I recommend adding tests for:
The existing 6. [Minor] Completion marker handling during backup mergeFile: Adding However, the current implementation uses: fileName.indexOf(
HBackupFileSystem.BACKUP_COMPLETE_FILE_NAME) > 0This matches any path containing the marker name, rather than strictly identifying the expected marker file. Prefer checking the filename directly: HBackupFileSystem.BACKUP_COMPLETE_FILE_NAME.equals(p.getName())It would also be useful to document the marker's state during merge. The marker is temporarily moved with the original backup directory and subsequently copied back. This means the merged backup directory does not initially advertise completion, which is desirable. However, the marker is restored before all merge operations are finalized. We should verify that the failure and repair paths preserve the intended consistency guarantees. 7. [Minor] Centralize marker path constructionFile: The marker path is currently constructed separately by production code and test utilities. Since HBASE-30517 will also need to locate the marker, I suggest introducing a helper such as: public static Path getBackupCompleteMarkerPath(
String backupRootDir, String backupId)Optionally, provide: public static boolean isBackupComplete(
Configuration conf, String backupRootDir, String backupId)
throws IOExceptionThis avoids duplicating path construction and establishes a single definition of the completion marker. The existence-check helper should propagate filesystem errors rather than silently interpreting them as a missing marker. 8. [Minor] Code quality and test organizationA few smaller improvements:
Final AssessmentI support the architectural direction of this change. A filesystem-based completion marker is a better solution than consulting the current cluster's However, the completion marker becomes part of the backup's persistent correctness contract, not merely an auxiliary metadata file. Its creation, publication, deletion, and recovery semantics must therefore be designed carefully. Before merging, I recommend addressing three primary issues:
The backward compatibility of pre-existing backups should also be explicitly resolved before HBASE-30517 starts requiring these markers. Overall recommendation: Request changes. The implementation is heading in the right direction, but the marker lifecycle needs stronger transactional guarantees before it can safely serve as authoritative evidence of backup completion. Review performed with ChatGPT 5.6 Sol. Static code review of PR #8845 and relevant Apache HBase code; tests were not executed. |
Change-Id: I7e1c27d518278b6ea38f6c22544d01ea9fff6c52
0d3e5ab to
2f889f0
Compare
|
Hey @anmolnar and @VladRodionov, I have addressed some of the review suggestions you shared. Can I get another round of reviews. IMO, the biggest concern was an error occurring when creating Some items are still unaddressed, and I will state my reasoning:
|
https://issues.apache.org/jira/browse/HBASE-30526
AI Usage
Assisted with Claude Opus 4.6
Summary
This PR is a child task of HBASE-30517 (PR #8835). The goal of PR #8835 is to make it so the
CustomBackupLocationPitrRestoreHandler.getBackupMetadata()method only gathers PITR metadata for backups in a COMPLETE state. However, as noted by one of the review comments in that PR, the current proposed implementation incorrectly relies on theBackupSystemTable.Imagine a scenario where Cluster A has created backups stored in an external storage location. If Cluster B wants to restore one of these backups, then it would need to use the
BackupSystemTableto retrieve each backup's state and filter out the non-COMPLETE backups. The problem is Cluster B'sBackupSystemTablemay not be the same as Cluster A's. With the changes in this PR, Cluster B can use the.backup.completefile in each relevant backup's directory to determine if the backup is in a COMPLETE state.