Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(admin): pause session polling after connection or refresh failures

lcq928e5177e117271
diff --git a/.github/pr-assets/issue-13496-after.png b/.github/pr-assets/issue-13496-after.png
new file mode 100644
index 0000000000..5f438895a0
Binary files /dev/null and b/.github/pr-assets/issue-13496-after.png differ
diff --git a/.github/pr-assets/issue-13496-before.png b/.github/pr-assets/issue-13496-before.png
new file mode 100644
index 0000000000..45b40c951b
Binary files /dev/null and b/.github/pr-assets/issue-13496-before.png differ
diff --git a/apps/desktop/src/components/admin/ProcessListPanel.vue b/apps/desktop/src/components/admin/ProcessListPanel.vue
index fddbd9cfa1..d057febd5d 100644
--- a/apps/desktop/src/components/admin/ProcessListPanel.vue
+++ b/apps/desktop/src/components/admin/ProcessListPanel.vue
@@ -412,6 +412,8 @@ async function load(options: { silent?: boolean } = {}) {
truncated.value = result.truncated === true;
} catch (error: any) {
if (isCurrent()) {
+ autoRefresh.value = false;
+ stopTimer();
if (activeDriver.mode === "transaction") {
// A failed refresh must not leave stale kill targets on screen. A
// connection failure is not evidence that there are no transactions.
diff --git a/apps/desktop/src/components/admin/__tests__/ProcessListPanel.spec.ts b/apps/desktop/src/components/admin/__tests__/ProcessListPanel.spec.ts
index 788b9945cf..3ffbddd63c 100644
--- a/apps/desktop/src/components/admin/__tests__/ProcessListPanel.spec.ts
+++ b/apps/desktop/src/components/admin/__tests__/ProcessListPanel.spec.ts
@@ -383,6 +383,7 @@ afterEach(() => {
root?.remove();
root = null;
document.body.innerHTML = "";
+ vi.useRealTimers();
});
function gridButtons(): HTMLButtonElement[] {
@@ -457,6 +458,97 @@ async function mountXuguPanel() {
await nextTick();
}
+describe("ProcessListPanel automatic refresh failures", () => {
+ function autoRefreshCheckbox(): HTMLInputElement {
+ const label = [...root!.querySelectorAll("label")].find((element) => element.textContent?.includes("processList.autoRefresh"));
+ return label!.querySelector<HTMLInputElement>('input[type="checkbox"]')!;
+ }
+
+ async function enableAutoRefresh() {
+ const interval = root!.querySelector<HTMLInputElement>('input[type="number"]')!;
+ interval.value = "1";
+ interval.dispatchEvent(new Event("input", { bubbles: true }));
+ interval.dispatchEvent(new Event("change", { bubbles: true }));
+ const checkbox = autoRefreshCheckbox();
+ checkbox.checked = true;
+ checkbox.dispatchEvent(new Event("change", { bubbles: true }));
+ await nextTick();
+ }
+
+ it.each([
+ ["MySQL", mysqlConnection],
+ ["Oracle", oracleConnection],
+ ] as const)("pauses %s polling after a connection failure and keeps manual retry available", async (_label, connection) => {
+ if (connection.db_type === "oracle") await mountOraclePanel();
+ else await mountPanel(connection);
+ vi.useFakeTimers();
+ await enableAutoRefresh();
+ mocks.ensureConnected.mockRejectedValueOnce(new Error("connection unavailable"));
+
+ await vi.advanceTimersByTimeAsync(1000);
+
+ expect(autoRefreshCheckbox().checked).toBe(false);
+ expect(root?.textContent).toContain("connection unavailable");
+ expect(mocks.ensureConnected).toHaveBeenCalledTimes(2);
+ await vi.advanceTimersByTimeAsync(10_000);
+ expect(mocks.ensureConnected).toHaveBeenCalledTimes(2);
+
+ findGridButton("grid.refresh")?.click();
+ await vi.advanceTimersByTimeAsync(0);
+ expect(mocks.ensureConnected).toHaveBeenCalledTimes(3);
+ expect(root?.textContent).not.toContain("connection unavailable");
+ expect(autoRefreshCheckbox().checked).toBe(false);
+
+ await enableAutoRefresh();
+ await vi.advanceTimersByTimeAsync(2000);
+ expect(autoRefreshCheckbox().checked).toBe(true);
+ expect(mocks.ensureConnected).toHaveBeenCalledTimes(5);
+ });
+
+ it("pauses polling when the session-list query fails after connecting", async () => {
+ await mountOraclePanel();
+ vi.useFakeTimers();
+ await enableAutoRefresh();
+ mocks.oracleListFailure = "ORA-03113: end-of-file on communication channel";
+
+ await vi.advanceTimersByTimeAsync(1000);
+
+ expect(autoRefreshCheckbox().checked).toBe(false);
+ expect(root?.textContent).toContain(mocks.oracleListFailure);
+ const queryCount = mocks.executeQuery.mock.calls.length;
+ await vi.advanceTimersByTimeAsync(10_000);
+ expect(mocks.ensureConnected).toHaveBeenCalledTimes(2);
+ expect(mocks.executeQuery).toHaveBeenCalledTimes(queryCount);
+ });
+
+ it("keeps polling the new connection after an old connection fails late", async () => {
+ const connection = await mountReactivePanel(oracleConnection);
+ vi.useFakeTimers();
+ await enableAutoRefresh();
+ let rejectOld!: (error: Error) => void;
+ mocks.ensureConnected.mockImplementationOnce(
+ () =>
+ new Promise<void>((_resolve, reject) => {
+ rejectOld = reject;
+ }),
+ );
+ await vi.advanceTimersByTimeAsync(1000);
+ connection.id = "oracle-next";
+ await nextTick();
+
+ rejectOld(new Error("old connection unavailable"));
+ await vi.advanceTimersByTimeAsync(0);
+
+ expect(autoRefreshCheckbox().checked).toBe(true);
+ expect(root?.textContent).not.toContain("old connection unavailable");
+ expect(mocks.ensureConnected).toHaveBeenLastCalledWith("oracle-next", { skipIfClosedByUser: true });
+ const attemptCount = mocks.ensureConnected.mock.calls.length;
+ await vi.advanceTimersByTimeAsync(1000);
+ expect(mocks.ensureConnected).toHaveBeenCalledTimes(attemptCount + 1);
+ expect(autoRefreshCheckbox().checked).toBe(true);
+ });
+});
+
describe("ProcessListPanel batch terminate", () => {
it.each([
["Oracle", oracleConnection, buildOracleSessionListSql(false)],