Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -73,6 +73,7 @@ public void run(SourceContext<WindowedValue<byte[]>> ctx) {
Thread.sleep(intervalMillis);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Interrupted while sleeping", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public void close() throws Exception {
}
} catch (InterruptedException e) {
LOG.debug("Could not properly await the termination of the scheduled executor service.", e);
Thread.currentThread().interrupt();
executorService.shutdownNow();
executorService = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void run(SourceContext<WindowedValue<byte[]>> ctx) {
Thread.sleep(intervalMillis);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Interrupted while sleeping", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public StreamObserver<BeamFnApi.Elements> data(
// incoming messages are sent to the single multiplexer instance.
return connectedClient.get().getInboundObserver();
} catch (InterruptedException | ExecutionException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
throw new RuntimeException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public String runImage(String imageTag, List<String> dockerOpts, List<String> ar
ImmutableList.<String>builder().add(dockerExecutable).add("pull").add(imageTag).build(),
pullTimeout);
} catch (IOException | TimeoutException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Unable to pull docker image {}", imageTag, e);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public StreamObserver<WorkerStatusResponse> workerStatus(
return existingClientFuture;
}
} catch (IOException | InterruptedException | ExecutionException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
LOG.warn("Error closing worker status client", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public State waitUntilFinish(Duration duration) {
completionFuture.get(duration.getMillis(), TimeUnit.MILLISECONDS);
return State.DONE;
} catch (InterruptedException | TimeoutException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
return getState(); // job should be RUNNING or STOPPED
} catch (ExecutionException e) {
throw new CompletionException(e.getCause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void stop() {
try {
boolean ignored = executorService.awaitTermination(5000L, TimeUnit.MILLISECONDS);
} catch (InterruptedException ignored) {
// Ignore InterruptedException during shutdown.
Thread.currentThread().interrupt();
}
if (process == null) {
return;
Expand All @@ -91,7 +91,7 @@ void stop() {
try {
process.waitFor();
} catch (InterruptedException ignored) {
// Ignore InterruptedException during shutdown.
Thread.currentThread().interrupt();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ private void forwardToConsumerForInstructionId(String instructionId, BeamFnApi.E
outboundObserver.onError(e);
return;
} catch (ExecutionException | InterruptedException | PoisonedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
if (e instanceof PoisonedException || e.getCause() instanceof PoisonedException) {
LOG.debug("Received data for poisoned instruction {}. Dropping input.", instructionId);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private static int findAvailablePort() throws IOException {
// Some systems don't free the port for future use immediately.
Thread.sleep(100);
} catch (InterruptedException exn) {
// ignore
Thread.currentThread().interrupt();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ private boolean backOffWasSuccessful(BackOff backOff) {
sleeper.sleep(backOffTime);
return true;
} catch (InterruptedException | IOException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ private boolean isPythonAvailable() {
new ProcessBuilder(executable, "--version").start().waitFor();
return true;
} catch (IOException | InterruptedException exn) {
// Ignore.
if (exn instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
}
}
return false;
Expand All @@ -459,7 +461,9 @@ private boolean isDockerAvailable() {
new ProcessBuilder(executable, "--version").start().waitFor();
return true;
} catch (IOException | InterruptedException exn) {
// Ignore.
if (exn instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ private String whichPython() {
new ProcessBuilder(executable, "--version").start().waitFor();
return executable;
} catch (IOException | InterruptedException exn) {
// Ignore.
if (exn instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
}
}
throw new RuntimeException("Unable to find a suitable Python executable.");
Expand All @@ -171,7 +173,7 @@ public static int findAvailablePort() throws IOException {
// Some systems don't free the port for future use immediately.
Thread.sleep(100);
} catch (InterruptedException exn) {
// ignore
Thread.currentThread().interrupt();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private void cleanupThreadBody() {
}
}
} catch (InterruptedException e) {
// We're being shutdown.
Thread.currentThread().interrupt();
} finally {
lock.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ CustomOptional<KinesisRecord> nextRecord() {
return CustomOptional.of(record);
} catch (InterruptedException e) {
LOG.warn("Interrupted while waiting for KinesisRecord from the buffer");
Thread.currentThread().interrupt();
return CustomOptional.absent();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ public synchronized BigQueryStorageStreamSource<T> getCurrentSource() {
// StorageClientImpl.
future.get(30, TimeUnit.SECONDS);
} catch (TimeoutException | InterruptedException | ExecutionException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
badSplitPointCalls.inc();
LOG.info(
"Split of stream {} abandoned because current position check failed with {}.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,17 @@ private MatchTableDynamicDestinations(
try (DatasetService datasetService = bqServices.getDatasetService(bqOptions)) {
return datasetService.getTable(tableReference);
} catch (InterruptedException | IOException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
LOG.info("Failed to get BigQuery table {}", tableReference);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} while (nextBackOff(Sleeper.DEFAULT, backoff));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,9 @@ public void importBatch(FinishBundleContext context) throws IOException {
// longer needed.
FileSystems.delete(tempDestinations);
} catch (IOException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
ResourceId deadLetterResourceId =
FileSystems.matchNewResource(deadLetterGcsPath.get(), true);
LOG.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,7 @@ private void writeMutations(Iterable<Mutation> mutationIterable)
try {
sleeper.sleep(sleepTimeMsecs);
} catch (InterruptedException e) {
// ignore.
Thread.currentThread().interrupt();
}
} else {
// Some other failure: pass up the stack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ public KV<K, V> getCurrent() {
valueCoder,
skipValueClone);
} catch (IOException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
LOG.error("Unable to read data: ", e);
throw new IllegalStateException("Unable to read data: " + "{}", e);
}
Expand Down Expand Up @@ -1569,6 +1572,9 @@ private RecordWriter<KeyT, ValueT> initRecordWriter(
taskAttemptContext.getJobID().getJtIdentifier());
return outputFormatObj.getRecordWriter(taskAttemptContext);
} catch (InterruptedException | IOException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
throw new IllegalStateException("Unable to create RecordWriter object: ", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ private void consumerPollLoop() {
commitCheckpointMark();
} catch (InterruptedException e) {
LOG.warn("{}: consumer thread is interrupted", this, e); // not expected
Thread.currentThread().interrupt();
break;
Comment on lines 611 to 614

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This block only catches interrupts that did not originate from a Kafka client (preexisting bug).
Kafka clients do not throw InterruptedException, but they may throw their own wrapper exception InterruptException instead.

No action required on this PR.
Just making sure I won't forget to address it later.

} catch (WakeupException e) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void teardown() throws UserCodeExecutionException {
try {
boolean ignored = executor.awaitTermination(3L, TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
// Ignore the interrupt during teardown.
Thread.currentThread().interrupt();
}
}
}
Expand Down Expand Up @@ -354,7 +354,7 @@ private void backoffIfNeeded(BackOff backOff, Sleeper sleeper) {
incIfPresent(sleeperCounter);
sleeper.sleep(backOff.nextBackOffMillis());
} catch (InterruptedException ignored) {
// Ignore the interrupt and try again.
Thread.currentThread().interrupt();
}
}
}
Expand Down Expand Up @@ -535,6 +535,9 @@ public ResponseT call(RequestT request) throws UserCodeExecutionException {
try {
return future.get(timeout.getMillis(), TimeUnit.MILLISECONDS);
} catch (TimeoutException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
future.cancel(true);
throw new UserCodeTimeoutException(e);
} catch (ExecutionException e) {
Expand Down Expand Up @@ -585,6 +588,9 @@ private void executeAsync(Callable<Void> callable) throws UserCodeExecutionExcep
try {
future.get(timeout.getMillis(), TimeUnit.MILLISECONDS);
} catch (TimeoutException | InterruptedException e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
future.cancel(true);
throw new UserCodeTimeoutException(e);
} catch (ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ OutputT apply(InputT input) throws UserCodeExecutionException {
}
latestError = Optional.of(e);
} catch (InterruptedException ignored) {
// Ignore the interrupt and try again.
Thread.currentThread().interrupt();
}
incIfPresent(getBackoffCounter());
waitFor = getBackOff().nextBackOffMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public ProcessContinuation processElement(
TimeUnit.SECONDS.sleep(startPollTimeoutSec);
} catch (InterruptedException e) {
LOG.error("SparkReceiver was interrupted before polling started", e);
Thread.currentThread().interrupt();
throw new IllegalStateException("Spark Receiver was interrupted before polling started");
}
if (!sparkConsumer.hasRecords()) {
Expand All @@ -306,6 +307,7 @@ public ProcessContinuation processElement(
TimeUnit.SECONDS.sleep(pullFrequencySec);
} catch (InterruptedException e) {
LOG.error("SparkReceiver was interrupted while waiting to poll new records", e);
Thread.currentThread().interrupt();
throw new IllegalStateException(
"Spark Receiver was interrupted while waiting to poll new records");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ private void invokeBuilderForPublishOnlyPipeline(PipelineBuilder<NexmarkOptions>
try {
Thread.sleep(PERF_DELAY.getMillis());
} catch (InterruptedException e) {
Thread.interrupted();
Thread.currentThread().interrupt();
NexmarkUtils.console("Interrupted: pipeline is still running");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ private void runDockerComposeCommand(List<String> command, @Nullable File output
try {
this.wait(STATUS_LOGGER_WAIT_TIME);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
Expand All @@ -301,7 +302,7 @@ public synchronized void waitTillUp(int timeout) throws IOException, TimeoutExce
// We are just waiting for a local process. No need for exponential backoff.
this.wait(1000);
} catch (InterruptedException e) {
// Ignore and retry.
Thread.currentThread().interrupt();
}

String output = String.join(" ", java.nio.file.Files.readAllLines(Paths.get(statusFileName)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void waitForAllServicesToBeReady() throws TimeoutException {
try {
Thread.sleep(duration);
} catch (InterruptedException e) {
// Ignore
Thread.currentThread().interrupt();
}
duration = (long) (duration * 1.2);
}
Expand Down
Loading