Author: kpvdr
Date: 2008-09-12 10:46:21 -0400 (Fri, 12 Sep 2008)
New Revision: 2458
Modified:
store/branches/mrg-1.0/cpp/lib/jrnl/jcntl.cpp
store/branches/mrg-1.0/cpp/lib/jrnl/nlfh.cpp
store/branches/mrg-1.0/cpp/lib/jrnl/rcvdat.hpp
store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.cpp
store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.hpp
store/branches/mrg-1.0/cpp/lib/jrnl/wrfc.cpp
Log:
Fix for BZ460346 " jexception 0x0406 nlfh::add_rd_subm_cnt_dblks() threw
JERR_NFLH_RDOFFSOVFL: Attempted increase read offset past write offset.
(_rd_subm_cnt_dblks=0 incr=4 _wr_subm_cnt_dblks=0) (BdbMessageStore.cpp:840)" This
was a case of non-tx recovery from a journal whose last record exactly coincided with eof
and has no outstanding enqueued records (ie nothing to read). Fixed by adjusting
initialization parameters for this case.
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/jcntl.cpp 2008-09-12 14:28:30 UTC (rev 2457)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/jcntl.cpp 2008-09-12 14:46:21 UTC (rev 2458)
@@ -190,7 +190,7 @@
rcvr_janalyze(_rcvdat, prep_txn_list_ptr);
highest_rid = _rcvdat._h_rid;
- if (_rcvdat._full)
+ if (_rcvdat._jfull)
throw jexception(jerrno::JERR_JCNTL_RECOVERJFULL, "jcntl",
"recover");
this->log(LOG_DEBUG, _rcvdat.to_log(_jid));
@@ -213,7 +213,7 @@
_rrfc.initialize(_num_jfiles, (nlfh**)_datafh, &_rcvdat);
_rmgr.initialize(rd_cb);
_wmgr.initialize(wr_cb, wcache_pgsize_sblks, wcache_num_pages, JRNL_WMGR_MAXDTOKPP,
- JRNL_WMGR_MAXWAITUS, _rcvdat._eo);
+ JRNL_WMGR_MAXWAITUS, (_rcvdat._lffull ? 0 : _rcvdat._eo));
_readonly_flag = true;
_init_flag = true;
@@ -328,7 +328,9 @@
if (res == RHM_IORES_RCINVALID)
{
get_wr_events(); // check for outstanding write events
- _rmgr.synchronize();
+ iores sres = _rmgr.synchronize();
+ if (sres != RHM_IORES_SUCCESS)
+ return sres;
if (cnt > 0)
::usleep(RCINVALID_SLEEP_TIME_MS * 1000);
}
@@ -614,7 +616,7 @@
rd._lfid = ji.get_end_file();
rd._owi = ji.get_initial_owi();
rd._frot = ji.get_frot();
- rd._empty = false;
+ rd._jempty = false;
}
catch (const jexception& e)
{
@@ -622,14 +624,14 @@
}
// Restore all read and write pointers and transactions
- if (!rd._empty)
+ if (!rd._jempty)
{
u_int16_t fid = rd._ffid;
std::ifstream ifs;
bool lowi = rd._owi; // local copy of owi to be used during analysis
while (rcvr_get_next_record(fid, &ifs, lowi, rd)) ;
- if (!rd._empty && prep_txn_list_ptr)
+ if (prep_txn_list_ptr)
{
std::vector<std::string> xid_list;
_tmap.xid_list(xid_list);
@@ -651,10 +653,12 @@
}
}
+ // Check for file full condition - add one to _jfsize_sblks to account for file
header
+ rd._lffull = rd._eo == (1 + _jfsize_sblks) * JRNL_SBLK_SIZE * JRNL_DBLK_SIZE;
+
// Check for journal full condition
u_int16_t next_wr_fid = (rd._lfid + 1) % _num_jfiles;
- if (rd._ffid == next_wr_fid && rd._enq_cnt_list[next_wr_fid])
- rd._full = true;
+ rd._jfull = rd._ffid == next_wr_fid && rd._enq_cnt_list[next_wr_fid];
}
}
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/nlfh.cpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/nlfh.cpp 2008-09-12 14:28:30 UTC (rev 2457)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/nlfh.cpp 2008-09-12 14:46:21 UTC (rev 2458)
@@ -107,7 +107,7 @@
#endif
if (ro) // Recovery initialization: set counters only
{
- if (!ro->_empty)
+ if (!ro->_jempty)
{
// For last file only, set write counters to end of last record (the
// continuation point); for all others, set to eof.
@@ -151,7 +151,7 @@
{
if (ro)
{
- if (!ro->_empty)
+ if (!ro->_jempty)
{
if (ro->_lfid == _fid)
{
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/rcvdat.hpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/rcvdat.hpp 2008-09-12 14:28:30 UTC (rev 2457)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/rcvdat.hpp 2008-09-12 14:46:21 UTC (rev 2458)
@@ -49,39 +49,42 @@
{
bool _owi; ///< Overwrite indicator
bool _frot; ///< First rotation flag
- bool _empty; ///< Journal data files empty
+ bool _jempty; ///< Journal data files empty
u_int16_t _ffid; ///< First file id
std::size_t _fro; ///< First record offset in ffid
u_int16_t _lfid; ///< Last file id
std::size_t _eo; ///< End offset (first byte past last record)
u_int64_t _h_rid; ///< Highest rid found
- bool _full; ///< Journal is full
+ bool _lffull; ///< last file is full
+ bool _jfull; ///< Journal is full
std::vector<u_int32_t> _enq_cnt_list; ///< Number enqueued records
found for each file
rcvdat():
_owi(false),
_frot(false),
- _empty(true),
+ _jempty(true),
_ffid(0),
_fro(0),
_lfid(0),
_eo(0),
_h_rid(0),
- _full(false),
+ _lffull(false),
+ _jfull(false),
_enq_cnt_list()
{}
void reset(u_int16_t num_jfiles)
{
- _owi=false;
+ _owi = false;
_frot = false;
- _empty=true;
- _ffid=0;
- _fro=0;
- _lfid=0;
- _eo=0;
- _h_rid=0;
- _full = false;
+ _jempty = true;
+ _ffid = 0;
+ _fro = 0;
+ _lfid = 0;
+ _eo = 0;
+ _h_rid = 0;
+ _lffull = false;
+ _jfull = false;
_enq_cnt_list.clear();
_enq_cnt_list.resize(num_jfiles, 0);
}
@@ -92,7 +95,7 @@
oss << "Recover file analysis (jid=\"" << jid
<< "\"):" << std::endl;
oss << " Overwrite indicator (_owi) = " << (_owi ?
"TRUE" : "FALSE") << std::endl;
oss << " First rotation (_frot) = " << (_frot ?
"TRUE" : "FALSE") << std::endl;
- oss << " Journal empty (_empty) = " << (_empty ?
"TRUE" : "FALSE") << std::endl;
+ oss << " Journal empty (_jempty) = " << (_jempty ?
"TRUE" : "FALSE") << std::endl;
oss << " First fid (_ffid) = " << _ffid <<
std::endl;
oss << " First record offset in first fid (_fro) = 0x"
<< std::hex << _fro <<
std::dec << " (" << (_fro/JRNL_DBLK_SIZE)
<< " dblks)" << std::endl;
@@ -100,7 +103,8 @@
oss << " End offset (_eo) = 0x" << std::hex
<< _eo << std::dec << " (" <<
(_eo/JRNL_DBLK_SIZE) << " dblks)" <<
std::endl;
oss << " Highest rid (_h_rid) = 0x" << std::hex
<< _h_rid << std::dec << std::endl;
- oss << " Journal full (_full) = " << (_full ?
"TRUE" : "FALSE") << std::endl;
+ oss << " Last file full (_lffull) = " << (_lffull
? "TRUE" : "FALSE") << std::endl;
+ oss << " Journal full (_jfull) = " << (_jfull ?
"TRUE" : "FALSE") << std::endl;
oss << " Enqueued records (txn & non-txn):" <<
std::endl;
for (unsigned i=0; i<_enq_cnt_list.size(); i++)
oss << " File " << std::setw(2) << i
<< ": " << _enq_cnt_list[i] <<
@@ -112,9 +116,9 @@
{
std::ostringstream oss;
oss << "Recover file analysis (jid=\"" << jid
<< "\"):";
- oss << " owi=" << (_owi ? "TRUE" :
"FALSE");
- oss << " frot=" << (_frot ? "TRUE" :
"FALSE");
- oss << " empty=" << (_empty ? "TRUE" :
"FALSE");
+ oss << " owi=" << (_owi ? "T" :
"F");
+ oss << " frot=" << (_frot ? "T" :
"F");
+ oss << " jempty=" << (_jempty ? "T" :
"F");
oss << " ffid=" << _ffid;
oss << " fro=0x" << std::hex << _fro <<
std::dec << " (" <<
(_fro/JRNL_DBLK_SIZE) << " dblks)";
@@ -122,7 +126,8 @@
oss << " eo=0x" << std::hex << _eo <<
std::dec << " (" <<
(_eo/JRNL_DBLK_SIZE) << " dblks)";
oss << " h_rid=0x" << std::hex << _h_rid
<< std::dec;
- oss << " full=" << (_full ? "TRUE" :
"FALSE");
+ oss << " lffull=" << (_lffull ? "T" :
"F");
+ oss << " jfull=" << (_jfull ? "T" :
"F");
oss << " Enqueued records (txn & non-txn): [ ";
for (unsigned i=0; i<_enq_cnt_list.size(); i++)
{
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.cpp 2008-09-12 14:28:30 UTC (rev 2457)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.cpp 2008-09-12 14:46:21 UTC (rev 2458)
@@ -526,7 +526,7 @@
}
}
-void
+iores
rmgr::aio_cycle()
{
int16_t first_uninit = -1;
@@ -552,17 +552,19 @@
default:;
}
}
+ iores res = RHM_IORES_SUCCESS;
if (num_uninit)
- init_aio_reads(first_uninit, num_uninit);
+ res = init_aio_reads(first_uninit, num_uninit);
if (outstanding)
get_events();
+ return res;
}
-void
+iores
rmgr::init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit)
{
if (_fhdr_rd_outstanding)
- return;
+ return RHM_IORES_SUCCESS;
for (int16_t i=0; i<num_uninit; i++)
{
if (_rrfc.is_void()) // Nothing to do; this file not yet written to
@@ -571,6 +573,9 @@
if (!_valid)
{
u_int16_t fid = _jc->get_earliest_fid();
+ // If this file has not yet been written to, return RHM_IORES_EMPTY
+ if (_rrfc.file_handle(fid)->rd_void())
+ return RHM_IORES_EMPTY;
init_file_header_read(fid);
break;
}
@@ -607,6 +612,7 @@
if (_rrfc.file_rotate())
_rrfc.rotate();
}
+ return RHM_IORES_SUCCESS;
}
void
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.hpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.hpp 2008-09-12 14:28:30 UTC (rev 2457)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/rmgr.hpp 2008-09-12 14:46:21 UTC (rev 2458)
@@ -82,7 +82,7 @@
u_int32_t get_events(page_state state = AIO_COMPLETE);
void recover_complete();
inline bool is_valid() const {return _valid; }
- inline void synchronize() { if (!_valid) aio_cycle(); }
+ inline iores synchronize() { if (!_valid) return aio_cycle(); return
RHM_IORES_SUCCESS; }
void invalidate();
/* TODO (if required)
@@ -99,8 +99,8 @@
void consume_xid_rec(rec_hdr& h, void* rptr, data_tok* dtokp);
void consume_filler();
iores skip(data_tok* dtokp);
- void aio_cycle();
- void init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit);
+ iores aio_cycle();
+ iores init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit);
void consume_fhdr();
void rotate_page();
u_int32_t dblks_rem() const;
Modified: store/branches/mrg-1.0/cpp/lib/jrnl/wrfc.cpp
===================================================================
--- store/branches/mrg-1.0/cpp/lib/jrnl/wrfc.cpp 2008-09-12 14:28:30 UTC (rev 2457)
+++ store/branches/mrg-1.0/cpp/lib/jrnl/wrfc.cpp 2008-09-12 14:46:21 UTC (rev 2458)
@@ -71,7 +71,7 @@
_reset_ok = true;
_owi = rdp->_owi;
_frot = rdp->_frot;
- if (is_full())
+ if (rdp->_lffull)
rotate();
}
else