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

   ### Description of PR
   
   JIRA: https://issues.apache.org/jira/browse/HADOOP-20067
   
   `LocalFSFileInputStream#getAsyncChannel()` checks `asyncChannel == null` 
outside the lock but not again inside it, and the field is not volatile. When 
two threads make the first `readVectored()` call on the same stream, both can 
open an `AsynchronousFileChannel`. `close()` only closes the one left in the 
field, so the other keeps its file descriptor until the JVM exits. 
`PositionedReadable` requires positioned reads, `readVectored` included, to be 
thread-safe.
   
   This patch makes the field volatile and checks it again inside the 
`synchronized` block. It follows up on 
https://github.com/apache/hadoop/pull/8511#discussion_r4452981403. A 
`readVectored()` after `close()` still opens a new channel; that is unchanged 
here.
   
   ### How was this patch tested?
   
   Added 
`TestRawLocalFileSystemAsyncChannel#testConcurrentGetAsyncChannelOpensSingleChannel`:
 eight threads released from a barrier call `getAsyncChannel()` on a fresh 
stream and must all get the same channel, which must be closed after `close()`. 
With the fix this is deterministic. Without it the test fails when the threads 
race, which depends on scheduling, so the race runs three times.
   
   ### For code changes:
   
   - [x] 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?
   - [ ] 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
   
   - [x] The PR includes the phrase "Contains content generated by Claude Opus".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Opus.
   


-- 
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]

  • [PR] HADOOP-20067. RawLocalFil... LuciferYang (via GitHub) via common-issues

Reply via email to