Below is the list of changes that have just been committed into a local
5.1-ndb repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1863 05/04/20 11:59:56 joreland@stripped +4 -0
wl1870 - ndb diskdata
fix bugs in undo traversing
ndb/src/kernel/blocks/print_file.cpp
1.5 05/04/20 11:59:52 joreland@stripped +3 -2
Fix undo page printer
ndb/src/kernel/blocks/lgman.hpp
1.27 05/04/20 11:59:52 joreland@stripped +1 -1
Return lsn for undo record
ndb/src/kernel/blocks/lgman.cpp
1.34 05/04/20 11:59:52 joreland@stripped +59 -68
1) Fix size on UNDO_LCP record
incl. handling of UNDO_NEXT_LSN
2) Fix bug in undo-log traversing
ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
1.71 05/04/20 11:59:52 joreland@stripped +0 -1
remove debug printout
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: joreland
# Host: eel.hemma.oreland.se.ndb.mysql.com
# Root: /home/jonas/src/mysql-5.1-ndb-dd
--- 1.33/ndb/src/kernel/blocks/lgman.cpp Tue Apr 19 15:21:45 2005
+++ 1.34/ndb/src/kernel/blocks/lgman.cpp Wed Apr 20 11:59:52 2005
@@ -1063,13 +1063,27 @@
Uint32 undo[3];
undo[0] = lcp_id;
undo[1] = table_id << 16 | frag_id;
- undo[2] = File_formats::Undofile::UNDO_LCP << 16 | sizeof(undo);
+ undo[2] = File_formats::Undofile::UNDO_LCP << 16 | (sizeof(undo) >> 2);
+ Uint64 last_lsn= m_last_lsn;
while(!ptr.isNull())
{
- Uint32 *dst= get_log_buffer(ptr, sizeof(undo) >> 2);
- memcpy(dst, undo, sizeof(undo));
-
+ Uint64 last_lsn_filegroup= ptr.p->m_last_lsn;
+ if(last_lsn_filegroup == last_lsn)
+ {
+ Uint32 *dst= get_log_buffer(ptr, sizeof(undo) >> 2);
+ memcpy(dst, undo, sizeof(undo));
+ * (dst + (sizeof(undo) >> 2) - 1) |= File_formats::Undofile::UNDO_NEXT_LSN << 16;
+ }
+ else
+ {
+ Uint32 *dst= get_log_buffer(ptr, (sizeof(undo) >> 2) + 2);
+ * dst++ = last_lsn >> 32;
+ * dst++ = last_lsn & 0xFFFFFFFF;
+ memcpy(dst, undo, sizeof(undo));
+ }
+ last_lsn = ptr.p->m_last_lsn = last_lsn + 1;
+
/**
* First LCP_FRAGORD for each LCP, sets tail pos
*/
@@ -1091,6 +1105,7 @@
m_logfile_group_list.next(ptr);
}
+ m_last_lsn = last_lsn;
m_latest_lcp = lcp_id;
}
@@ -1607,47 +1622,26 @@
/**
* Init buffer pointers
*/
- Lgman::Page_map::Iterator it;
- Page_map map(m_data_buffer_pool, ptr.p->m_buffer_pages);
ptr.p->m_free_buffer_words -= File_formats::UNDO_PAGE_WORDS;
ptr.p->m_pos[CONSUMER].m_current_page.m_idx = 0; // 0 more pages read
- Uint32 idx=
- ptr.p->m_pos[PRODUCER].m_current_page.m_ptr_i = map.getSize()-2;
- map.position(it, idx);
-
- union {
- Uint32 _tmp[2];
- Lgman::Buffer_idx range;
- };
- _tmp[0] = *it.data; map.next(it); _tmp[1] = *it.data;
-
- if(idx == ptr.p->m_pos[CONSUMER].m_current_page.m_ptr_i)
- {
- ndbassert(map.getSize() == 2);
- /**
- * Only 1 page_range
- */
- range.m_idx --;
- range.m_ptr_i ++;
- }
- ptr.p->m_pos[PRODUCER].m_current_pos.m_ptr_i= range.m_ptr_i+ range.m_idx;
- ptr.p->m_pos[PRODUCER].m_current_page.m_idx = range.m_idx;
+ ptr.p->m_pos[PRODUCER].m_current_page.m_idx = 0; // 0 more pages read
Uint32 page = ptr.p->m_pos[CONSUMER].m_current_pos.m_ptr_i;
File_formats::Undofile::Undo_page* pageP =
(File_formats::Undofile::Undo_page*)m_global_page_pool.getPtr(page);
ptr.p->m_pos[CONSUMER].m_current_pos.m_idx = pageP->m_words_used;
- ptr.p->m_pos[PRODUCER].m_current_pos.m_idx = pageP->m_words_used;
+ ptr.p->m_pos[PRODUCER].m_current_pos.m_idx =
+ File_formats::UNDO_PAGE_WORDS;
}
/**
- * Start consumer thread
+ * Start producer thread
*/
signal->theData[0] = LgmanContinueB::READ_UNDO_LOG;
signal->theData[1] = ptr.i;
sendSignal(reference(), GSN_CONTINUEB, signal, 2, JBB);
-
+
/**
* Insert in correct postion in list of logfile_group's
*/
@@ -1672,7 +1666,6 @@
Uint32 cnt, free= ptr.p->m_free_buffer_words;
if(free <= File_formats::UNDO_PAGE_WORDS)
{
- ndbout_c("free: %d", free);
signal->theData[0] = LgmanContinueB::READ_UNDO_LOG;
signal->theData[1] = ptr.i;
sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 2);
@@ -1682,18 +1675,37 @@
Logfile_group::Position producer= ptr.p->m_pos[PRODUCER];
Logfile_group::Position consumer= ptr.p->m_pos[CONSUMER];
+ if(producer.m_current_page.m_idx == 0)
+ {
+ /**
+ * zero pages left in range -> switch range
+ */
+ Lgman::Page_map::Iterator it;
+ Page_map map(m_data_buffer_pool, ptr.p->m_buffer_pages);
+ Uint32 sz = map.getSize();
+ Uint32 pos= (producer.m_current_page.m_ptr_i + sz - 2) % sz;
+ map.position(it, pos);
+ union {
+ Uint32 _tmp[2];
+ Lgman::Buffer_idx range;
+ };
+ _tmp[0] = *it.data; map.next(it); _tmp[1] = *it.data;
+ producer.m_current_page.m_ptr_i = pos;
+ producer.m_current_page.m_idx = range.m_idx;
+ producer.m_current_pos.m_ptr_i = range.m_ptr_i + range.m_idx;
+ }
+
if(producer.m_current_page.m_ptr_i == consumer.m_current_page.m_ptr_i &&
producer.m_current_pos.m_ptr_i > consumer.m_current_pos.m_ptr_i)
{
Uint32 max=
producer.m_current_pos.m_ptr_i - consumer.m_current_pos.m_ptr_i - 1;
ndbassert(free >= max * File_formats::UNDO_PAGE_WORDS);
-
cnt= read_undo_pages(signal, ptr, producer.m_current_pos.m_ptr_i, max);
ndbassert(cnt <= max);
producer.m_current_pos.m_ptr_i -= cnt;
producer.m_current_page.m_idx -= cnt;
- }
+ }
else
{
Uint32 max= producer.m_current_page.m_idx;
@@ -1702,27 +1714,10 @@
ndbassert(cnt <= max);
producer.m_current_pos.m_ptr_i -= cnt;
producer.m_current_page.m_idx -= cnt;
- if(cnt == max)
- {
- // Switch range
- Lgman::Page_map::Iterator it;
- Page_map map(m_data_buffer_pool, ptr.p->m_buffer_pages);
- Uint32 sz = map.getSize();
- Uint32 pos= (producer.m_current_page.m_ptr_i + sz - 2) % sz;
- map.position(it, pos);
- union {
- Uint32 _tmp[2];
- Lgman::Buffer_idx range;
- };
-
- _tmp[0] = *it.data; map.next(it); _tmp[1] = *it.data;
- producer.m_current_page.m_ptr_i = pos;
- producer.m_current_page.m_idx = range.m_idx;
- producer.m_current_pos.m_ptr_i = range.m_ptr_i;
- }
}
- free -= cnt *= File_formats::UNDO_PAGE_WORDS;
+ ndbassert(free >= cnt * File_formats::UNDO_PAGE_WORDS);
+ free -= (cnt * File_formats::UNDO_PAGE_WORDS);
ptr.p->m_free_buffer_words = free;
ptr.p->m_pos[PRODUCER] = producer;
@@ -1739,6 +1734,7 @@
Lgman::read_undo_pages(Signal* signal, Ptr<Logfile_group> ptr,
Uint32 pageId, Uint32 pages)
{
+ ndbassert(pages);
Ptr<Undofile> filePtr;
Buffer_idx tail= ptr.p->m_file_pos[TAIL];
m_file_pool.getPtr(filePtr, tail.m_ptr_i);
@@ -1764,8 +1760,6 @@
jam();
tail.m_idx -= pages;
- ndbout_c("reading %d pages from %d (fileSize: %d)",
- pages, 1+tail.m_idx, filePtr.p->m_file_size);
req->varIndex = 1 + tail.m_idx;
req->numberOfPages = pages;
req->data.pageData[0] = pageId - pages;
@@ -1785,9 +1779,6 @@
req->varIndex = 1;
req->numberOfPages = max;
req->data.pageData[0] = pageId - max;
-
- ndbout_c("reading %d pages from %d (fileSize: %d)",
- max, 1, filePtr.p->m_file_size);
sendSignal(NDBFS_REF, GSN_FSREADREQ, signal,
FsReadWriteReq::FixedLength + 1, JBA);
@@ -1818,13 +1809,14 @@
Lgman::execute_undo_record(Signal* signal)
{
const Uint32* ptr;
- if((ptr = get_next_undo_record()))
+ Uint64 lsn;
+ if((ptr = get_next_undo_record(&lsn)))
{
Uint32 len= (* ptr) & 0xFFFF;
Uint32 type= (* ptr) >> 16;
switch(type){
default:
- ndbout_c("Found undo: %d len: %d", type & 0x7FFF, len);
+ (void)1; //ndbout_c("Found undo: %d len: %d lsn: %lld", type & 0x7FFF, len, lsn);
}
}
@@ -1834,17 +1826,16 @@
}
const Uint32*
-Lgman::get_next_undo_record()
+Lgman::get_next_undo_record(Uint64 * this_lsn)
{
Ptr<Logfile_group> ptr;
m_logfile_group_list.first(ptr);
Logfile_group::Position consumer= ptr.p->m_pos[CONSUMER];
Logfile_group::Position producer= ptr.p->m_pos[PRODUCER];
- if(producer.m_current_pos.m_idx < File_formats::UNDO_PAGE_WORDS + 1)
+ if(producer.m_current_pos.m_idx < 2 * File_formats::UNDO_PAGE_WORDS)
{
jam();
- //ndbout_c("waiting for fetch");
/**
* Wait for fetching pages...
*/
@@ -1861,16 +1852,15 @@
Uint32 *record= pageP->m_data + pos - 1;
Uint32 len= (* record) & 0xFFFF;
ndbassert(len);
-
ndbassert(pos >= len);
- pos -= len;
ndbassert(producer.m_current_pos.m_idx > len);
- producer.m_current_pos.m_idx -= len;
+ ptr.p->m_pos[PRODUCER].m_current_pos.m_idx =
+ producer.m_current_pos.m_idx - len;
Uint32 *prev= record - len;
Uint64 lsn = 0;
- if(pos == 0)
+ if(pos == len)
{
/**
* Switching page
@@ -1918,6 +1908,7 @@
if(pos == 0)
ndbout_c("FOUND EMPTY PAGE");
ptr.p->m_pos[CONSUMER] = consumer;
+ ptr.p->m_free_buffer_words += File_formats::UNDO_PAGE_WORDS;
}
else
{
@@ -1936,8 +1927,8 @@
ptr.p->m_pos[CONSUMER].m_current_pos.m_idx -= len;
}
- ptr.p->m_last_read_lsn = lsn;
-
+ * this_lsn = ptr.p->m_last_read_lsn = lsn;
+
/**
* Re-sort log file groups
*/
--- 1.26/ndb/src/kernel/blocks/lgman.hpp Tue Apr 19 15:21:45 2005
+++ 1.27/ndb/src/kernel/blocks/lgman.hpp Wed Apr 20 11:59:52 2005
@@ -232,7 +232,7 @@
Uint32 pageId, Uint32 pages);
void execute_undo_record(Signal*);
- const Uint32* get_next_undo_record();
+ const Uint32* get_next_undo_record(Uint64* lsn);
};
class Logfile_client {
--- 1.4/ndb/src/kernel/blocks/print_file.cpp Tue Apr 19 15:21:45 2005
+++ 1.5/ndb/src/kernel/blocks/print_file.cpp Wed Apr 20 11:59:52 2005
@@ -264,13 +264,14 @@
printf("[ NOOP %d ]", len);
break;
case File_formats::Undofile::UNDO_LCP:
- printf("[ %lld LCP %d ]", lsn, page->m_data[pos-1]);
+ printf("[ %lld LCP %d tab: %d frag: %d ]", lsn,
+ src[0], src[1] >> 16, src[1] & 0xFFFF);
break;
case File_formats::Undofile::UNDO_TUP_ALLOC:
if(g_verbosity > 3)
{
Dbtup::Disk_undo::Alloc *req= (Dbtup::Disk_undo::Alloc*)src;
- printf("[ %%d A %d %d %d ]",
+ printf("[ %lld A %d %d %d ]",
lsn,
req->m_file_no_page_idx >> 16,
req->m_file_no_page_idx & 0xFFFF,
--- 1.70/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp Tue Apr 19 15:23:02 2005
+++ 1.71/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp Wed Apr 20 11:59:52 2005
@@ -1317,7 +1317,6 @@
tabPtr.i = addfragptr.p->tabId;
ptrCheckGuard(tabPtr, ctabrecFileSize, tablerec);
tabPtr.p->m_disk_table = 1;
- ndbout_c("disk based");
}
}//for
addfragptr.p->attrSentToTup = 0;
| Thread |
|---|
| • bk commit into 5.1-ndb tree (joreland:1.1863) | jonas.oreland | 20 Apr |