Skip to content

Commit 704944b

Browse files
fix(tables): scale idle timeout in updateColumnConstraints for large tables
1 parent dd6b077 commit 704944b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

apps/sim/lib/table/service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,9 +3061,16 @@ export async function updateColumnConstraints(
30613061
requestId: string
30623062
): Promise<TableDefinition> {
30633063
return withLockedTable(data.tableId, async (table, trx) => {
3064-
await setTableTxTimeouts(trx, {
3065-
statementMs: scaledStatementTimeoutMs(table.rowCount ?? 0, { baseMs: 60_000, perRowMs: 2 }),
3064+
// Scale both statement and idle timeouts to row count: the required/unique
3065+
// validation runs between separate queries inside this transaction, leaving
3066+
// it briefly idle. Match `updateColumnType` so the default 5s
3067+
// `idle_in_transaction_session_timeout` can't abort a valid change on a
3068+
// large table.
3069+
const timeoutMs = scaledStatementTimeoutMs(table.rowCount ?? 0, {
3070+
baseMs: 60_000,
3071+
perRowMs: 2,
30663072
})
3073+
await setTableTxTimeouts(trx, { statementMs: timeoutMs, idleMs: timeoutMs })
30673074

30683075
const schema = table.schema
30693076
const columnIndex = schema.columns.findIndex(

0 commit comments

Comments
 (0)