Skip to content

Commit ef4f5cf

Browse files
authored
[UI] Fix stale cache causing 'Table does not exist' error (#4075)
* [UI] Fix stale cache causing 'Table does not exist' error Signed-off-by: j1wonpark <jpark92@outlook.kr> * [UI] Fix race condition in getTableDetails when route changes during request Signed-off-by: Jiwon Park <22048252+j1wonpark@users.noreply.github.com> --------- Signed-off-by: j1wonpark <jpark92@outlook.kr> Signed-off-by: Jiwon Park <22048252+j1wonpark@users.noreply.github.com>
1 parent 4677f14 commit ef4f5cf

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

‎amoro-web/src/views/tables/components/Details.vue‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ limitations under the License.
1919
<script setup lang="ts">
2020
import { computed, onMounted, reactive, shallowReactive, watch } from 'vue'
2121
import { useI18n } from 'vue-i18n'
22-
import { useRoute } from 'vue-router'
22+
import { useRoute, useRouter } from 'vue-router'
2323
import type { ColumnProps } from 'ant-design-vue/es/table'
2424
import type { DetailColumnItem, IBaseDetailInfo, IColumns, IMap, PartitionColumnItem } from '@/types/common.type'
2525
import { getTableDetail } from '@/services/table.service'
2626
import { dateFormat } from '@/utils'
2727
2828
const emit = defineEmits<{
2929
(e: 'setBaseDetailInfo', data: IBaseDetailInfo): void
30+
(e: 'tableNotFound', info: { catalog: string; db: string; table: string }): void
3031
}>()
3132
const { t } = useI18n()
3233
const route = useRoute()
34+
const router = useRouter()
35+
36+
const STORAGE_TABLE_KEY = 'easylake-menu-catalog-db-table'
3337
3438
const params = computed(() => {
3539
return {
@@ -79,14 +83,15 @@ const state = reactive({
7983
})
8084
8185
async function getTableDetails() {
86+
const requestParams = { ...params.value }
87+
const { catalog, db, table } = requestParams
88+
if (!catalog || !db || !table) {
89+
return
90+
}
8291
try {
83-
const { catalog, db, table } = params.value
84-
if (!catalog || !db || !table) {
85-
return
86-
}
8792
state.detailLoading = true
8893
const result = await getTableDetail({
89-
...params.value,
94+
...requestParams,
9095
})
9196
const { pkList = [], tableType, partitionColumnList = [], properties, changeMetrics, schema, createTime, tableIdentifier, baseMetrics, tableSummary, comment } = result
9297
state.baseDetailInfo = {
@@ -124,6 +129,20 @@ async function getTableDetails() {
124129
setBaseDetailInfo()
125130
}
126131
catch (error) {
132+
const errorMessage = (error as Error)?.message || ''
133+
const isNotFoundError = /not exist|not found/i.test(errorMessage)
134+
135+
if (isNotFoundError) {
136+
localStorage.removeItem(STORAGE_TABLE_KEY)
137+
138+
emit('tableNotFound', {
139+
catalog: catalog as string,
140+
db: db as string,
141+
table: table as string,
142+
})
143+
144+
router.replace({ path: '/tables', query: {} })
145+
}
127146
}
128147
finally {
129148
state.detailLoading = false

‎amoro-web/src/views/tables/index.vue‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ export default defineComponent({
140140
state.baseInfo = { ...baseInfo }
141141
}
142142
143+
const handleTableNotFound = () => {
144+
state.baseInfo = {
145+
optimizingStatus: '',
146+
records: '',
147+
tableType: '',
148+
tableName: '',
149+
createTime: '',
150+
tableFormat: '',
151+
hasPartition: false,
152+
healthScore: -1,
153+
smallFileScore: 0,
154+
equalityDeleteScore: 0,
155+
positionalDeleteScore: 0,
156+
comment: '',
157+
} as IBaseDetailInfo
158+
state.detailLoaded = false
159+
}
160+
143161
const onChangeTab = (key: string | number) => {
144162
const query = { ...route.query }
145163
query.tab = key.toString()
@@ -210,6 +228,7 @@ export default defineComponent({
210228
isIceberg,
211229
hasSelectedTable,
212230
setBaseDetailInfo,
231+
handleTableNotFound,
213232
goBack,
214233
onChangeTab,
215234
sidebarWidth,
@@ -262,7 +281,7 @@ export default defineComponent({
262281
<div class="tables-main-body">
263282
<a-tabs v-model:activeKey="activeKey" destroy-inactive-tab-pane @change="onChangeTab">
264283
<a-tab-pane key="Details" :tab="$t('details')" force-render>
265-
<UDetails ref="detailRef" @set-base-detail-info="setBaseDetailInfo" />
284+
<UDetails ref="detailRef" @set-base-detail-info="setBaseDetailInfo" @table-not-found="handleTableNotFound" />
266285
</a-tab-pane>
267286
<a-tab-pane v-if="detailLoaded" key="Files" :tab="$t('files')">
268287
<UFiles :has-partition="baseInfo.hasPartition" />

0 commit comments

Comments
 (0)