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;
|
||||
|
@ -139,7 +139,8 @@ class CompFileData
|
||||
{
|
||||
public:
|
||||
CompFileData(const FileID& id, const FID& fid,
|
||||
const execplan::CalpontSystemCatalog::ColDataType colDataType, int colWidth)
|
||||
const execplan::CalpontSystemCatalog::ColDataType colDataType, int colWidth,
|
||||
bool readOnly = false)
|
||||
: fFileID(id)
|
||||
, fFid(fid)
|
||||
, fColDataType(colDataType)
|
||||
@ -147,6 +148,7 @@ class CompFileData
|
||||
, fDctnryCol(false)
|
||||
, fFilePtr(NULL)
|
||||
, fCompressionType(1)
|
||||
, fReadOnly(readOnly)
|
||||
{
|
||||
}
|
||||
|
||||
@ -163,6 +165,7 @@ class CompFileData
|
||||
CompFileHeader fFileHeader;
|
||||
std::list<ChunkData*> fChunkList;
|
||||
uint32_t fCompressionType;
|
||||
bool fReadOnly;
|
||||
|
||||
friend class ChunkManager;
|
||||
};
|
||||
@ -179,7 +182,8 @@ class ChunkManager
|
||||
// @brief Retrieve a file pointer in the chunk manager.
|
||||
// for column file
|
||||
IDBDataFile* getFilePtr(const Column& column, uint16_t root, uint32_t partition, uint16_t segment,
|
||||
std::string& filename, const char* mode, int size, bool useTmpSuffix) const;
|
||||
std::string& filename, const char* mode, int size, bool useTmpSuffix,
|
||||
bool isReadOnly = false) const;
|
||||
|
||||
// @brief Retrieve a file pointer in the chunk manager.
|
||||
// for dictionary file
|
||||
@ -200,7 +204,7 @@ class ChunkManager
|
||||
|
||||
// @brief Read a block from pFile at offset fbo.
|
||||
// The data may copied from memory if the chunk it belongs to is already available.
|
||||
int readBlock(IDBDataFile* pFile, unsigned char* readBuf, uint64_t fbo, bool isReadOnly = false);
|
||||
int readBlock(IDBDataFile* pFile, unsigned char* readBuf, uint64_t fbo);
|
||||
|
||||
// @brief Save a block to a chunk in pFile.
|
||||
// The block is not written to disk immediately, will be delayed until flush.
|
||||
@ -279,7 +283,7 @@ class ChunkManager
|
||||
CompFileData* getFileData(const FID& fid, uint16_t root, uint32_t partition, uint16_t segment,
|
||||
std::string& filename, const char* mode, int size,
|
||||
const execplan::CalpontSystemCatalog::ColDataType colDataType, int colWidth,
|
||||
bool useTmpSuffix, bool dictnry = false) const;
|
||||
bool useTmpSuffix, bool dictnry = false, bool isReadOnly = false) const;
|
||||
|
||||
CompFileData* getFileDataByName(const std::string& filename, const FID& fid, uint16_t root,
|
||||
uint32_t partition, uint16_t segment, const char* mode, int size,
|
||||
@ -287,7 +291,7 @@ class ChunkManager
|
||||
bool useTmpSuffix, bool dctnry) const;
|
||||
|
||||
// @brief Retrieve a chunk of pFile from disk.
|
||||
int fetchChunkFromFile(IDBDataFile* pFile, int64_t id, ChunkData*& chunkData, bool isReadOnly = false);
|
||||
int fetchChunkFromFile(IDBDataFile* pFile, int64_t id, ChunkData*& chunkData);
|
||||
|
||||
// @brief Compress a chunk and write it to file.
|
||||
int writeChunkToFile(CompFileData* fileData, int64_t id);
|
||||
@ -370,7 +374,7 @@ class ChunkManager
|
||||
private:
|
||||
CompFileData* getFileData_(const FileID& fid, const std::string& filename, const char* mode, int size,
|
||||
const execplan::CalpontSystemCatalog::ColDataType colDataType, int colWidth,
|
||||
bool useTmpSuffix, bool dictnry = false) const;
|
||||
bool useTmpSuffix, bool dictnry = false, bool isReadOnly = false) const;
|
||||
};
|
||||
|
||||
} // namespace WriteEngine
|
||||
|
Reference in New Issue
Block a user