Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't wait for streams thread to be in running state #4908

Merged
merged 3 commits into from
Mar 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.kafka.streams.KafkaStreams.State;
import org.apache.kafka.streams.StoreQueryParameters;
import org.apache.kafka.streams.state.QueryableStoreType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Wrapper around Kafka Streams state store.
Expand All @@ -39,6 +41,7 @@ class KsStateStore {
private final LogicalSchema schema;
private final KsqlConfig ksqlConfig;
private final Supplier<Long> clock;
private static final Logger LOG = LoggerFactory.getLogger(KsStateStore.class);

KsStateStore(
final String stateStoreName,
Expand Down Expand Up @@ -69,15 +72,14 @@ LogicalSchema schema() {
}

<T> T store(final QueryableStoreType<T> queryableStoreType) {
awaitRunning();

try {
if (ksqlConfig.getBoolean(KsqlConfig.KSQL_QUERY_PULL_ENABLE_STANDBY_READS)) {
// True flag allows queries on standby and replica state stores
return kafkaStreams.store(
StoreQueryParameters.fromNameAndType(stateStoreName, queryableStoreType)
.enableStaleStores());
} else {
awaitRunning();
vpapavas marked this conversation as resolved.
Show resolved Hide resolved
// False flag allows queries only on active state store
return kafkaStreams.store(
StoreQueryParameters.fromNameAndType(stateStoreName, queryableStoreType));
Expand All @@ -93,6 +95,7 @@ <T> T store(final QueryableStoreType<T> queryableStoreType) {
}

private void awaitRunning() {
LOG.debug("Waiting for streams thread to be in RUNNING state");
vpapavas marked this conversation as resolved.
Show resolved Hide resolved
final long timeoutMs =
ksqlConfig.getLong(KsqlConfig.KSQL_QUERY_PULL_STREAMSTORE_REBALANCING_TIMEOUT_MS_CONFIG);
final long threshold = clock.get() + timeoutMs;
Expand Down