Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: clear cache after issue done (#14203)

ecmadao0a3ed4c27244
diff --git a/frontend/src/components/IssueV1/logic/poll.ts b/frontend/src/components/IssueV1/logic/poll.ts
index b08073cc71..fd71930b7c 100644
--- a/frontend/src/components/IssueV1/logic/poll.ts
+++ b/frontend/src/components/IssueV1/logic/poll.ts
@@ -1,9 +1,16 @@
import { watch } from "vue";
import { databaseForTask } from "@/components/IssueV1/logic";
import { useProgressivePoll } from "@/composables/useProgressivePoll";
-import { experimentalFetchIssueByUID, useChangeHistoryStore } from "@/store";
+import {
+ experimentalFetchIssueByUID,
+ useChangeHistoryStore,
+ useInstanceV1Store,
+ useDBSchemaV1Store,
+} from "@/store";
+import { useListCache } from "@/store/modules/v1/cache";
import type { ComposedIssue } from "@/types";
import { IssueStatus } from "@/types/proto/v1/issue_service";
+import { Task_Type } from "@/types/proto/v1/rollout_service";
import {
extractIssueUID,
extractProjectResourceName,
@@ -12,12 +19,33 @@ import {
import { flattenTaskV1List } from "@/utils";
import { useIssueContext } from "./context";
-const clearChangeHistory = (issue: ComposedIssue) => {
+const clearCache = (issue: ComposedIssue) => {
const changeHistoryStore = useChangeHistoryStore();
const tasks = flattenTaskV1List(issue.rolloutEntity);
+
for (const task of tasks) {
const database = databaseForTask(issue, task);
- changeHistoryStore.clearCache(database.name);
+ switch (task.type) {
+ case Task_Type.DATABASE_CREATE:
+ useInstanceV1Store()
+ .syncInstance(database.instance, false /* not enable full sync */)
+ .then(() => {
+ const cache = useListCache("database");
+ cache.deleteCache(database.instance);
+ cache.deleteCache(database.project);
+ });
+ break;
+ case Task_Type.DATABASE_DATA_EXPORT:
+ case Task_Type.UNRECOGNIZED:
+ case Task_Type.TYPE_UNSPECIFIED:
+ continue;
+ case Task_Type.DATABASE_DATA_UPDATE:
+ changeHistoryStore.clearCache(database.name);
+ break;
+ default:
+ useDBSchemaV1Store().removeCache(database.name);
+ changeHistoryStore.clearCache(database.name);
+ }
}
};
@@ -34,7 +62,7 @@ export const usePollIssue = () => {
issue.value.status !== IssueStatus.DONE &&
updatedIssue.status === IssueStatus.DONE
) {
- clearChangeHistory(updatedIssue);
+ clearCache(updatedIssue);
}
issue.value = updatedIssue;
diff --git a/frontend/src/store/modules/v1/cache.ts b/frontend/src/store/modules/v1/cache.ts
index 634774593a..19d1e2645f 100644
--- a/frontend/src/store/modules/v1/cache.ts
+++ b/frontend/src/store/modules/v1/cache.ts
@@ -50,6 +50,10 @@ export const useListCache = (namespace: string) => {
return undefined;
};
+ const deleteCache = (attr: string) => {
+ listCache.delete(getCacheKey(attr));
+ };
+
const clearCache = () => {
LIST_CACHE.delete(namespace);
};
@@ -59,6 +63,7 @@ export const useListCache = (namespace: string) => {
getCacheKey,
getCache,
clearCache,
+ deleteCache,
};
};
diff --git a/frontend/src/store/modules/v1/instance.ts b/frontend/src/store/modules/v1/instance.ts
index 591c4923e4..ea96d3881f 100644
--- a/frontend/src/store/modules/v1/instance.ts
+++ b/frontend/src/store/modules/v1/instance.ts
@@ -79,9 +79,9 @@ export const useInstanceV1Store = defineStore("instance_v1", () => {
const composed = await upsertInstances([instance]);
return composed[0];
};
- const syncInstance = async (instance: Instance, enableFullSync: boolean) => {
+ const syncInstance = async (instance: string, enableFullSync: boolean) => {
await instanceServiceClient.syncInstance({
- name: instance.name,
+ name: instance,
enableFullSync,
});
};
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 9945bcd92d..f1c33c2ca6 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -164,16 +164,18 @@ const allowCreateDatabase = computed(() => {
});
const syncSchema = async (enableFullSync: boolean) => {
- await instanceV1Store.syncInstance(instance.value, enableFullSync);
+ await instanceV1Store.syncInstance(instance.value.name, enableFullSync);
// Remove the database list cache for the instance.
- listCache.cacheMap.delete(listCache.getCacheKey(instance.value.name));
+ listCache.deleteCache(instance.value.name);
await wrapRefAsPromise(ready, true);
- // Clear the db schema metadata cache entities.
- // So we will re-fetch new values when needed.
- const dbSchemaStore = useDBSchemaV1Store();
- databaseList.value.forEach((database) =>
- dbSchemaStore.removeCache(database.name)
- );
+ if (enableFullSync) {
+ // Clear the db schema metadata cache entities.
+ // So we will re-fetch new values when needed.
+ const dbSchemaStore = useDBSchemaV1Store();
+ databaseList.value.forEach((database) =>
+ dbSchemaStore.removeCache(database.name)
+ );
+ }
pushNotification({
module: "bytebase",
style: "SUCCESS",
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 3fea622c95..942d8a4707 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -24,13 +24,12 @@
{{ $t("common.cancel") }}
</NButton>
<NButton
+ type="primary"
:disabled="!allowSaveEdit"
@click.prevent="saveEdit"
>
<template #icon>
- <heroicons-solid:save
- class="h-5 w-5 text-control-light"
- />
+ <heroicons-solid:save class="h-5 w-5" />
</template>
{{ $t("common.save") }}
</NButton>