diff --git a/src/common/backend/utils/cache/relcache.cpp b/src/common/backend/utils/cache/relcache.cpp index 3e091d3b8..822431120 100644 --- a/src/common/backend/utils/cache/relcache.cpp +++ b/src/common/backend/utils/cache/relcache.cpp @@ -8147,7 +8147,7 @@ void SetupPageCompressForRelation(RelFileNode* node, PageCompressOpts* compress_ compress_options->compressChunkSize, BLCKSZ / 16, BLCKSZ / 8, BLCKSZ / 4, BLCKSZ / 2, relationName))); } - uint1 preallocChunks; + uint1 preallocChunks = 0; if (compress_options->compressPreallocChunks >= BLCKSZ / compress_options->compressChunkSize) { ereport(ERROR, (errmsg("invalid compress_prealloc_chunks %d , must be less than %d for %s", compress_options->compressPreallocChunks, diff --git a/src/gausskernel/storage/replication/basebackup.cpp b/src/gausskernel/storage/replication/basebackup.cpp index f49282137..3d69fe40b 100755 --- a/src/gausskernel/storage/replication/basebackup.cpp +++ b/src/gausskernel/storage/replication/basebackup.cpp @@ -1279,7 +1279,7 @@ static void SendRealFile(bool sizeOnly, char* pathbuf, size_t pathBufLen, int ba // we must ensure the page integrity when in IncrementalCheckpoint if (!sizeOnly && g_instance.attr.attr_storage.enableIncrementalCheckpoint && IsCompressedFile(pathbuf, strlen(pathbuf)) != COMPRESSED_TYPE_UNKNOWN) { - SendCompressedFile(pathbuf, basepathlen, (*statbuf), true, &size); + SendCompressedFile(pathbuf, basepathlen, (*statbuf), false, &size); } else { bool sent = false; if (!sizeOnly) { @@ -1951,7 +1951,8 @@ static void SendCompressedFile(char* readFileName, int basePathLen, struct stat& } char pcaFilePath[MAXPGPATH]; - securec_check_c(memcpy_s(pcaFilePath, MAXPGPATH, readFileName, readFileNameLen), "", ""); + securec_check(strcpy_s(pcaFilePath, MAXPGPATH, readFileName), "", ""); + /* change pcd => pca */ pcaFilePath[readFileNameLen - 1] = 'a'; FILE* pcaFile = AllocateFile(pcaFilePath, "rb"); diff --git a/src/gausskernel/storage/smgr/md.cpp b/src/gausskernel/storage/smgr/md.cpp index 290815d38..117aeef27 100644 --- a/src/gausskernel/storage/smgr/md.cpp +++ b/src/gausskernel/storage/smgr/md.cpp @@ -1107,7 +1107,7 @@ static MdfdVec *mdopen(SMgrRelation reln, ForkNumber forknum, ExtensionBehavior { MdfdVec *mdfd = NULL; char *path = NULL; - File fd; + File fd = -1; RelFileNodeForkNum filenode; uint32 flags = O_RDWR | PG_BINARY; @@ -2603,9 +2603,29 @@ static MdfdVec *_mdfd_openseg(SMgrRelation reln, ForkNumber forknum, BlockNumber ADIO_END(); /* open the file */ + if (RecoveryInProgress() && CheckFileRepairHashTbl(reln->smgr_rnode.node, forknum, segno) && + (AmStartupProcess() || AmPageRedoWorker() || AmPageWriterProcess() || AmCheckpointerProcess())) { + fd = openrepairfile(fullpath, filenode); + if (fd < 0) { + pfree(fullpath); + return NULL; + } else { + ereport(LOG, (errmsg("[file repair] open repair file %s.repair", fullpath))); + } + } else { + fd = DataFileIdOpenFile(fullpath, filenode, O_RDWR | PG_BINARY | oflags, 0600); + } + + if (fd < 0) { + pfree(fullpath); + return NULL; + } + int fd_pca = -1; int fd_pcd = -1; if (IS_COMPRESSED_MAINFORK(reln, forknum)) { + FileClose(fd); + fd = -1; fd_pca = OpenPcaFile(fullpath, reln->smgr_rnode, MAIN_FORKNUM, segno, oflags); if (fd_pca < 0) { pfree(fullpath); @@ -2617,28 +2637,10 @@ static MdfdVec *_mdfd_openseg(SMgrRelation reln, ForkNumber forknum, BlockNumber return NULL; } SetupPageCompressMemoryMap(fd_pca, reln->smgr_rnode.node, filenode); - } else { - - if (RecoveryInProgress() && CheckFileRepairHashTbl(reln->smgr_rnode.node, forknum, segno) && - (AmStartupProcess() || AmPageRedoWorker() || AmPageWriterProcess() || AmCheckpointerProcess())) { - fd = openrepairfile(fullpath, filenode); - if (fd < 0) { - pfree(fullpath); - return NULL; - } else { - ereport(LOG, (errmsg("[file repair] open repair file %s.repair", fullpath))); - } - } else { - fd = DataFileIdOpenFile(fullpath, filenode, O_RDWR | PG_BINARY | oflags, 0600); - } } pfree(fullpath); - if (fd < 0) { - return NULL; - } - /* allocate an mdfdvec entry for it */ v = _fdvec_alloc();