Repository navigation
Conversation
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 |
|
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. |
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:
|
|
PR: [apache/hbase#8845](#8845) SummaryThank you for addressing the previous review comments. The updated implementation represents substantial progress. Most of the original concerns have been resolved, particularly the possibility that marker creation failures could invalidate an already committed backup. The additional negative tests and improvements to backup cleanup are also welcome. However, I still see two correctness concerns that should be addressed before approval. 1. Status of Previous Review Comments
Marker creation failure — ResolvedMaking marker creation best-effort is a reasonable solution. A marker write failure should not destroy an otherwise valid backup already committed to The new Failure cleanup — AddressedAdding explicit marker deletion to The additional assertions in One remaining test improvement would be to explicitly create a stale marker before invoking repair and verify that repair removes it. This is not a separate blocker. 2. [Major] Manifest fallback contradicts the purpose of the completion markerFile: The updated Javadoc suggests falling back to checking for a valid I disagree with this recommendation. The original problem in HBASE-30517 is precisely that the existence of a backup manifest does not guarantee successful backup completion. In Therefore, the following sequence is possible:
If custom-location PITR falls back to manifest existence, it may select an incomplete backup. This effectively reintroduces the original bug. RecommendationThe completion state should distinguish between:
For newly created backups, marker absence must not automatically authorize their use in PITR. If compatibility with older backups is required, it should be handled explicitly rather than treating every readable manifest as evidence of successful completion. I agree that backward compatibility may be deferred if continuous backup and PITR have not been released to users. However, the semantics of the completion marker must remain consistent. A valid manifest is not equivalent to a completed backup. 3. [Major] Completion marker can be published before backup merge finishesFile: The revised However, the marker publication timing remains concerning. The merge procedure follows approximately this sequence: The completion marker is restored during step 4, before the merge has finished. Furthermore, There is no guarantee that Consequently, the marker may become visible before the destination metadata has been fully restored. Consider a concurrent PITR operation from another cluster:
A failure after marker publication but before merge completion creates a similar problem. The merge repair mechanism may eventually restore consistency, but it cannot prevent a concurrent external reader from observing the intermediate state. RecommendationTreat the completion marker as a publication boundary for the merged backup. I suggest:
The marker does not necessarily need to be the final operation in the entire merge procedure, but it must be published after the merged image becomes independently consistent and restorable. I would also recommend a failure-injection test that forces an exception during metadata copying or merge finalization, verifying that an incomplete merged image is never advertised as complete. This is especially important because custom-location PITR cannot depend on the originating cluster's backup lock or system table. 4. [Minor] Marker creation atomicity and filesystem semanticsFile: The implementation uses: fs.create(markerPath, true).close();The author noted that creating an empty file is already atomic. However, this assumption is not universally valid across Hadoop-compatible filesystems. HDFS and object stores have different file creation, close, and visibility semantics. The fact that the marker contains no data simplifies the implementation, but it does not establish universal atomic-publication guarantees. I do not necessarily recommend introducing temporary-file-and-rename logic, since rename operations themselves are not atomic on many object stores. Instead, the required consistency semantics should be explicitly documented. For ordinary backup completion, the current best-effort approach seems reasonable because the marker is written after the backup state has been committed. For backup merge, however, the publication ordering discussed above remains important. I consider this nonblocking if the merge publication issue is addressed and the supported filesystem assumptions are documented. 5. Test CoverageThe updated tests substantially improve coverage:
I recommend the following additional tests:
The first is a useful enhancement. The second and third are important for ensuring the correctness of the completion-marker protocol. Final AssessmentThe author has addressed most of the substantive issues from the original review. I am satisfied with:
Two concerns remain: 1. Manifest fallback: A valid manifest must not be treated as unconditional proof of successful backup completion. Doing so would undermine the purpose of HBASE-30517. 2. Marker publication during merge: The completion marker must not become visible before the merged backup is independently consistent and restorable. The second concern is particularly important because external PITR clients may not have access to the originating cluster's synchronization or backup metadata. I recommend addressing these two issues before merging. Once the marker semantics and merge publication ordering are corrected, I see no reason to block this PR over the remaining minor implementation details. Overall recommendation: Request changes. Original AI-assisted review by ChatGPT 5.6 Sol. Follow-up review by ChatGPT (GPT-6), based on static inspection of PR #8845 through commit |
anmolnar
left a comment
There was a problem hiding this comment.
Changes looks good to me. Just a few comments.
|
Hey @anmolnar and @VladRodionov, I have addressed some additional comments again. These include:
|
…fter a backup succeeds Change-Id: I0036051387ec1e19d92843cde53c6f8fe5626035
f1713cc to
6ec61b3
Compare
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.