Skip to content

Commit 9cbcfcc

Browse files
fix(tables): scale idle timeout in updateColumnType to avoid aborting large type changes
1 parent d05348d commit 9cbcfcc

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
@@ -2970,9 +2970,16 @@ export async function updateColumnType(
29702970
requestId: string
29712971
): Promise<TableDefinition> {
29722972
return withLockedTable(data.tableId, async (table, trx) => {
2973-
await setTableTxTimeouts(trx, {
2974-
statementMs: scaledStatementTimeoutMs(table.rowCount ?? 0, { baseMs: 60_000, perRowMs: 2 }),
2973+
// Scale both statement and idle timeouts to row count: the compatibility
2974+
// check below iterates every row in Node between the row SELECT and the
2975+
// schema UPDATE, leaving the transaction idle for that gap. The default 5s
2976+
// `idle_in_transaction_session_timeout` would abort a valid type change on
2977+
// a large table.
2978+
const timeoutMs = scaledStatementTimeoutMs(table.rowCount ?? 0, {
2979+
baseMs: 60_000,
2980+
perRowMs: 2,
29752981
})
2982+
await setTableTxTimeouts(trx, { statementMs: timeoutMs, idleMs: timeoutMs })
29762983

29772984
if (!(COLUMN_TYPES as readonly string[]).includes(data.newType)) {
29782985
throw new Error(

0 commit comments

Comments
 (0)