From 809e31f8cf7d870a061d4ffe804ecadacda920a8 Mon Sep 17 00:00:00 2001
From: unknown <jonas@perch.ndb.mysql.com>
Date: Thu, 4 May 2006 16:01:37 +0200
Subject: [PATCH] ndb dd - Fix bug where page is read, modified and then
 transaction abort   and then puge is flushed causing lsn on page to be 0

storage/ndb/src/kernel/blocks/pgman.cpp:
  Fix bug where page is read, modified and then transaction abort
    and then puge is flushed causing lsn on page to be 0
---
 storage/ndb/src/kernel/blocks/pgman.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/storage/ndb/src/kernel/blocks/pgman.cpp b/storage/ndb/src/kernel/blocks/pgman.cpp
index 1e28fad92a..75a63f9d76 100644
--- a/storage/ndb/src/kernel/blocks/pgman.cpp
+++ b/storage/ndb/src/kernel/blocks/pgman.cpp
@@ -1330,6 +1330,24 @@ Pgman::fsreadconf(Signal* signal, Ptr<Page_entry> ptr)
   state |= Page_entry::MAPPED;
   set_page_state(ptr, state);
 
+  {
+    /**
+     * Update lsn record on page
+     *   as it can be modified/flushed wo/ update_lsn has been called
+     *   (e.g. prealloc) and it then would get lsn 0, which is bad
+     *   when running undo and following SR
+     */
+    Ptr<GlobalPage> pagePtr;
+    m_global_page_pool.getPtr(pagePtr, ptr.p->m_real_page_i);
+    File_formats::Datafile::Data_page* page =
+      (File_formats::Datafile::Data_page*)pagePtr.p;
+    
+    Uint64 lsn = 0;
+    lsn += page->m_page_header.m_page_lsn_hi; lsn <<= 32;
+    lsn += page->m_page_header.m_page_lsn_lo;
+    ptr.p->m_lsn = lsn;
+  }
+  
   ndbrequire(m_stats.m_current_io_waits > 0);
   m_stats.m_current_io_waits--;
 
-- 
2.30.9