Author: kpvdr
Date: 2008-12-09 12:53:33 -0500 (Tue, 09 Dec 2008)
New Revision: 2954
Modified:
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/lib/jrnl/txn_map.cpp
store/trunk/cpp/lib/jrnl/txn_map.hpp
Log:
Fix for BZ 472937 - "TPL recoverTplStore() failed: jexception 0x0b01
txn_map::get_tdata_list() threw JERR_MAP_NOTFOUND: Key not found in map.
(xid=rhm-tid0x2aac2c9b0ee0) (MessageStoreImpl.cpp:1079)".
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-12-09 15:53:21 UTC (rev 2953)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-12-09 17:53:33 UTC (rev 2954)
@@ -168,21 +168,7 @@
return RHM_IORES_TXPENDING;
// (Recover mode only) Ok, not in emap - now search tmap, if present
then read
- std::vector<std::string> xid_list;
- _tmap.xid_list(xid_list);
- for (std::vector<std::string>::iterator itr =
xid_list.begin();
- itr != xid_list.end() && !is_enq; itr++)
- {
- txn_data_list tx_list = _tmap.get_tdata_list(*itr);
- for (tdl_itr ditr = tx_list.begin(); ditr != tx_list.end()
&& !is_enq;
- ditr++)
- {
- if (ditr->_enq_flag)
- is_enq = ditr->_rid == _hdr._rid;
- else
- is_enq = ditr->_drid == _hdr._rid;
- }
- }
+ is_enq = _tmap.is_enq(_hdr._rid);
if (enforce_txns && is_enq)
return RHM_IORES_TXPENDING;
}
Modified: store/trunk/cpp/lib/jrnl/txn_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.cpp 2008-12-09 15:53:21 UTC (rev 2953)
+++ store/trunk/cpp/lib/jrnl/txn_map.cpp 2008-12-09 17:53:33 UTC (rev 2954)
@@ -93,12 +93,18 @@
txn_map::get_tdata_list(const std::string& xid)
{
slock s(&_mutex);
+ return get_tdata_list_nolock(xid);
+}
+
+const txn_data_list
+txn_map::get_tdata_list_nolock(const std::string& xid)
+{
xmap_itr itr = _map.find(xid);
if (itr == _map.end()) // not found in map
{
std::ostringstream oss;
oss << std::hex << "xid=" << xid_format(xid);
- throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map",
"get_tdata_list");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map",
"get_tdata_list_nolock");
}
return itr->second;
}
@@ -112,8 +118,7 @@
{
std::ostringstream oss;
oss << std::hex << "xid=" << xid_format(xid);
- throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map",
- "get_remove_tdata_list");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map",
"get_remove_tdata_list");
}
txn_data_list list = itr->second;
_map.erase(itr);
@@ -236,10 +241,10 @@
const txn_data&
txn_map::get_data(const std::string& xid, const u_int64_t rid)
{
- txn_data_list tdl = get_tdata_list(xid);
bool found = false;
{
slock s(&_mutex);
+ txn_data_list tdl = get_tdata_list_nolock(xid);
tdl_itr itr = tdl.begin();
while (itr != tdl.end() && !found)
{
@@ -256,6 +261,27 @@
}
}
+bool
+txn_map::is_enq(const u_int64_t rid)
+{
+ bool found = false;
+ {
+ slock s(&_mutex);
+ for (xmap_itr i = _map.begin(); i != _map.end() && !found; i++)
+ {
+ txn_data_list list = i->second;
+ for (tdl_itr j = list.begin(); j < list.end() && !found; j++)
+ {
+ if (j->_enq_flag)
+ found = j->_rid == rid;
+ else
+ found = j->_drid == rid;
+ }
+ }
+ }
+ return found;
+}
+
void
txn_map::xid_list(std::vector<std::string>& xv)
{
Modified: store/trunk/cpp/lib/jrnl/txn_map.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.hpp 2008-12-09 15:53:21 UTC (rev 2953)
+++ store/trunk/cpp/lib/jrnl/txn_map.hpp 2008-12-09 17:53:33 UTC (rev 2954)
@@ -139,6 +139,7 @@
bool is_txn_synced(const std::string& xid);
bool set_aio_compl(const std::string& xid, const u_int64_t rid);
const txn_data& get_data(const std::string& xid, const u_int64_t rid);
+ bool is_enq(const u_int64_t rid);
inline void clear() { _map.clear(); }
inline bool empty() const { return _map.empty(); }
inline u_int32_t size() const { return u_int32_t(_map.size()); }
@@ -147,6 +148,8 @@
u_int32_t cnt(const bool enq_flag);
u_int32_t cnt(const std::string& xid, const bool enq_flag);
static std::string xid_format(const std::string& xid);
+
+ const txn_data_list get_tdata_list_nolock(const std::string& xid);
};
} // namespace journal