1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

MCOL-4330 dev Refresh shared memory

If the plugin is restarted after the system is running, it's possible to have stale references to shared memory. This patch deletes those references so the next time they're used, just-in-time initialization will get the latest.
This commit is contained in:
David Hall
2020-10-01 18:19:03 -05:00
parent 1f1ce5bf07
commit 951a6abe85
6 changed files with 46 additions and 11 deletions

View File

@ -59,7 +59,6 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th
std::vector<struct BRM::EMEntry>::iterator iter; std::vector<struct BRM::EMEntry>::iterator iter;
std::vector<struct BRM::EMEntry>::iterator end; std::vector<struct BRM::EMEntry>::iterator end;
emp->getExtents(oid, entries, false, false, true); emp->getExtents(oid, entries, false, false, true);
if (entries.size() == 0) if (entries.size() == 0)
@ -188,6 +187,7 @@ static int is_columnstore_extents_fill(THD* thd, TABLE_LIST* tables, COND* cond)
BRM::OID_t cond_oid = 0; BRM::OID_t cond_oid = 0;
TABLE* table = tables->table; TABLE* table = tables->table;
BRM::DBRM::refreshShm();
BRM::DBRM* emp = new BRM::DBRM(); BRM::DBRM* emp = new BRM::DBRM();
if (!emp || !emp->isDBRMReady()) if (!emp || !emp->isDBRMReady())

View File

