Skip to content

Commit a4b29b1

Browse files
author
Mikael Ronström
committed
BUG#20727343: Fix problems in UNDO log applier when changing log files
1 parent c8b32bb commit a4b29b1

File tree

9 files changed

+1195
-185
lines changed

9 files changed

+1195
-185
lines changed

storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16632,6 +16632,12 @@ Dblqh::execFSWRITEREQ(Signal* signal)
1663216632
/**
1663316633
* This is currently run in other thread -> no jam
1663416634
* and no global variables
16635+
*
16636+
* This method is called from NDB file system while initialising a REDO log
16637+
* file, so we need to ensure that we don't touch any block variables other
16638+
* than to read stable variables. This is only called during initial
16639+
* restart. The pages are allocated by NDBFS from DataMemory, so these can
16640+
* be written to safely since they are owned by the file system thread.
1663516641
*/
1663616642
Ptr<GlobalPage> page_ptr;
1663716643
FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtr();

storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,7 @@ struct TupHeadInfo {
33203320
Dbtup::Apply_undo f_undo;
33213321
Uint32 c_proxy_undo_data[20 + MAX_TUPLE_SIZE_IN_WORDS];
33223322

3323-
void disk_restart_undo_next(Signal*);
3323+
void disk_restart_undo_next(Signal*, Uint32 applied = 0);
33243324
void disk_restart_undo_lcp(Uint32, Uint32, Uint32 flag, Uint32 lcpId);
33253325
void disk_restart_undo_callback(Signal* signal, Uint32, Uint32);
33263326
void disk_restart_undo_alloc(Apply_undo*);

storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -22,10 +22,12 @@
2222
#include <ndb_limits.h>
2323
#include <pc.hpp>
2424
#include <signaldata/TupCommit.hpp>
25+
#include <EventLogger.hpp>
2526
#include "../dblqh/Dblqh.hpp"
2627

2728
#define JAM_FILE_ID 416
2829

30+
extern EventLogger *g_eventLogger;
2931

3032
void Dbtup::execTUP_DEALLOCREQ(Signal* signal)
3133
{
@@ -633,6 +635,8 @@ int Dbtup::retrieve_log_page(Signal *signal,
633635
signal->theData[0] = 1;
634636
return res;
635637
case -1:
638+
g_eventLogger->warning("Out of space in RG_DISK_OPERATIONS resource,"
639+
" increase config parameter GlobalSharedMemory");
636640
ndbrequire("NOT YET IMPLEMENTED" == 0);
637641
break;
638642
default:

storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@ Dbtup::disk_page_prealloc(Signal* signal,
603603
case 0:
604604
break;
605605
case -1:
606+
g_eventLogger->warning("Out of space in RG_DISK_OPERATIONS"
607+
" resource, increase config parameter"
608+
" GlobalSharedMemory");
606609
ndbrequire("NOT YET IMPLEMENTED" == 0);
607610
break;
608611
default:
@@ -1619,10 +1622,12 @@ Dbtup::disk_restart_undo(Signal* signal, Uint64 lsn,
16191622
}
16201623

16211624
void
1622-
Dbtup::disk_restart_undo_next(Signal* signal)
1625+
Dbtup::disk_restart_undo_next(Signal* signal, Uint32 applied)
16231626
{
16241627
signal->theData[0] = LgmanContinueB::EXECUTE_UNDO_RECORD;
1625-
sendSignal(LGMAN_REF, GSN_CONTINUEB, signal, 1, JBB);
1628+
/* Flag indicating whether UNDO log was applied. */
1629+
signal->theData[1] = applied;
1630+
sendSignal(LGMAN_REF, GSN_CONTINUEB, signal, 2, JBB);
16261631
}
16271632

16281633
void
@@ -1773,6 +1778,7 @@ Dbtup::disk_restart_undo_callback(Signal* signal,
17731778
// key.m_file_no = pagePtr.p->m_file_no;
17741779

17751780
Uint64 lsn = 0;
1781+
Uint32 applied = 0;
17761782
lsn += pagePtr.p->m_page_header.m_page_lsn_hi; lsn <<= 32;
17771783
lsn += pagePtr.p->m_page_header.m_page_lsn_lo;
17781784

@@ -1788,6 +1794,7 @@ Dbtup::disk_restart_undo_callback(Signal* signal,
17881794
}
17891795

17901796
update = true;
1797+
applied = 1;
17911798
if (DBG_UNDO)
17921799
ndbout_c("applying %lld", undo->m_lsn);
17931800
/**
@@ -1830,7 +1837,7 @@ Dbtup::disk_restart_undo_callback(Signal* signal,
18301837
<< " tab: " << tableId << endl;
18311838
}
18321839

1833-
disk_restart_undo_next(signal);
1840+
disk_restart_undo_next(signal, applied);
18341841
}
18351842

18361843
void
@@ -1882,8 +1889,17 @@ Dbtup::disk_restart_undo_free(Apply_undo* undo)
18821889
{
18831890
abort();
18841891
}
1885-
1886-
ndbrequire(idx == undo->m_key.m_page_idx);
1892+
1893+
if (idx != undo->m_key.m_page_idx)
1894+
{
1895+
Uint64 lsn = undo->m_lsn;
1896+
jam();
1897+
jamLine(lsn & 0xFFFF);
1898+
jamLine((lsn >> 16) & 0xFFFF);
1899+
jamLine((lsn >> 32) & 0xFFFF);
1900+
jamLine((lsn >> 48) & 0xFFFF);
1901+
ndbrequire(false);
1902+
}
18871903
const Disk_undo::Free *free = (const Disk_undo::Free*)undo->m_ptr;
18881904
const Uint32* src= free->m_data;
18891905
memcpy(ptr, src, 4 * len);

storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -488,6 +488,8 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal)
488488
signal->theData[0] = 1;
489489
return;
490490
case -1:
491+
g_eventLogger->warning("Out of space in RG_DISK_OPERATIONS resource,"
492+
" increase config parameter GlobalSharedMemory");
491493
ndbrequire("NOT YET IMPLEMENTED" == 0);
492494
break;
493495
}
@@ -2041,6 +2043,8 @@ void Dbtup::releaseFragment(Signal* signal, Uint32 tableId,
20412043
jam();
20422044
return;
20432045
case -1:
2046+
g_eventLogger->warning("Out of space in RG_DISK_OPERATIONS resource,"
2047+
" increase config parameter GlobalSharedMemory");
20442048
warningEvent("Failed to get log buffer for drop table: %u",
20452049
tabPtr.i);
20462050
lgman.free_log_space(sz);
@@ -2194,6 +2198,8 @@ Dbtup::drop_fragment_free_extent(Signal *signal,
21942198
jam();
21952199
return;
21962200
case -1:
2201+
g_eventLogger->warning("Out of space in RG_DISK_OPERATIONS resource,"
2202+
" increase config parameter GlobalSharedMemory");
21972203
ndbrequire("NOT YET IMPLEMENTED" == 0);
21982204
break;
21992205
default:

storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -402,7 +402,8 @@ DbtupProxy::disk_restart_undo_finish(Signal* signal)
402402
if (undo.m_actions & Proxy_undo::SendUndoNext) {
403403
jam();
404404
signal->theData[0] = LgmanContinueB::EXECUTE_UNDO_RECORD;
405-
sendSignal(LGMAN_REF, GSN_CONTINUEB, signal, 1, JBB);
405+
signal->theData[1] = 0; /* Not applied flag */
406+
sendSignal(LGMAN_REF, GSN_CONTINUEB, signal, 2, JBB);
406407
}
407408

408409
if (undo.m_actions & Proxy_undo::NoExecute) {

0 commit comments

Comments
 (0)