From 8ca85fbb409949e2c035b17962fb12fa5eb827e4 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Fri, 15 Sep 2017 10:05:19 +0100 Subject: [PATCH] MCOL-859 DDL System catalog mutex deadlock A race between a DDL change and a system catalog version cache update can cause a deadlock in DDLProc. This makes the mutex recursive. --- dbcon/execplan/calpontsystemcatalog.cpp | 4 ++-- dbcon/execplan/calpontsystemcatalog.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 33fe2a7a3..016e91744 100755 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -1190,7 +1190,7 @@ const CalpontSystemCatalog::ColType CalpontSystemCatalog::colTypeDct(const OID& } // check map first cached column type - boost::mutex::scoped_lock lk3(fDctTokenMapLock); + boost::recursive_mutex::scoped_lock lk3(fDctTokenMapLock); DctTokenMap::const_iterator iter = fDctTokenMap.find(dictOid); if (iter != fDctTokenMap.end()) return colType(iter->second); @@ -5320,7 +5320,7 @@ void CalpontSystemCatalog::flushCache() buildSysTablemap(); lk3.unlock(); - boost::mutex::scoped_lock lk4(fDctTokenMapLock); + boost::recursive_mutex::scoped_lock lk4(fDctTokenMapLock); fDctTokenMap.clear(); buildSysDctmap(); lk4.unlock(); diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index c58e531bc..2fc3be75b 100755 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -871,7 +871,8 @@ private: typedef std::map DctTokenMap; DctTokenMap fDctTokenMap; - boost::mutex fDctTokenMapLock; + // MCOL-859: this can lock when already locked in the same thread + boost::recursive_mutex fDctTokenMapLock; typedef std::map TableNameMap; TableNameMap fTableNameMap;