diff --git a/src/backend/gporca/libgpos/include/gpos/memory/CMemoryPool.h b/src/backend/gporca/libgpos/include/gpos/memory/CMemoryPool.h index 7d997d37cbb..3f9ab65946c 100644 --- a/src/backend/gporca/libgpos/include/gpos/memory/CMemoryPool.h +++ b/src/backend/gporca/libgpos/include/gpos/memory/CMemoryPool.h @@ -25,6 +25,9 @@ #ifndef GPOS_CMemoryPool_H #define GPOS_CMemoryPool_H +#include +#include + #include "gpos/assert.h" #include "gpos/common/CLink.h" #include "gpos/common/CStackDescriptor.h" @@ -75,7 +78,11 @@ class CMemoryPool friend class CMemoryPoolManager; private: - // hash key is only set by pool manager + // psudo random hash key generator + std::mt19937 m_generator; + std::uniform_int_distribution m_distribution; + + // hash key for this memory pool ULONG_PTR m_hash_key; #ifdef GPOS_DEBUG @@ -98,6 +105,13 @@ class CMemoryPool EatArray = 0x7e }; + CMemoryPool() + // MAX LONG is invalid hash key, so skip that hash value. + : m_distribution(0, std::numeric_limits::max() - 1), + m_hash_key(m_distribution(m_generator)) + { + } + // dtor virtual ~CMemoryPool() = default;