diff --git a/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.cpp b/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.cpp index f0cdbb63dda976d6328f18f0246a3bdd6048585a..cb26dd5c40fd09ab733921094205a2aab8b782a3 100644 --- a/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.cpp +++ b/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.cpp @@ -39,9 +39,6 @@ BitmapSet::BitmapSet() BitmapSet::BitmapSet(uint8_t* data, uint16_t size) : m_data(data), m_size(size), m_init(true) {} -BitmapSet::BitmapSet(uint16_t size) : m_data((uint8_t*)malloc(GetLength(size))), m_size(size), m_init(true) -{} - BitmapSet::~BitmapSet() {} @@ -67,12 +64,6 @@ void BitmapSet::Reset(uint16_t size) securec_check(erc, "\0", "\0"); } -void BitmapSet::Destroy() -{ - free(m_data); - m_init = false; -} - void BitmapSet::Clear() { errno_t erc = memset_s(m_data, GetLength(), 0, GetLength()); diff --git a/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.h b/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.h index fa77d1a2a5970b8f0371c77edeb110074c0c55ca..ddc7625f53b69dfdc56b041eab30615cc21f13d0 100644 --- a/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.h +++ b/src/gausskernel/storage/mot/core/src/infra/containers/bitmapset.h @@ -55,13 +55,11 @@ public: }; BitmapSet(); - explicit BitmapSet(uint16_t size); BitmapSet(uint8_t* data, uint16_t size); ~BitmapSet(); void Init(uint8_t* data, uint16_t size); void Reset(); - void Destroy(); void Clear(); void Reset(uint16_t size); void SetBit(uint16_t bit); diff --git a/src/gausskernel/storage/mot/core/src/storage/table.cpp b/src/gausskernel/storage/mot/core/src/storage/table.cpp index ba6458669c65fd9b18493a0b4e21af29f17680fa..371f19df874888fb251657d3c54fbb26ab8bd8c7 100644 --- a/src/gausskernel/storage/mot/core/src/storage/table.cpp +++ b/src/gausskernel/storage/mot/core/src/storage/table.cpp @@ -173,8 +173,8 @@ bool Table::AddSecondaryIndex(const string& indexName, Index* index, TxnManager* { // OA: Should we check for duplicate indices with same name? // first create secondary index data - bool createdIndexData = (txn != nullptr) ? CreateSecondaryIndexData(index, txn) : - CreateSecondaryIndexDataNonTransactional(index, tid); + bool createdIndexData = + (txn != nullptr) ? CreateSecondaryIndexData(index, txn) : CreateSecondaryIndexDataNonTransactional(index, tid); if (!createdIndexData) { MOT_REPORT_ERROR(MOT_ERROR_INTERNAL, "Add Secondary Index", diff --git a/src/gausskernel/storage/mot/core/src/system/checkpoint/checkpoint_manager.cpp b/src/gausskernel/storage/mot/core/src/system/checkpoint/checkpoint_manager.cpp index bfe65eb605c044226905000cd90bce2777d93984..683dd94064b775976086c9f4ecc37a927884411d 100644 --- a/src/gausskernel/storage/mot/core/src/system/checkpoint/checkpoint_manager.cpp +++ b/src/gausskernel/storage/mot/core/src/system/checkpoint/checkpoint_manager.cpp @@ -783,6 +783,9 @@ bool CheckpointManager::CreateTpcRecoveryFile(uint64_t checkpointId) break; } + // this lock is held while serializing the in process transactions call by + // checkpoint. It prevents gs_clean removing entries from the in-process map + // while they are serialized GetRecoveryManager()->LockInProcessTxns(); CheckpointUtils::TpcFileHeader tpcFileHeader; tpcFileHeader.m_magic = CP_MGR_MAGIC; diff --git a/src/gausskernel/storage/mot/core/src/system/recovery/recovery_manager.cpp b/src/gausskernel/storage/mot/core/src/system/recovery/recovery_manager.cpp index 99ea2c22e6e5a036cb1c1d3380cece3f79d09cb9..3f382ce2a20244ca7c7063b5561f347ac102ba41 100644 --- a/src/gausskernel/storage/mot/core/src/system/recovery/recovery_manager.cpp +++ b/src/gausskernel/storage/mot/core/src/system/recovery/recovery_manager.cpp @@ -1026,10 +1026,6 @@ bool RecoveryManager::SerializeInProcessTxns(int fd) return false; } - // this lock is held while serializing the in process transactions call by - // checkpoint. It prevents gs_clean removing entries from the in-process map - // while they are serialized - std::lock_guard lock(m_inProcessTxLock); map::iterator it = m_inProcessTransactionMap.begin(); while (it != m_inProcessTransactionMap.end()) { RedoTransactionSegments* segments = it->second; diff --git a/src/gausskernel/storage/mot/core/src/system/transaction/txn_local_allocators.h b/src/gausskernel/storage/mot/core/src/system/transaction/txn_local_allocators.h index 1f24439bfaa64a5f349a7e65a6ca823f438ca142..92c8b9292efa93ae4ca30a2e45f6c672e60be60e 100644 --- a/src/gausskernel/storage/mot/core/src/system/transaction/txn_local_allocators.h +++ b/src/gausskernel/storage/mot/core/src/system/transaction/txn_local_allocators.h @@ -75,6 +75,8 @@ public: if (buf == nullptr) { return nullptr; } + errno_t erc = memset_s(buf, size, 0, size); + securec_check(erc, "\0", "\0"); return reinterpret_cast(buf); } diff --git a/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log.cpp b/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log.cpp index 6c486984190631ffe4928e029331ad4008aa1774..954e63fbd6d1299a88c790f49e608298048ba6d1 100644 --- a/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log.cpp +++ b/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log.cpp @@ -330,7 +330,7 @@ RC RedoLog::SerializeTransaction() if (m_txn->m_isLightSession) return RC_OK; - for (uint32_t index = 0; index < m_txn->m_accessMgr->m_rowCnt ; index++) { + for (uint32_t index = 0; index < m_txn->m_accessMgr->m_rowCnt; index++) { Access* access = m_txn->m_accessMgr->GetAccessPtr(index); if (access != nullptr) { switch (access->m_type) { diff --git a/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log_writer.cpp b/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log_writer.cpp index 87ddeb9411e999e200aa8fe75f7fe044bebe714c..10af02bf1aa5044b8c02a1a478595ee818aeb526 100644 --- a/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log_writer.cpp +++ b/src/gausskernel/storage/mot/core/src/system/transaction_logger/redo_log_writer.cpp @@ -213,10 +213,8 @@ bool RedoLogWriter::AppendCommitPrepared(RedoLogBuffer& redoLogBuffer, TxnManage bool RedoLogWriter::AppendRollbackPrepared(RedoLogBuffer& redoLogBuffer, TxnManager* txn) { // buffer must have enough space for control entry - EndSegmentBlock block(OperationCode::ROLLBACK_PREPARED_TX, - 0, - txn->GetTransactionId(), - txn->GetInternalTransactionId()); + EndSegmentBlock block( + OperationCode::ROLLBACK_PREPARED_TX, 0, txn->GetTransactionId(), txn->GetInternalTransactionId()); redoLogBuffer.Append(block); return true; } @@ -232,10 +230,7 @@ bool RedoLogWriter::AppendRollback(RedoLogBuffer& redoLogBuffer, TxnManager* txn bool RedoLogWriter::AppendPartial(RedoLogBuffer& redoLogBuffer, TxnManager* txn) { // buffer must have enough space for control entry - EndSegmentBlock block(OperationCode::PARTIAL_REDO_TX, - 0, - txn->GetTransactionId(), - txn->GetInternalTransactionId()); + EndSegmentBlock block(OperationCode::PARTIAL_REDO_TX, 0, txn->GetTransactionId(), txn->GetInternalTransactionId()); redoLogBuffer.Append(block); return true; } diff --git a/src/gausskernel/storage/mot/jit_exec/src/jit_context.cpp b/src/gausskernel/storage/mot/jit_exec/src/jit_context.cpp index e6912141f6848125bb06620b4fa792ea620e892c..d02cd42939783abccfde89f491de82ff37eb48e0 100755 --- a/src/gausskernel/storage/mot/jit_exec/src/jit_context.cpp +++ b/src/gausskernel/storage/mot/jit_exec/src/jit_context.cpp @@ -166,9 +166,15 @@ extern bool PrepareJitContext(JitContext* jitContext) if (buf == NULL) { MOT_LOG_TRACE("Failed to allocate reusable bitmap set for JIT context, aborting jitted code execution"); return false; // safe cleanup during destroy - } else { - jitContext->m_bitmapSet = new (buf) MOT::BitmapSet(fieldCount); } + + uint8_t* bitmapData = (uint8_t*)palloc_top(MOT::BitmapSet::GetLength(fieldCount)); + if (bitmapData == NULL) { + MOT_LOG_TRACE("Failed to allocate reusable bitmap set for JIT context, aborting jitted code execution"); + pfree_top(buf); + return false; // safe cleanup during destroy + } + jitContext->m_bitmapSet = new (buf) MOT::BitmapSet(bitmapData, fieldCount); } // allocate end-iterator key object when executing range UPDATE command or special SELECT commands @@ -261,7 +267,7 @@ extern void DestroyJitContext(JitContext* jitContext) // cleanup bitmap set if (jitContext->m_bitmapSet != NULL) { - jitContext->m_bitmapSet->Destroy(); + pfree_top(jitContext->m_bitmapSet->GetData()); jitContext->m_bitmapSet->MOT::BitmapSet::~BitmapSet(); pfree_top(jitContext->m_bitmapSet); jitContext->m_bitmapSet = NULL;