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 HiveMinioDataLake leak when start fails #14763

Merged
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 @@ -81,7 +81,7 @@ public HiveMinioDataLake(String bucketName, Map<String, String> hiveHadoopFilesT
this.hiveHadoop = closer.register(hiveHadoopBuilder.build());
}

public HiveMinioDataLake start()
public void start()
{
checkState(state == State.INITIAL, "Already started: %s", state);
state = State.STARTING;
Expand All @@ -90,8 +90,6 @@ public HiveMinioDataLake start()
minioClient = closer.register(minio.createMinioClient());
minio.createBucket(bucketName);
state = State.STARTED;

return this;
}

public void stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ public void testS3WrongRegionSelection()
// Bucket names are global so a unique one needs to be used.
String bucketName = "test-bucket" + randomTableSuffix();

try (HiveMinioDataLake dataLake = new HiveMinioDataLake(bucketName).start();
QueryRunner queryRunner = S3HiveQueryRunner.builder(dataLake)
.setHiveProperties(ImmutableMap.of("hive.s3.region", "eu-central-1")) // Different than the default one
.build()) {
String tableName = "s3_region_test_" + randomTableSuffix();
queryRunner.execute("CREATE TABLE default." + tableName + " (a int) WITH (external_location = 's3://" + bucketName + "/" + tableName + "')");
assertThatThrownBy(() -> queryRunner.execute("SELECT * FROM default." + tableName))
.getRootCause()
.hasMessageContaining("Status Code: 400")
.hasMessageContaining("Error Code: AuthorizationHeaderMalformed"); // That is how Minio reacts to bad region
try (HiveMinioDataLake dataLake = new HiveMinioDataLake(bucketName)) {
dataLake.start();
try (QueryRunner queryRunner = S3HiveQueryRunner.builder(dataLake)
.setHiveProperties(ImmutableMap.of("hive.s3.region", "eu-central-1")) // Different than the default one
.build()) {
String tableName = "s3_region_test_" + randomTableSuffix();
queryRunner.execute("CREATE TABLE default." + tableName + " (a int) WITH (external_location = 's3://" + bucketName + "/" + tableName + "')");
assertThatThrownBy(() -> queryRunner.execute("SELECT * FROM default." + tableName))
.getRootCause()
.hasMessageContaining("Status Code: 400")
.hasMessageContaining("Error Code: AuthorizationHeaderMalformed"); // That is how Minio reacts to bad region
}
}
}
}