@ -207,6 +207,7 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th
static int is_columnstore_files_fill(THD* thd, TABLE_LIST* tables, COND* cond) static int is_columnstore_files_fill(THD* thd, TABLE_LIST* tables, COND* cond)
{ {
BRM::DBRM::refreshShm();
BRM::DBRM* emp = new BRM::DBRM(); BRM::DBRM* emp = new BRM::DBRM();
BRM::OID_t cond_oid = 0; BRM::OID_t cond_oid = 0;
TABLE* table = tables->table; TABLE* table = tables->table;

View File

@ -70,7 +70,7 @@ using namespace oam;
namespace BRM namespace BRM
{ {
DBRM::DBRM(bool noBRMinit) throw() : fDebug(false) DBRM::DBRM(bool noBRMinit) : fDebug(false)
{ {
if (!noBRMinit) if (!noBRMinit)
{ {
@ -1751,7 +1751,7 @@ unsigned DBRM::getExtentRows() throw()
} }
int DBRM::getExtents(int OID, std::vector<struct EMEntry>& entries, int DBRM::getExtents(int OID, std::vector<struct EMEntry>& entries,
bool sorted, bool notFoundErr, bool incOutOfService) throw() bool sorted, bool notFoundErr, bool incOutOfService)
{ {
#ifdef BRM_INFO #ifdef BRM_INFO

View File

@ -104,9 +104,16 @@ class DBRM
public: public:
// The param noBRMFcns suppresses init of the ExtentMap, VSS, VBBM, and CopyLocks. // The param noBRMFcns suppresses init of the ExtentMap, VSS, VBBM, and CopyLocks.
// It can speed up init if the caller only needs the other structures. // It can speed up init if the caller only needs the other structures.
EXPORT DBRM(bool noBRMFcns = false) throw(); EXPORT DBRM(bool noBRMFcns = false);
EXPORT ~DBRM() throw(); EXPORT ~DBRM();
EXPORT static void refreshShm()
{
MasterSegmentTableImpl::refreshShm();
ExtentMapImpl::refreshShm();
FreeListImpl::refreshShm();
}
// @bug 1055+ - Added functions below for multiple files per OID enhancement. // @bug 1055+ - Added functions below for multiple files per OID enhancement.
/** @brief Get the OID, offset, db root, partition, and segment of a logical block ID. /** @brief Get the OID, offset, db root, partition, and segment of a logical block ID.
@ -495,7 +502,7 @@ public:
*/ */
EXPORT int getExtents(int OID, std::vector<struct EMEntry>& entries, EXPORT int getExtents(int OID, std::vector<struct EMEntry>& entries,
bool sorted = true, bool notFoundErr = true, bool sorted = true, bool notFoundErr = true,
bool incOutOfService = false) throw(); bool incOutOfService = false);
/** @brief Gets the extents of a given OID under specified dbroot /** @brief Gets the extents of a given OID under specified dbroot
* *
@ -1015,6 +1022,7 @@ public:
*/ */
EXPORT void invalidateUncommittedExtentLBIDs(execplan::CalpontSystemCatalog::SCN txnid, EXPORT void invalidateUncommittedExtentLBIDs(execplan::CalpontSystemCatalog::SCN txnid,
std::vector<LBID_t>* plbidList = NULL); std::vector<LBID_t>* plbidList = NULL);
private: private:
DBRM(const DBRM& brm); DBRM(const DBRM& brm);
DBRM& operator=(const DBRM& brm); DBRM& operator=(const DBRM& brm);

View File

@ -161,7 +161,17 @@ struct ExtentSorter
class ExtentMapImpl class ExtentMapImpl
{ {
public: public:
~ExtentMapImpl(){};
static ExtentMapImpl* makeExtentMapImpl(unsigned key, off_t size, bool readOnly = false); static ExtentMapImpl* makeExtentMapImpl(unsigned key, off_t size, bool readOnly = false);
static void refreshShm()
{
if (fInstance)
{
delete fInstance;
fInstance = NULL;
}
}
inline void grow(unsigned key, off_t size) inline void grow(unsigned key, off_t size)
#ifdef NDEBUG #ifdef NDEBUG
@ -199,7 +209,6 @@ public:
private: private:
ExtentMapImpl(unsigned key, off_t size, bool readOnly = false); ExtentMapImpl(unsigned key, off_t size, bool readOnly = false);
~ExtentMapImpl();
ExtentMapImpl(const ExtentMapImpl& rhs); ExtentMapImpl(const ExtentMapImpl& rhs);
ExtentMapImpl& operator=(const ExtentMapImpl& rhs); ExtentMapImpl& operator=(const ExtentMapImpl& rhs);
@ -212,7 +221,17 @@ private:
class FreeListImpl class FreeListImpl
{ {
public: public:
~FreeListImpl(){};
static FreeListImpl* makeFreeListImpl(unsigned key, off_t size, bool readOnly = false); static FreeListImpl* makeFreeListImpl(unsigned key, off_t size, bool readOnly = false);
static void refreshShm()
{
if (fInstance)
{
delete fInstance;
fInstance = NULL;
}
}
inline void grow(unsigned key, off_t size) inline void grow(unsigned key, off_t size)
#ifdef NDEBUG #ifdef NDEBUG
@ -250,7 +269,6 @@ public:
private: private:
FreeListImpl(unsigned key, off_t size, bool readOnly = false); FreeListImpl(unsigned key, off_t size, bool readOnly = false);
~FreeListImpl();
FreeListImpl(const FreeListImpl& rhs); FreeListImpl(const FreeListImpl& rhs);
FreeListImpl& operator=(const FreeListImpl& rhs); FreeListImpl& operator=(const FreeListImpl& rhs);

View File

@ -64,14 +64,23 @@ struct MSTEntry
class MasterSegmentTableImpl class MasterSegmentTableImpl
{ {
public: public:
~MasterSegmentTableImpl(){};
static MasterSegmentTableImpl* makeMasterSegmentTableImpl(int key, int size); static MasterSegmentTableImpl* makeMasterSegmentTableImpl(int key, int size);
static void refreshShm()
{
if (fInstance)
{
delete fInstance;
fInstance = NULL;
}
}
boost::interprocess::shared_memory_object fShmobj; boost::interprocess::shared_memory_object fShmobj;
boost::interprocess::mapped_region fMapreg; boost::interprocess::mapped_region fMapreg;
private: private:
MasterSegmentTableImpl(int key, int size); MasterSegmentTableImpl(int key, int size);
~MasterSegmentTableImpl();
MasterSegmentTableImpl(const MasterSegmentTableImpl& rhs); MasterSegmentTableImpl(const MasterSegmentTableImpl& rhs);
MasterSegmentTableImpl& operator=(const MasterSegmentTableImpl& rhs); MasterSegmentTableImpl& operator=(const MasterSegmentTableImpl& rhs);
@ -90,7 +99,6 @@ public:
* @note Throws runtime_error on a semaphore-related error. * @note Throws runtime_error on a semaphore-related error.
*/ */
EXPORT MasterSegmentTable(); EXPORT MasterSegmentTable();
//MasterSegmentTable(const MasterSegmentTable& mst);
EXPORT ~MasterSegmentTable(); EXPORT ~MasterSegmentTable();
/// specifies the Extent Map table /// specifies the Extent Map table