[rhmessaging-commits] rhmessaging commits: r3731 - in store/trunk/cpp/lib: jrnl and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Wed Dec 2 13:23:36 EST 2009
Author: kpvdr
Date: 2009-12-02 13:23:36 -0500 (Wed, 02 Dec 2009)
New Revision: 3731
Modified:
store/trunk/cpp/lib/IdSequence.cpp
store/trunk/cpp/lib/MessageStoreImpl.cpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
Log:
Fix for rid overflow (which happens after 2^64 persistence ids are used - this will take a little time) which allowed the persistence id to return to 0. Fixed recovery logic to use correct RFC 1982 arithmatic, modified for use with unsigned ints.
Modified: store/trunk/cpp/lib/IdSequence.cpp
===================================================================
--- store/trunk/cpp/lib/IdSequence.cpp 2009-11-30 20:07:31 UTC (rev 3730)
+++ store/trunk/cpp/lib/IdSequence.cpp 2009-12-02 18:23:36 UTC (rev 3731)
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2007, 2008 Red Hat, Inc.
+ Copyright (c) 2007, 2008, 2009 Red Hat, Inc.
This file is part of the Qpid async store library msgstore.so.
@@ -31,6 +31,7 @@
u_int64_t IdSequence::next()
{
Mutex::ScopedLock guard(lock);
+ if (!id) id++; // avoid 0 when folding around
return id++;
}
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-11-30 20:07:31 UTC (rev 3730)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-12-02 18:23:36 UTC (rev 3731)
@@ -795,7 +795,8 @@
long idcnt = 0L; // in-doubt msg count
u_int64_t thisHighestRid = 0;
jQueue->recover(numJrnlFiles, autoJrnlExpand, autoJrnlExpandMaxFiles, jrnlFsizeSblks, wCacheNumPages, wCachePgSizeSblks, &prepared, thisHighestRid, key.id); // start recovery
- if (thisHighestRid > highestRid)
+ // RFC 1982 comparison for unsigned 64-bit
+ if (thisHighestRid - highestRid < 0x8000000000000000ULL)
highestRid = thisHighestRid;
recoverMessages(txn, registry, queue, prepared, messages, rcnt, idcnt);
QPID_LOG(info, "Recovered queue \"" << queueName << "\": " << rcnt << " messages recovered; " << idcnt << " messages in-doubt.");
@@ -812,6 +813,7 @@
// NOTE: highestRid is set by both recoverQueues() and recoverTplStore() as
// the messageIdSequence is used for both queue journals and the tpl journal.
messageIdSequence.reset(highestRid + 1);
+ QPID_LOG(info, "Most recent persistence id found: 0x" << std::hex << highestRid << std::dec);
queueIdSequence.reset(maxQueueId + 1);
}
@@ -1188,7 +1190,8 @@
if (journal::jdir::exists(tplStorePtr->jrnl_dir() + tplStorePtr->base_filename() + ".jinf")) {
u_int64_t thisHighestRid;
tplStorePtr->recover(tplNumJrnlFiles, false, 0, tplJrnlFsizeSblks, tplWCachePgSizeSblks, tplWCacheNumPages, 0, thisHighestRid, 0);
- if (thisHighestRid > highestRid)
+ // RFC 1982 comparison for unsigned 64-bit
+ if (thisHighestRid - highestRid < 0x8000000000000000ULL)
highestRid = thisHighestRid;
// Load tplRecoverMap by reading the TPL store
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2009-11-30 20:07:31 UTC (rev 3730)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2009-12-02 18:23:36 UTC (rev 3731)
@@ -932,7 +932,8 @@
throw jexception(jerrno::JERR_JCNTL_OWIMISMATCH, oss.str(), "jcntl",
"check_owi");
}
- if (rd._h_rid < h._rid)
+ // RFC 1982 comparison for unsigned 64-bit
+ if (h._rid - rd._h_rid < 0x8000000000000000ULL)
rd._h_rid = h._rid;
return true;
}
More information about the rhmessaging-commits
mailing list