!1546 bugfix: gs_ctl build备份、basebackup备份时,当文件大小超过一个段文件时,会导致build结果异常

Merge pull request !1546 from 吴岳川/I4V678
This commit is contained in:
opengauss-bot
2022-03-07 13:20:58 +00:00
committed by Gitee
3 changed files with 25 additions and 22 deletions

View File

@ -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,

View File

@ -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");

View File

@ -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();