Author: kpvdr
Date: 2010-08-12 10:57:55 -0400 (Thu, 12 Aug 2010)
New Revision: 4204
Modified:
store/trunk/cpp/tools/janal.py
store/trunk/cpp/tools/jerr.py
store/trunk/cpp/tools/resize
store/trunk/cpp/tools/store_chk
Log:
Fix for BZ623653 - "resize and store_chk tools do not correctly analyze some
transactional records"
Modified: store/trunk/cpp/tools/janal.py
===================================================================
--- store/trunk/cpp/tools/janal.py 2010-08-12 13:48:50 UTC (rev 4203)
+++ store/trunk/cpp/tools/janal.py 2010-08-12 14:57:55 UTC (rev 4204)
@@ -42,7 +42,7 @@
"""Add a new record into the map"""
if hdr.rid in self.__map:
raise jerr.DuplicateRidError(hdr.rid)
- self.__map[hdr.rid] = (fid, hdr, lock)
+ self.__map[hdr.rid] = [fid, hdr, lock]
def contains(self, rid):
"""Return True if the map contains the given
rid"""
@@ -58,7 +58,7 @@
raise jerr.JWarning("ERROR: Deleting non-existent rid from EnqMap:
rid=0x%x" % rid)
def get(self, rid):
- """Return a tuple (fid, hdr, lock) for the given
rid"""
+ """Return a list [fid, hdr, lock] for the given
rid"""
if self.contains(rid):
return self.__map[rid]
return None
@@ -88,9 +88,8 @@
def lock(self, rid):
"""Set the transaction lock for a given rid to
True"""
if rid in self.__map:
- tup = self.__map[rid]
- if not tup[2]:
- self.__map[rid] = (tup[0], tup[1], True)
+ if not self.__map[rid][2]: # locked
+ self.__map[rid][2] = True
else:
raise jerr.AlreadyLockedError(rid)
else:
@@ -106,8 +105,7 @@
rid_list = self.__map.keys()
rid_list.sort()
for rid in rid_list:
- rec = self.__map[rid]
- if rec[2]:
+ if self.__map[rid][2]:
lock_str = " [LOCKED]"
else:
lock_str = ""
@@ -127,9 +125,8 @@
def unlock(self, rid):
"""Set the transaction lock for a given rid to
False"""
if rid in self.__map:
- tup = self.__map[rid]
- if tup[2]:
- self.__map[rid] = (tup[0], tup[1], False)
+ if self.__map[rid][2]:
+ self.__map[rid][2] = False
else:
raise jerr.NotLockedError(rid)
else:
@@ -153,11 +150,20 @@
def add(self, fid, hdr):
"""Add a new transactional record into the map"""
if isinstance(hdr, jrnl.DeqRec):
- self.__emap.lock(hdr.deq_rid)
+ try:
+ self.__emap.lock(hdr.deq_rid)
+ except jerr.JWarning:
+ # Not in emap, look for rid in tmap
+ l = self.find_rid(hdr.deq_rid, hdr.xid)
+ if l == None:
+ raise jerr.DequeueNonExistentEnqueueError(hdr.deq_rid)
+ if l[2]:
+ raise jerr.AlreadyLockedError(hdr.deq_rid)
+ l[2] = True
if hdr.xid in self.__map:
- self.__map[hdr.xid].append((fid, hdr)) # append to existing list
+ self.__map[hdr.xid].append([fid, hdr, False]) # append to existing list
else:
- self.__map[hdr.xid] = [(fid, hdr)] # create new list
+ self.__map[hdr.xid] = [[fid, hdr, False]] # create new list
def contains(self, xid):
"""Return True if the xid exists in the map; False
otherwise"""
@@ -171,6 +177,18 @@
self._abort(hdr.xid)
else:
raise jerr.InvalidRecordTypeError("delete from TxnMap", hdr.magic,
hdr.rid)
+
+ def find_rid(self, rid, xid_hint = None):
+ """ Search for and return map list with supplied rid. If xid_hint
is supplied, try that xid first"""
+ if xid_hint != None and self.contains(xid_hint):
+ for l in self.__map[xid_hint]:
+ if l[1].rid == rid:
+ return l
+ for xid in self.__map.iterkeys():
+ if xid_hint == None or xid != xid_hint:
+ for l in self.__map[xid]:
+ if l[1].rid == rid:
+ return l
def get(self, xid):
"""Return a list of operations for the given
xid"""
@@ -210,9 +228,9 @@
def _commit(self, xid):
"""Perform a commit operation for the given xid
record"""
mismatch_list = []
- for fid, hdr in self.__map[xid]:
- if isinstance(hdr, jrnl.EnqRec):
- self.__emap.add(fid, hdr) # Transfer enq to emap
+ for fid, hdr, lock in self.__map[xid]:
+ if isinstance(hdr, jrnl.EnqRec):
+ self.__emap.add(fid, hdr, lock) # Transfer enq to emap
else:
if self.__emap.contains(hdr.deq_rid):
self.__emap.unlock(hdr.deq_rid)
Modified: store/trunk/cpp/tools/jerr.py
===================================================================
--- store/trunk/cpp/tools/jerr.py 2010-08-12 13:48:50 UTC (rev 4203)
+++ store/trunk/cpp/tools/jerr.py 2010-08-12 14:57:55 UTC (rev 4204)
@@ -63,6 +63,12 @@
"""Constructor"""
Exception.__init__(self, "Deleting locked record from EnqMap: rid=0x%s"
% rid)
+class DequeueNonExistentEnqueueError(Exception):
+ """Error class for attempting to dequeue a non-existent enqueue record
(rid)"""
+ def __init__(self, deq_rid):
+ """Constructor"""
+ Exception.__init__(self, "Dequeuing non-existent rnqueue record:
rid=0x%s" % deq_rid)
+
class DuplicateRidError(Exception):
"""Error class for placing duplicate rid into enqueue
map"""
def __init__(self, rid):
Modified: store/trunk/cpp/tools/resize
===================================================================
--- store/trunk/cpp/tools/resize 2010-08-12 13:48:50 UTC (rev 4203)
+++ store/trunk/cpp/tools/resize 2010-08-12 14:57:55 UTC (rev 4204)
@@ -126,8 +126,8 @@
if self._opts.vflag and self._jrnl_reader.tmap().size() > 0:
print "* Assembling %d records from tmap" %
self._jrnl_reader.tmap().size()
for xid in self._jrnl_reader.tmap().xids():
- for tup in self._jrnl_reader.tmap().get(xid):
- hdr = tup[1]
+ for l in self._jrnl_reader.tmap().get(xid):
+ hdr = l[1]
hdr.flags &= ~jrnl.Hdr.OWI_MASK # Turn off owi
master_record_list[hdr.rid] = hdr
rid_list = master_record_list.keys()
Modified: store/trunk/cpp/tools/store_chk
===================================================================
--- store/trunk/cpp/tools/store_chk 2010-08-12 13:48:50 UTC (rev 4203)
+++ store/trunk/cpp/tools/store_chk 2010-08-12 14:57:55 UTC (rev 4204)
@@ -84,11 +84,11 @@
rid_list = self.jrnl_rdr.emap().rids()
rid_list.sort()
for rid in rid_list:
- tup = self.jrnl_rdr.emap().get(rid)
+ l = self.jrnl_rdr.emap().get(rid)
locked = ""
- if tup[2]:
+ if l[2]:
locked += " (locked)"
- print " fid=%d %s%s" % (tup[0], tup[1], locked)
+ print " fid=%d %s%s" % (l[0], l[1], locked)
print "WARNING: Enqueue-Dequeue mismatch, %d enqueued records
remain." % self.jrnl_rdr.emap().size()
else:
print "No remaining enqueued records found (emap empty)."
@@ -99,8 +99,8 @@
for xid in self.jrnl_rdr.tmap().xids():
jrnl.Utils.format_xid(xid)
recs = self.jrnl_rdr.tmap().get(xid)
- for tup in recs:
- print " fid=%d %s" % (tup[0], tup[1])
+ for l in recs:
+ print " fid=%d %s" % (l[0], l[1])
print " Total: %d records for %s" % (len(recs),
jrnl.Utils.format_xid(xid))
print
txn_rec_cnt += len(recs)