GUACAMOLE-919: pass through defaultStatementTimeout

Testing a workaround for handling dropped TCP connections to the Postgres database.
This commit is contained in:
Douglas Heriot
2020-03-23 21:23:56 +11:00
parent 699e262501
commit 34130f54c9
4 changed files with 42 additions and 0 deletions

View File

@@ -69,6 +69,7 @@ public class PostgreSQLAuthenticationProviderModule implements Module {
myBatisProperties.setProperty("JDBC.autoCommit", "false");
myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true");
myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1");
myBatisProperties.setProperty("mybatis.configuration.defaultStatementTimeout", environment.getPostgreSQLDefaultStatementTimeout());
// Use UTF-8 in database
driverProperties.setProperty("characterEncoding", "UTF-8");

View File

@@ -48,6 +48,14 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
*/
private static final int DEFAULT_PORT = 5432;
/**
* The default defaultStatementTimeout (in seconds),
* if POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT is not specified.
* Default to null (no timeout)
* https://mybatis.org/mybatis-3/configuration.html
*/
private static final String DEFAULT_DEFAULT_STATEMENT_TIMEOUT = "null";
/**
* Whether a database user account is required by default for authentication
* to succeed.
@@ -249,6 +257,23 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
public String getPostgreSQLPassword() throws GuacamoleException {
return getRequiredProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_PASSWORD);
}
/**
* Returns the defaultStatementTimeout set for PostgreSQL connections.
* If unspecified, this will be the default "null" (no timeout)
*
* @return
* The statement timeout (in seconds)
*
* @throws GuacamoleException
* If an error occurs while retrieving the property value.
*/
public String getPostgreSQLDefaultStatementTimeout() throws GuacamoleException {
return getProperty(
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT,
DEFAULT_DEFAULT_STATEMENT_TIMEOUT
);
}
@Override
public boolean isRecursiveQuerySupported(SqlSession session) {

View File

@@ -94,6 +94,18 @@ public class PostgreSQLGuacamoleProperties {
};
/**
* Sets the number of seconds the driver will wait for
* a response from the database.
*/
public static final StringGuacamoleProperty
POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT = new StringGuacamoleProperty(){
@Override
public String getName() { return "postgresql-default-statement-timeout"; }
};
/**
* Whether a user account within the database is required for authentication
* to succeed, even if the user has been authenticated via another