cxzl25 opened a new pull request, #8980:
URL: https://github.com/apache/hadoop/pull/8980
### Description of PR
`DirectoryScanner#reconcile` sleeps between batches while holding the
`diffs` lock (HDFS-14476), and the loop does not notice that the scanner has
been shutdown. `DirectoryScanner#shutdown` waits 1 minute for the master thread
and then
calls `clear()`, which blocks on the same lock with no timeout. As a result
`DataNode#shutdown` hangs until every diff has been reconciled, which can take
tens of minutes when there are many diffs.
This PR adds a `shutdownRequested` flag that is set at the beginning of
`shutdown()` and checked at the top of the reconcile loop, so the loop exits
after at most one `checkAndUpdate` plus one batch sleep.
A separate flag is used instead of `shouldRun` because `shouldRun` is only
true between `start()` and `shutdown()`: `reconcile()` is also called directly
on scanners that were never started (most of `TestDirectoryScanner` does this),
and those calls must still do the full reconciliation.
Aborting the loop is safe: each `checkAndUpdate` is independent, and the
remaining diffs are recomputed by the next scan.
### How was this patch tested?
Added `TestDirectoryScanner#testShutdownAbortsReconcile`. It creates 20
diffs, makes the scanner sleep 1s after every diff, calls `shutdown()` once
`reconcile()` has started, and asserts that fewer than 20 diffs were handled.
- With the fix the test passes in about 4s.
- Without the fix it fails after about 24s with "reconcile was not aborted
by shutdown, handled 20 diffs".
Ran the whole `TestDirectoryScanner`: 15 of 16 pass. `testThrottling` fails
with "Throttle is too permissive", a timing based assertion that is not related
to this change.
### For code changes:
- [ ] Does the title of this PR start with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: Have the integration tests been executed and the
endpoint
declared according to the connector-specific documentation? *Note:
Automated CI
testing doesn't cover all cases so manual testing with cloud storage
is still
required.*
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
### AI Tooling
If an AI tool was used:
- [ ] The PR includes the phrase "Contains content generated by <tool>"
where <tool> is the name of the AI tool used.
- [ ] 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]