Caideyipi opened a new pull request, #18376:
URL: https://github.com/apache/iotdb/pull/18376
## Description
`PipeTsFileResourceManager.increaseFileReference` checked whether a resource
existed before entering the creation critical section. Historical and realtime
extractors could both observe a missing resource, then create and put separate
`PipeTsFileResource` instances for the same hardlink. The later put overwrote
the first reference count, so releasing one event could delete a hardlink that
another event still needed and stop the pipe with `FileNotFoundException`.
This change rechecks the resource map after acquiring the segment lock. If
another caller has already created the resource, it increments and reuses that
resource instead of overwriting it.
A concurrent regression test starts 64 retain operations together and
verifies that both the pipe-private and shared reference counts reach 64, then
verifies complete cleanup after all releases. Before the fix, the test
reproduced a lost count (`expected: 64, actual: 58`); with the fix, the full
test class passes.
Validation:
- `mvn -pl iotdb-core/datanode -Ddevelocity.off=true
-Dtest=PipeTsFileResourceManagerTest test`
- `mvn -pl iotdb-core/datanode -Ddevelocity.off=true spotless:check`
- `mvn -pl iotdb-core/datanode -Ddevelocity.off=true checkstyle:check`
- `git diff --check`
This PR has:
- [x] been self-reviewed.
- [x] concurrent write
- [x] added comments explaining the why and the intent of the code wherever
it would not be obvious.
- [x] added unit tests to cover the concurrent code path.
<hr>
##### Key changed/added classes
- `PipeTsFileResourceManager`
- `PipeTsFileResourceManagerTest`
--
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]