-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Describe the bug
According to the documentation, importing an empty object (size of 0 bytes) using aws_s3.table_import_from_s3 will cause an error. However, the wrapper will initiate a writer failover procedure and throw a FailoverSuccessSQLException instead of throwing an exception for the failed aws_s3.table_import_from_s3 function.
Expected Behavior
Executing the aws_s3.table_import_from_s3 function with an empty object should throw a java.sql.SQLException.
What plugins are used? What other connection properties were set?
iam,auroraConnectionTracker,failover2,efm2
Current Behavior
Executing the aws_s3.table_import_from_s3 function with an empty object initiates a writer failover procedure and throws a FailoverSuccessSQLException.
See the trace log file here.
Relevant log lines:
DEBUG 2025-06-26 17:40:18.396 UTC [main] software.amazon.jdbc.plugin.failover2.FailoverConnectionPlugin - Detected an exception while executing a command: ERROR: Unable to validate pre-signed URL. Error: HTTP 416. Check your arguments and try again.
Where: SQL function "table_import_from_s3" statement 1
Location: File: aws_s3.c, Routine: generate_url_and_validate, Line: 408
Server SQLState: XX000
TRACE 2025-06-26 17:40:18.397 UTC [main] org.postgresql.core.QueryExecutorBase - FE=> Terminate
INFO 2025-06-26 17:40:18.399 UTC [main] software.amazon.jdbc.plugin.failover2.FailoverConnectionPlugin - Starting writer failover procedure.
TRACE 2025-06-26 17:40:18.399 UTC [main] org.postgresql.core.QueryExecutorBase - FE=> Terminate
TRACE 2025-06-26 17:40:18.401 UTC [AWS JDBC Driver monitor-1] software.amazon.jdbc.hostlistprovider.monitoring.ClusterTopologyMonitorImpl - Starting node monitoring threads.
Reproduction Steps
- Upload an empty object to an S3 bucket.
- Run the following SQL:
SELECT aws_s3.table_import_from_s3( 'some_table', '', '(format csv)', aws_commons.create_s3_uri('some_bucket', 'some_empty_object_key', 'us-east-1'))
Possible Solution
No response
Additional Information/Context
Database: Aurora Postgres 17.4 with CREATE EXTENSION aws_s3 CASCADE and "s3Import" DB IAM role feature.
Method used to create HikariDataSource instance:
private HikariDataSource createDataSource(boolean writer) {
final HikariConfig config = new HikariConfig();
config.setDataSourceClassName(AwsWrapperDataSource.class.getName());
config.addDataSourceProperty("jdbcProtocol", "jdbc:postgresql:");
config.addDataSourceProperty("targetDataSourceClassName", PGSimpleDataSource.class.getName());
config.addDataSourceProperty("serverName", writer ? ENDPOINT_WRITER : ENDPOINT_READER);
config.addDataSourceProperty("serverPort", "5432");
config.addDataSourceProperty("database", "postgres");
config.addDataSourceProperty("user", USERNAME);
final Properties targetProperties = new Properties();
config.addDataSourceProperty("targetDataSourceProperties", targetProperties);
targetProperties.setProperty("sslmode", "require");
targetProperties.setProperty("tcpKeepAlive", "true");
targetProperties.setProperty("connectTimeout", "10");
targetProperties.setProperty("socketTimeout", "10");
targetProperties.setProperty("loginTimeout", "30");
targetProperties.setProperty("wrapperPlugins", "iam,auroraConnectionTracker,failover2,efm2");
config.setExceptionOverrideClassName(HikariCPSQLException.class.getName());
config.setMinimumIdle(1);
config.setMaximumPoolSize(getRuntime().availableProcessors() * 8);
config.setConnectionTimeout(ofSeconds(30).toMillis());
config.setIdleTimeout(ofMinutes(1).toMillis());
config.setMaxLifetime(ofMinutes(10).toMillis());
config.setValidationTimeout(ofSeconds(10).toMillis());
config.setReadOnly(!writer);
return new HikariDataSource(config);
}Relevant dependencies:
implementation("org.postgresql", "postgresql", "42.7.6")
implementation("software.amazon.jdbc", "aws-advanced-jdbc-wrapper", "2.6.0")
implementation("com.zaxxer", "HikariCP", "6.3.0")The AWS Advanced JDBC Driver version used
2.6.0
JDK version used
OpenJDK Runtime Environment Corretto-24.0.1.9.1 (build 24.0.1+9-FR)
Operating System and version
Ubuntu 24.04.2 LTS