From f15b2390a320cc31e7cada07104984a8bbd1fe2a 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 635927c7b..acc49ef7f 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -1187,7 +1187,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); @@ -5317,7 +5317,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 2936b2daa..641a40b49 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -869,7 +869,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;