Caideyipi opened a new pull request, #18659:
URL: https://github.com/apache/iotdb/pull/18659
## Description
### Problem
A subscription consumer could block forever in `close()` when the DataNode
accepted a synchronous `pipeSubscribe(CLOSE)` request but never returned a
response. The closing thread held the consumer/provider monitor while waiting
in socket read, so a concurrent shutdown-hook `close()` also waited for that
monitor and SIGTERM could not terminate the process.
The pull consumer also committed buffered messages before reaching the close
handshake. Those commit RPCs used the same unbounded socket read and could hang
the close path first.
### Changes
- Apply a dedicated 5-second transport read timeout before close-time commit
and CLOSE RPCs.
- Serialize provider RPCs with an explicit lock so close preparation can
detect an already-blocked RPC. Since changing SO_TIMEOUT cannot affect a read
already in progress, close the transport to interrupt that read.
- Force-close the transport before local Session cleanup, preventing a
second `closeSession` RPC from blocking.
- Publish the terminal consumer state before network cleanup and use an
atomic closing gate, so concurrent `close()` calls return immediately.
- Detach providers during terminal close without waiting for the provider
collection write lock. Providers created concurrently with terminal close are
closed instead of being added.
- Preserve manual-commit close validation, while protecting pull-consumer
final auto-commit RPCs with the close timeout.
### Tests
- Added a local black-hole Thrift server test that accepts `pipeSubscribe`
without responding and verifies the dynamically applied socket read timeout.
- Added a lifecycle test proving that a concurrent pull-consumer `close()`
returns while the first close is still running.
- Added transport timeout/force-close unit coverage.
- Ran all 12 subscription test classes: 52 tests, 0 failures, 0 errors.
- Ran `SessionConnectionTest`: 34 tests, 0 failures, 0 errors.
- Ran full-reactor `test-compile` for both default and `with-zh-locale`
builds.
This has not yet been revalidated against the original external cluster
workload; the no-response condition is covered locally by the black-hole Thrift
test.
<hr>
This PR has:
- [x] been self-reviewed.
- [x] concurrent read
- [x] concurrent write
- [x] concurrent read and write
- [x] added comments explaining the why and intent of non-obvious close
behavior.
- [x] added unit tests covering the new code paths.
<hr>
##### Key changed/added classes
- `SessionConnection` / `SubscriptionSessionConnection`
- `AbstractSubscriptionProvider` / `AbstractSubscriptionProviders`
- `AbstractSubscriptionConsumer`
- `AbstractSubscriptionPullConsumer` / `AbstractSubscriptionPushConsumer`
- `SubscriptionSessionConnectionTimeoutTest`
- `SubscriptionConsumerLifecycleTest`
--
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]