Skip to content

Commit

Permalink
CXP-3032: Race condition during local.buffer.dir creation
Browse files Browse the repository at this point in the history
When multiple tasks are starte on the same worker all of them are
trying to check if the directory exists and create if not. Sometimes
some of the tasks fail because the directory gets created after
the existence check and before the creation attempt by other tasks.

The fix is to do a few attempts of checking and creating the directory.
  • Loading branch information
ramanenka committed Feb 14, 2024
1 parent 5e6180d commit cee8ece
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ allprojects {
apply plugin: 'maven-publish'

group = 'com.spredfast.kafka.connect.s3'
version = '1.2.0'
version = '1.2.1'

apply plugin: 'java-library'
sourceCompatibility = 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ private PartitionWriter(TopicPartition tp, SinkRecord firstRecord) throws IOExce
.orElseThrow(() -> new ConnectException("No local buffer directory configured"));

File directory = new File(localBufferDirectory);
if (!directory.exists() && !directory.mkdirs()) {
int attempts = 3;
while (attempts > 0 && !directory.exists() && !directory.mkdirs()) {
attempts--;
}
if (!directory.exists()) {
throw new ConnectException("Could not create directory " + localBufferDirectory);
}

Expand Down

0 comments on commit cee8ece

Please sign in to comment.