-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deadlock when closing transient push query (#4297)
fixes: #4296 The produce side not calls `offer` in a loop, with a short timeout, to try and put the row into the blocking queue. When the consume side closes the query, e.g. on an `EOFException` if the user has closed the connection, the query first closes the queue; setting a flag the producers are checking on each loop; causing any producers to exit the loop. Then it can safely close the KS topology. (cherry picked from commit 6b5ce0c)
- Loading branch information
1 parent
4dcab06
commit ac8fb63
Showing
10 changed files
with
366 additions
and
83 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
ksql-engine/src/main/java/io/confluent/ksql/query/BlockingRowQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.ksql.query; | ||
|
||
import io.confluent.ksql.GenericRow; | ||
import java.util.Collection; | ||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.kafka.streams.KeyValue; | ||
|
||
/** | ||
* The queue between the Kafka-streams topology and the client connection. | ||
* | ||
* <p>The KS topology writes to the queue from its {@code StreamThread}, while the KSQL server | ||
* thread that is servicing the client request reads from the queue and writes to the client | ||
* socket. | ||
*/ | ||
public interface BlockingRowQueue { | ||
|
||
/** | ||
* Sets the limit handler that will be called when any row limit is reached. | ||
* | ||
* <p>Replaces any previous handler. | ||
* | ||
* @param limitHandler the handler. | ||
*/ | ||
void setLimitHandler(LimitHandler limitHandler); | ||
|
||
/** | ||
* Poll the queue for a single row | ||
* | ||
* @see BlockingQueue#poll(long, TimeUnit) | ||
*/ | ||
KeyValue<String, GenericRow> poll(long timeout, TimeUnit unit) | ||
throws InterruptedException; | ||
|
||
/** | ||
* Drain the queue to the supplied {@code collection}. | ||
* | ||
* @see BlockingQueue#drainTo(Collection) | ||
*/ | ||
void drainTo(Collection<? super KeyValue<String, GenericRow>> collection); | ||
|
||
/** | ||
* The size of the queue. | ||
* | ||
* @see BlockingQueue#size() | ||
*/ | ||
int size(); | ||
|
||
/** | ||
* Close the queue. | ||
*/ | ||
void close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.