iskenderurs opened a new pull request, #8956:
URL: https://github.com/apache/hadoop/pull/8956

   ### Description of PR
   
   Jira: [HDFS-18024](https://issues.apache.org/jira/browse/HDFS-18024)
   
   Preserve the copy-on-truncate source when standby replays deletion of the 
last snapshot while truncate recovery is pending. `OP_TRUNCATE` replay leaves 
its target `UNDER_CONSTRUCTION`, which bypasses the `UNDER_RECOVERY`-only 
protection in `FileDiffList` introduced by HDFS-7903. The source disappears 
from the standby block map while recovery still needs its bytes. After 
promotion, block reports can then lead to premature invalidation of the source 
replicas.
   
   Protect the source for every incomplete target. Capture that source before 
`OP_CLOSE` replay completes the target, then release it only if no snapshot 
references remain. Resolve and detach the canonical block before removal. The 
change is limited to `FileDiffList`, CLOSE replay in `FSEditLogLoader`, and a 
three-case ordinary QJM HA test. No protocol, configuration or layout change.
   
   ### How was this patch tested?
   
   Base: apache/hadoop trunk `6c8dc8f2216cab134d5546f3327ad5907ef4b7d3`. JDK 
17.0.20.1, Maven 3.9.16, macOS ARM64, pure Java MiniClusters. Every run uses 
`-Dmaven.test.failure.ignore=false`, `-DenableAssertions=true`, 
`-DargLine=-ea`, `-DforkCount=1`, `-DtestsThreadCount=1` and an isolated Maven 
repository. The new fixture checks runtime assertions are enabled.
   
   | Runtime | Result |
   | --- | --- |
   | Current trunk + new fixture | 3 cases: expected source-retention failure 
1; controls pass 2; errors/skips 0 |
   | Retention-only patch, c815ec8e (affected files unchanged at final base) | 
3 cases: expected source leak after CLOSE failure 1; controls pass 2; 
errors/skips 0 |
   | Full patch, current trunk | `TestTruncateSnapshotSource` 3, 
`TestFileTruncate` 24, `TestFSEditLogLoader` 26 (13 sync + 13 async): **53 
pass, failures/errors/skips 0** |
   
   The new cases cover standby retention, active retention as a control, 
promotion and lease recovery with exact truncated bytes, source cleanup after 
CLOSE replay on both NameNodes, and snapshot retention through CLOSE followed 
by later snapshot deletion. Surefire XML testcase nodes and Maven summaries 
were checked, including the parameterized edit-log suite whose aggregate root 
reports zero tests.
   
   Checkstyle 11.1.0: no diagnostics in the new test or added runtime lines (30 
existing diagnostics in the selected production files). Targeted SpotBugs 4.9.7 
before/after for the two changed runtime classes: no new findings; same 11 
findings. `git diff --check` passes.
   
   Validation caveat: the new HA case and existing truncate tests log an 
active-side `BlocksMap.removeBlock` assertion after CLOSE is persisted, despite 
passing JUnit results. A separate unmodified-trunk 
`TestFileTruncate#testUpgradeAndRestart` control also logs it (1/1 pass). 
`FSNamesystem` is unchanged; this PR does not claim to repair that active-side 
behavior or qualify complete physical source GC. Native-library and shell/Bats 
suites were not run; Bats is unavailable locally.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id?
   - Object storage integration tests: not applicable.
   - New dependencies: none.
   - LICENSE/NOTICE changes: not applicable.
   
   ### AI Tooling
   
   Contains content generated by OpenAI Codex.
   
   - [x] The PR includes the phrase "Contains content generated by OpenAI 
Codex".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to