дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
fix(database): isolate JDBC console sessions (#6553)
Two SQL consoles on one JDBC data source waited on the same connection, so a long query, cancellation or close in one blocked the other. The JDBC bridge now multiplexes one connection per console inside the existing bridge JVM (capped at 32, with bounded reply buffers), and result reads, cancel and close are routed to the originating console's connection. DuckDB console connections share the database and its attachments with separate temporary tables and session settings; anonymous SQLite and H2 databases keep one shared connection so their contents stay visible. Fixes #6484 Co-authored-by: principalwater <[email protected]>
Цей коміт міститься в:
1 джерело
8fd5ee382d
коміт
4b3717618f
17 files changed
+1637
-354
No files matched your search
@@ -1281,11 +1281,11 @@ describe("result tab reuse (IDEA: new results replace the console's unpinned tab
|
||||
}
|
||||
});
|
||||
|
||||
it("routes ClickHouse runs and result operations through the originating SQL editor", async () => {
|
||||
it.each(["clickhouse", "jdbc"] as const)("keeps %s results in their editor session", async (driver) => {
|
||||
const first = "/project/console.sql";
|
||||
const second = "/project/console_1.sql";
|
||||
useDatabase.setState({
|
||||
sources: [{ id: "pg", name: "Local", driver: "clickhouse", readOnly: false }],
|
||||
sources: [{ id: "pg", name: "Local", driver, readOnly: false }],
|
||||
});
|
||||
backend.resultRow.mockResolvedValue({ status: "ok", data: result([{ name: "v" }], [["1"]]) });
|
||||
backend.explain.mockResolvedValue({ status: "ok", data: [] });
|
||||
@@ -1305,11 +1305,13 @@ describe("result tab reuse (IDEA: new results replace the console's unpinned tab
|
||||
await readResultRow(firstResult, 1);
|
||||
expect(backend.resultRow.mock.lastCall?.[5]).toBe(first);
|
||||
|
||||
await explainConsole(second, "SELECT 2", 0, 0);
|
||||
expect(backend.explain.mock.lastCall?.[4]).toBe(second);
|
||||
const plan = useDatabase.getState().results.find((tab) => !!tab.plan)!;
|
||||
await rerunResult(plan.id);
|
||||
expect(backend.explain.mock.lastCall?.[4]).toBe(second);
|
||||
if (driver === "clickhouse") {
|
||||
await explainConsole(second, "SELECT 2", 0, 0);
|
||||
expect(backend.explain.mock.lastCall?.[4]).toBe(second);
|
||||
const plan = useDatabase.getState().results.find((tab) => !!tab.plan)!;
|
||||
await rerunResult(plan.id);
|
||||
expect(backend.explain.mock.lastCall?.[4]).toBe(second);
|
||||
}
|
||||
|
||||
await runSql("pg", ["SELECT 3"]);
|
||||
expect(backend.execute.mock.lastCall?.[7]).toBeNull();
|
||||
|
||||
@@ -1669,7 +1669,7 @@ function withConsoleConnection<T>(
|
||||
const current = databaseRequest(id);
|
||||
return withConnection(id, async () => {
|
||||
const driver = sourceById(id)?.driver;
|
||||
if (!path || (driver !== "clickhouse" && driver !== "postgres")) return op(null, null);
|
||||
if (!path || (driver !== "clickhouse" && driver !== "postgres" && driver !== "jdbc")) return op(null, null);
|
||||
const key = consoleScopeKey(id, path);
|
||||
// A reopened editor waits for the previous session's release before using the same path.
|
||||
const closing = closingConsoles.get(key);
|
||||
|
||||
Reference in new issue
Заблокувати користувача