You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/07/19 22:19:37 UTC
[GitHub] [incubator-druid] jihoonson opened a new pull request #8114: Fix
race between canHandle() and addSegment() in StorageLocation
jihoonson opened a new pull request #8114: Fix race between canHandle() and addSegment() in StorageLocation
URL: https://github.com/apache/incubator-druid/pull/8114
### Description
Historicals can use multiple threads to load segments in parallel from deep storage now (https://github.com/apache/incubator-druid/pull/7088, https://github.com/apache/incubator-druid/pull/4966). This could lead an incorrect computation of remaining space in `StorageLocation`.
The current pattern to use `StorageLocation` is:
```java
if (location.canHandle(segment)) {
// load segment files into the location
location.addSegment(segment);
}
```
Even though each of `canHandle()` and `addSegment()` is synchronized, they are not atomically executed which could lead a wrong estimation of the available space.
This PR fixes this problem to add a new method, `reserve()`, to `StorageLocation`. `reserve()` basically does what `canHandle()` and `addSegment()` atomically. If some error occurs after `reserve()`, the caller should call `remove(segment)` to release the reserved space.
<hr>
This PR has:
- [x] been self-reviewed.
- [x] added unit tests or modified existing tests to cover new code paths.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org