diff --git a/src/gausskernel/ddes/adapter/ss_transaction.cpp b/src/gausskernel/ddes/adapter/ss_transaction.cpp index a25033bb7..642ebbe0b 100644 --- a/src/gausskernel/ddes/adapter/ss_transaction.cpp +++ b/src/gausskernel/ddes/adapter/ss_transaction.cpp @@ -102,6 +102,10 @@ Snapshot SSGetSnapshotData(Snapshot snapshot) /* For cm agent, it only query the system status using the parameter in memory. So don't need MVCC */ if (u_sess->libpq_cxt.IsConnFromCmAgent) { snapshot = SnapshotNow; + if (!TransactionIdIsNormal(u_sess->utils_cxt.RecentGlobalXmin)) { + u_sess->utils_cxt.RecentGlobalXmin = FirstNormalTransactionId; + } + u_sess->utils_cxt.RecentGlobalDataXmin = u_sess->utils_cxt.RecentGlobalXmin; return snapshot; } diff --git a/src/gausskernel/storage/smgr/segment/data_file.cpp b/src/gausskernel/storage/smgr/segment/data_file.cpp index 523c83f3b..6ea800893 100644 --- a/src/gausskernel/storage/smgr/segment/data_file.cpp +++ b/src/gausskernel/storage/smgr/segment/data_file.cpp @@ -155,6 +155,11 @@ bool df_ss_update_segfile_size(SegLogicFile *sf, BlockNumber target_block) } uint32 flags = O_RDWR | PG_BINARY; + /* need palloc segfiles if file_num is 0 */ + if (sf->vector_capacity == 0) { + df_extend_file_vector(sf); + } + if (sf->file_num == 0) { char *filename = slice_filename(sf->filename, 0); int fd = dv_open_file(filename, flags, (int)SEGMENT_FILE_MODE); diff --git a/src/gausskernel/storage/smgr/segment/space.cpp b/src/gausskernel/storage/smgr/segment/space.cpp index 122ff7884..bb8fcc0c5 100644 --- a/src/gausskernel/storage/smgr/segment/space.cpp +++ b/src/gausskernel/storage/smgr/segment/space.cpp @@ -413,19 +413,22 @@ static void SSClose_seg_files(SegSpace *spc) void SSDrop_seg_space(Oid spcNode, Oid dbNode) { - SegSpace *spc = spc_init_space_node(spcNode, dbNode); - AutoMutexLock spc_lock(&spc->lock); + SegSpace *entry = NULL; + AutoMutexLock spc_lock(&segspace_lock); + SegSpcTag tag = {.spcNode = spcNode, .dbNode = dbNode}; + SegmentCheck(t_thrd.storage_cxt.SegSpcCache != NULL); spc_lock.lock(); - - SpaceDataFileStatus dataStatus = spc_status(spc); - if (dataStatus == SpaceDataFileStatus::EMPTY) { - spc_lock.unLock(); - return; - } - - SegDropSpaceMetaBuffers(spcNode, dbNode); - SSClose_seg_files(spc); + entry = (SegSpace *)hash_search(t_thrd.storage_cxt.SegSpcCache, (void *)&tag, HASH_FIND, NULL); spc_lock.unLock(); + + if (entry != NULL) { + if(entry->status == OPENED) { + SSClose_seg_files(entry); + SegDropSpaceMetaBuffers(spcNode, dbNode); + } + spc_lock.lock(); + (void)hash_search(t_thrd.storage_cxt.SegSpcCache, (void *)&tag, HASH_REMOVE, NULL); + } return; }