You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-5021 non-AUX column files are opened in read-only mode during
the DELETE operation. ColumnOp::readBlock() calls can cause writes to database files when the active chunk list in ChunkManager is full. Since non-AUX columns are read-only for the DELETE operation, we prevent writes of compressed chunks and header for these columns by passing an isReadOnly flag to CompFileData which indicates whether the column is read-only or read-write.
This commit is contained in:
@ -252,10 +252,11 @@ int ChunkManager::removeBackups(TxnID txnId)
|
||||
// @bug 5572 - HDFS usage: add *.tmp file backup flag
|
||||
IDBDataFile* ChunkManager::getFilePtr(const Column& column, uint16_t root, uint32_t partition,
|
||||
uint16_t segment, string& filename, const char* mode, int size,
|
||||
bool useTmpSuffix) const
|
||||
bool useTmpSuffix, bool isReadOnly) const
|
||||
{
|
||||
CompFileData* fileData = getFileData(column.dataFile.fid, root, partition, segment, filename, mode, size,
|
||||
column.colDataType, column.colWidth, useTmpSuffix);
|
||||
column.colDataType, column.colWidth, useTmpSuffix,
|
||||
false, isReadOnly);
|
||||
return (fileData ? fileData->fFilePtr : NULL);
|
||||
}
|
||||
|
||||
@ -313,7 +314,8 @@ IDBDataFile* ChunkManager::getFilePtrByName(const std::string& filename, FID& fi
|
||||
CompFileData* ChunkManager::getFileData(const FID& fid, uint16_t root, uint32_t partition, uint16_t segment,
|
||||
string& filename, const char* mode, int size,
|
||||
const CalpontSystemCatalog::ColDataType colDataType, int colWidth,
|
||||
bool useTmpSuffix, bool dctnry) const
|
||||
bool useTmpSuffix, bool dctnry,
|
||||
bool isReadOnly) const
|
||||
{
|
||||
FileID fileID(fid, root, partition, segment);
|
||||
map<FileID, CompFileData*>::const_iterator mit = fFileMap.find(fileID);
|
||||
@ -335,7 +337,7 @@ CompFileData* ChunkManager::getFileData(const FID& fid, uint16_t root, uint32_t
|
||||
|
||||
// Initialize the given `filename`.
|
||||
filename = name;
|
||||
return getFileData_(fileID, filename, mode, size, colDataType, colWidth, useTmpSuffix, dctnry);
|
||||
return getFileData_(fileID, filename, mode, size, colDataType, colWidth, useTmpSuffix, dctnry, isReadOnly);
|
||||
}
|
||||
|
||||
CompFileData* ChunkManager::getFileDataByName(const std::string& filename, const FID& fid, uint16_t root,
|
||||
@ -359,9 +361,9 @@ CompFileData* ChunkManager::getFileDataByName(const std::string& filename, const
|
||||
|
||||
CompFileData* ChunkManager::getFileData_(const FileID& fileID, const string& filename, const char* mode,
|
||||
int size, const CalpontSystemCatalog::ColDataType colDataType,
|
||||
int colWidth, bool useTmpSuffix, bool dctnry) const
|
||||
int colWidth, bool useTmpSuffix, bool dctnry, bool isReadOnly) const
|
||||
{
|
||||
CompFileData* fileData = new CompFileData(fileID, fileID.fFid, colDataType, colWidth);
|
||||
CompFileData* fileData = new CompFileData(fileID, fileID.fFid, colDataType, colWidth, isReadOnly);
|
||||
fileData->fFileName = filename;
|
||||
|
||||
if (openFile(fileData, mode, colWidth, useTmpSuffix, __LINE__) != NO_ERROR)
|
||||
@ -483,7 +485,7 @@ IDBDataFile* ChunkManager::createDctnryFile(const FID& fid, int64_t width, uint1
|
||||
// Read the block for the specified fbo, from pFile's applicable chunk, and
|
||||
// into readBuf.
|
||||
//------------------------------------------------------------------------------
|
||||
int ChunkManager::readBlock(IDBDataFile* pFile, unsigned char* readBuf, uint64_t fbo, bool isReadOnly)
|
||||
int ChunkManager::readBlock(IDBDataFile* pFile, unsigned char* readBuf, uint64_t fbo)
|
||||
{
|
||||
map<IDBDataFile*, CompFileData*>::iterator fpIt = fFilePtrMap.find(pFile);
|
||||
|
||||
@ -504,7 +506,7 @@ int ChunkManager::readBlock(IDBDataFile* pFile, unsigned char* readBuf, uint64_t
|
||||
|
||||
// chunk is not already uncompressed
|
||||
if (chunkData == NULL)
|
||||
rc = fetchChunkFromFile(pFile, offset.quot, chunkData, isReadOnly);
|
||||
rc = fetchChunkFromFile(pFile, offset.quot, chunkData);
|
||||
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
@ -639,7 +641,7 @@ int ChunkManager::flushChunks(int rc, const std::map<FID, FID>& columOids)
|
||||
break;
|
||||
|
||||
// finally update the header
|
||||
if ((rc = writeHeader(fileData, __LINE__)) != NO_ERROR)
|
||||
if (!fileData->fReadOnly && (rc = writeHeader(fileData, __LINE__)) != NO_ERROR)
|
||||
break;
|
||||
|
||||
//@Bug 4977 remove log file
|
||||
@ -678,8 +680,7 @@ int ChunkManager::flushChunks(int rc, const std::map<FID, FID>& columOids)
|
||||
// If the header ptr for the requested chunk is 0 (or has length 0), then
|
||||
// chunkData is initialized with a new empty chunk.
|
||||
//------------------------------------------------------------------------------
|
||||
int ChunkManager::fetchChunkFromFile(IDBDataFile* pFile, int64_t id, ChunkData*& chunkData,
|
||||
bool isReadOnly)
|
||||
int ChunkManager::fetchChunkFromFile(IDBDataFile* pFile, int64_t id, ChunkData*& chunkData)
|
||||
{
|
||||
// return value
|
||||
int rc = NO_ERROR;
|
||||
@ -725,7 +726,7 @@ int ChunkManager::fetchChunkFromFile(IDBDataFile* pFile, int64_t id, ChunkData*&
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!isReadOnly && (rc = writeHeader(fIt->second, __LINE__)) != NO_ERROR)
|
||||
if (!fIt->second->fReadOnly && (rc = writeHeader(fIt->second, __LINE__)) != NO_ERROR)
|
||||
{
|
||||
// logged by writeHeader
|
||||
return rc;
|
||||
|
Reference in New Issue
Block a user