liangyu-1 opened a new pull request, #7859:
URL: https://github.com/apache/hadoop/pull/7859
…on because of some concurrent execution.
<!--
Thanks for sending a pull request!
1. If this is your first time, please read our contributor guidelines:
https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
2. Make sure your PR title starts with JIRA issue id, e.g.,
'HADOOP-17799. Your PR title ...'.
-->
### Description of PR
As Described in
[MAPREDUCE-7508](https://issues.apache.org/jira/browse/MAPREDUCE-7508)
When Spark scans for files, it uses the FileInputFormat.getSplits() method
to split the file. The first step in getSplits is to retrieve the file's
length. If the file length is not zero, the next step is to get the block
locations array for that file. However, if the two upstream programs rapidly
create and write to the same file (i.e., the file is overwritten or appended to
almost simultaneously), a race condition may occur:
The file's length is already non-zero,
but calling getFileBlockLocations() returns an empty array because the file
is being overwritten or is not yet fully written.
When this happens, subsequent logic in getSplits (such as accessing the last
element of the block locations array) will throw an
ArrayIndexOutOfBoundsException because the block locations array is
unexpectedly empty.
### How was this patch tested?
I rebuild the project and ran on our cluster, spark did not throw Execptions.
### For code changes:
If Array `blkLocations` is empty, it will continue to next iteration, so
that it will now find the the last blockLocation of this file.
- [ ] Does the title or this PR starts 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?
--
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]