Skip to content
Merged
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
25 changes: 13 additions & 12 deletions cloud-sql/postgres/knex/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,27 @@ const connect = () => {
// Additional connections will be established to meet this value unless the pool is full.
knex.client.pool.min = 5;
// [END cloud_sql_postgres_knex_limit]

// [START cloud_sql_postgres_knex_timeout]
// 'acquireTimeoutMillis' is the maximum number of milliseconds to wait for a connection checkout.
// Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an
// SQLException.
// 'acquireTimeoutMillis' is the number of milliseconds before a timeout occurs when acquiring a
// connection from the pool. This is slightly different from connectionTimeout, because acquiring
// a pool connection does not always involve making a new connection, and may include multiple retries.
// when making a connection
knex.client.pool.acquireTimeoutMillis = 60000; // 60 seconds
// 'createTimeoutMillis` is the maximum number of milliseconds to wait trying to establish an
// initial connection before retrying.
// After acquireTimeoutMillis has passed, a timeout exception will be thrown.
knex.client.pool.createTimeoutMillis = 30000; // 30 seconds
// 'idleTimeoutMillis' is the maximum amount of time a connection can sit in the pool. Connections that
// sit idle for this many milliseconds are retried if idleTimeoutMillis is exceeded.
// 'idleTimeoutMillis' is the number of milliseconds a connection must sit idle in the pool
// and not be checked out before it is automatically closed.
knex.client.pool.idleTimeoutMillis = 600000; // 10 minutes
// [END cloud_sql_postgres_knex_timeout]

// [START cloud_sql_postgres_knex_backoff]
// 'knex' uses a built-in retry strategy which does not implement backoff.
// 'createRetryIntervalMillis' is how long to idle after failed connection creation before trying again
knex.client.pool.createRetryIntervalMillis = 200; // 0.2 seconds
// [END cloud_sql_postgres_knex_backoff]
// [START cloud_sql_postgres_knex_lifetime]
// 'acquireTimeoutMillis' is the maximum possible lifetime of a connection in the pool. Connections that
// live longer than this many milliseconds will be closed and reestablished between uses. This
// value should be several minutes shorter than the database's timeout value to avoid unexpected
// terminations.
knex.client.pool.acquireTimeoutMillis = 600000; // 10 minutes
// [START cloud_sql_postgres_knex_lifetime]

// [END_EXCLUDE]
return knex;
Expand Down