fix(dameng): defer table metadata refresh
This commit is contained in:
parent
a8fa8bed5b
commit
474b2bc6ce
|
|
@ -1057,6 +1057,7 @@ async function openData() {
|
|||
console.warn("[DBX][openData:metadata:error]", { traceId, tabId, elapsed: elapsed(), error });
|
||||
}
|
||||
};
|
||||
const shouldRefreshTableMeta = !cachedTableMeta;
|
||||
if (cachedTableMeta) {
|
||||
console.info("[DBX][openData:metadata:cache-hit]", {
|
||||
traceId,
|
||||
|
|
@ -1067,8 +1068,7 @@ async function openData() {
|
|||
elapsed: elapsed(),
|
||||
});
|
||||
} else {
|
||||
void refreshTableMetaInBackground();
|
||||
logPhase("metadata-started", { tabId });
|
||||
logPhase("metadata-deferred", { tabId });
|
||||
}
|
||||
|
||||
// Check if superseded by a newer openData call
|
||||
|
|
@ -1105,6 +1105,10 @@ async function openData() {
|
|||
await queryStore.executeTabSql(tabId, sql, { sourceTraceId: traceId, skipEnsureConnected: true });
|
||||
console.info("[DBX][openData:execute:done]", { traceId, tabId, elapsed: elapsed() });
|
||||
logPhase("execute-tab-sql", { tabId });
|
||||
if (shouldRefreshTableMeta && isCurrentDataTab()) {
|
||||
void refreshTableMetaInBackground();
|
||||
logPhase("metadata-started", { tabId });
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (!isActive()) {
|
||||
logPhase("superseded-after-error", { tabId });
|
||||
|
|
|
|||
|
|
@ -91,11 +91,9 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
|||
columns: [],
|
||||
primaryKeys: [],
|
||||
});
|
||||
const columnsPromise = api.getColumns(target.connectionId, target.database, querySchema, target.tableName);
|
||||
const dataPromise = queryStore.executeTabSql(tabId, sql);
|
||||
const [columnsResult, dataResult] = await Promise.allSettled([columnsPromise, dataPromise]);
|
||||
if (columnsResult.status === "fulfilled") {
|
||||
const columns = columnsResult.value;
|
||||
await queryStore.executeTabSql(tabId, sql);
|
||||
try {
|
||||
const columns = await api.getColumns(target.connectionId, target.database, querySchema, target.tableName);
|
||||
const indexes = await api.listIndexes(target.connectionId, target.database, querySchema, target.tableName).catch(() => []);
|
||||
const primaryKeys = editableRowIdentifierColumns(effectiveDbType, columns, indexes);
|
||||
const useRowId = usesSyntheticRowIdKey(effectiveDbType, primaryKeys);
|
||||
|
|
@ -120,9 +118,9 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
|||
queryStore.updateSql(tabId, newSql);
|
||||
await queryStore.executeTabSql(tabId, newSql);
|
||||
}
|
||||
} catch (reason) {
|
||||
console.error("[DBX] ERROR fetching table metadata:", reason);
|
||||
}
|
||||
if (dataResult.status === "rejected") throw dataResult.reason;
|
||||
if (columnsResult.status === "rejected") console.error("[DBX] ERROR fetching table metadata:", columnsResult.reason);
|
||||
} catch (e: any) {
|
||||
queryStore.setErrorResult(tabId, e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue