DATAREDIS-905 - Fix race condition in StreamMessageListenerContainer subscription activation.
Stream subscriptions now report reliably their state reflecting regarding activation, cancellation and while being active. Previously, registering a subscription with immediate cancel could report an inactive subscription although StreamMessageListenerContainer could perform a stream read. When activating a subscription in StreamMessageListenerContainer, awaiting activation (awaitStart(…)), immediately cancelling the subscription, and reading active state via Subscription.isActive(), Subscription.isActive() could report in this case false. This was because we checked that the status was either running or the stream read has reached event looping. The state was CANCELLED and the task thread had not yet reached the event loop and so there was a gap. Original Pull Request: #377
This commit is contained in:
committed by
Christoph Strobl
parent
f02369fa0a
commit
ed79d14355
@@ -115,11 +115,11 @@ class StreamPollTask<K, V extends Record<K, ?>> implements Task {
|
||||
public void run() {
|
||||
|
||||
pollState.starting();
|
||||
pollState.running();
|
||||
|
||||
try {
|
||||
|
||||
isInEventLoop = true;
|
||||
pollState.running();
|
||||
doLoop(request.getStreamOffset().getKey());
|
||||
} finally {
|
||||
isInEventLoop = false;
|
||||
@@ -144,8 +144,7 @@ class StreamPollTask<K, V extends Record<K, ?>> implements Task {
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
pollState.cancel();
|
||||
|
||||
cancel();
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user