diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.ts index c808f66120..d747d8f7a9 100644 --- a/apps/desktop/src/stores/queryStore.ts +++ b/apps/desktop/src/stores/queryStore.ts @@ -1988,7 +1988,9 @@ export const useQueryStore = defineStore("query", () => { executionPromise = api.executeInManualTransaction(tab.txnSessionId, sqlToExecute, tab.database, executionSchema, pageLimit); } else { console.info("[DBX][executeTabSql:execute-multi:start]", { traceId, elapsed: elapsed() }); - const clientSessionId = tab.mode === "query" || tab.mode === "data" ? tabClientSessionId(tab) : undefined; + // Data tabs should reuse the already-open pool; session pools are reserved + // for query tabs/background tasks that need connection-local state isolation. + const clientSessionId = tab.mode === "query" ? tabClientSessionId(tab) : undefined; const executionOptions = { ...(typeof pageLimit === "number" ? useAgentResultSession diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.ts index 8df5a5b10e..266298f5d1 100644 --- a/packages/app-tests/queryStore.test.ts +++ b/packages/app-tests/queryStore.test.ts @@ -2628,7 +2628,7 @@ test("query execution is scoped to the tab client session", async () => { } }); -test("data tab execution is scoped to the tab client session", async () => { +test("data tab execution reuses the shared connection pool", async () => { const restoreStorage = installMemoryStorage(); setActivePinia(createPinia()); const connectionStore = useConnectionStore(); @@ -2654,7 +2654,7 @@ test("data tab execution is scoped to the tab client session", async () => { try { await store.executeTabSql(tabId, "select * from users"); - assert.equal(executeBody.clientSessionId, tabId); + assert.equal(executeBody.clientSessionId, undefined); assert.equal(executeBody.timeoutSecs, 30); } finally { globalThis.fetch = originalFetch; diff --git a/packages/app-tests/useDataGridActions.test.ts b/packages/app-tests/useDataGridActions.test.ts index f455631955..56f91143f9 100644 --- a/packages/app-tests/useDataGridActions.test.ts +++ b/packages/app-tests/useDataGridActions.test.ts @@ -98,7 +98,7 @@ test("data reload executes before slow metadata refresh completes", async () => const reload = actions.onReloadData(undefined, undefined, undefined, undefined, 50, 0); await waitFor(() => !!executeBody); - assert.equal(executeBody.clientSessionId, tabId); + assert.equal(executeBody.clientSessionId, undefined); assert.deepEqual(tab.result?.rows, [[1]]); await waitFor(() => typeof resolveColumns === "function");