diff --git a/proxy/src/bin/proxy.rs b/proxy/src/bin/proxy.rs index 570cf0943a..d90ac86a82 100644 --- a/proxy/src/bin/proxy.rs +++ b/proxy/src/bin/proxy.rs @@ -90,6 +90,9 @@ struct ProxyCliArgs { /// timeout for http connections #[clap(long, default_value = "15s", value_parser = humantime::parse_duration)] sql_over_http_timeout: tokio::time::Duration, + /// Whether the SQL over http pool is opt-in + #[clap(long, default_value_t = true, value_parser = clap::builder::BoolishValueParser::new(), action = clap::ArgAction::Set)] + sql_over_http_pool_opt_in: bool, /// timeout for scram authentication protocol #[clap(long, default_value = "15s", value_parser = humantime::parse_duration)] scram_protocol_timeout: tokio::time::Duration, @@ -275,7 +278,8 @@ fn build_config(args: &ProxyCliArgs) -> anyhow::Result<&'static ProxyConfig> { } }; let http_config = HttpConfig { - sql_over_http_timeout: args.sql_over_http_timeout, + timeout: args.sql_over_http_timeout, + pool_opt_in: args.sql_over_http_pool_opt_in, }; let authentication_config = AuthenticationConfig { scram_protocol_timeout: args.scram_protocol_timeout, diff --git a/proxy/src/config.rs b/proxy/src/config.rs index 0c094ff4aa..89b432df92 100644 --- a/proxy/src/config.rs +++ b/proxy/src/config.rs @@ -34,7 +34,8 @@ pub struct TlsConfig { } pub struct HttpConfig { - pub sql_over_http_timeout: tokio::time::Duration, + pub timeout: tokio::time::Duration, + pub pool_opt_in: bool, } pub struct AuthenticationConfig { diff --git a/proxy/src/serverless/sql_over_http.rs b/proxy/src/serverless/sql_over_http.rs index b449a6e471..2df2be1d3d 100644 --- a/proxy/src/serverless/sql_over_http.rs +++ b/proxy/src/serverless/sql_over_http.rs @@ -204,8 +204,8 @@ pub async fn handle( config: &'static HttpConfig, ) -> Result, ApiError> { let result = tokio::time::timeout( - config.sql_over_http_timeout, - handle_inner(request, sni_hostname, conn_pool, session_id), + config.timeout, + handle_inner(config, request, sni_hostname, conn_pool, session_id), ) .await; let mut response = match result { @@ -269,7 +269,7 @@ pub async fn handle( Err(_) => { let message = format!( "HTTP-Connection timed out, execution time exeeded {} seconds", - config.sql_over_http_timeout.as_secs() + config.timeout.as_secs() ); error!(message); json_response( @@ -287,6 +287,7 @@ pub async fn handle( #[instrument(name = "sql-over-http", fields(pid = tracing::field::Empty), skip_all)] async fn handle_inner( + config: &'static HttpConfig, request: Request, sni_hostname: Option, conn_pool: Arc, @@ -311,7 +312,8 @@ async fn handle_inner( let array_mode = headers.get(&ARRAY_MODE) == Some(&HEADER_VALUE_TRUE); // Allow connection pooling only if explicitly requested - let allow_pool = headers.get(&ALLOW_POOL) == Some(&HEADER_VALUE_TRUE); + // or if we have decided that http pool is no longer opt-in + let allow_pool = !config.pool_opt_in || headers.get(&ALLOW_POOL) == Some(&HEADER_VALUE_TRUE); // isolation level, read only and deferrable diff --git a/test_runner/fixtures/neon_fixtures.py b/test_runner/fixtures/neon_fixtures.py index 214bcc3a53..23a36ad6c9 100644 --- a/test_runner/fixtures/neon_fixtures.py +++ b/test_runner/fixtures/neon_fixtures.py @@ -2114,6 +2114,7 @@ class NeonProxy(PgProtocol): # Console auth backend params *["--auth-backend", "console"], *["--auth-endpoint", self.endpoint], + *["--sql-over-http-pool-opt-in", "false"], ] if self.fixed_rate_limit is not None: args += [