Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/jrd/cch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,11 @@ void CCH_mark(thread_db* tdbb, WIN* window, bool mark_system, bool must_write)

fb_assert(bdb->ourIOLock());

// A page changed by a regular (non-merge) operation must be written into the
// difference file again, even if the merge process has previously read it from
// there and marked it with BDB_merge.
bdb->bdb_flags &= ~BDB_merge;

// Allocate difference page (if in stalled mode) before mark page as dirty.
// It guarantees that disk space is allocated and page could be written later.

Expand Down Expand Up @@ -1778,6 +1783,32 @@ void CCH_mark(thread_db* tdbb, WIN* window, bool mark_system, bool must_write)
}


void CCH_mark_merge(thread_db* tdbb, WIN* window)
{
/**************************************
*
* C C H _ m a r k _ m e r g e
*
**************************************
*
* Functional description
* Mark a window as dirty by the difference file merge process.
* The page content is taken from the difference file, so it must
* not be written back into the difference file while merging.
*
**************************************/
BufferDesc* bdb = window->win_bdb;
BLKCHK(bdb, type_bdb);

SET_TDBB(tdbb);

// CCH_mark() clears BDB_merge, so the flag must be set afterwards
CCH_mark(tdbb, window, true, false);

bdb->bdb_flags |= BDB_merge;
}


void CCH_must_write(thread_db* tdbb, WIN* window)
{
/**************************************
Expand Down Expand Up @@ -5008,7 +5039,8 @@ static bool write_page(thread_db* tdbb, BufferDesc* bdb, FbStatusVector* const s

if (!isTempPage &&
(backupState == Ods::hdr_nbak_stalled ||
(backupState == Ods::hdr_nbak_merge && bdb->bdb_difference_page)))
(backupState == Ods::hdr_nbak_merge && bdb->bdb_difference_page &&
!(bdb->bdb_flags & BDB_merge))))
{
if (!dbb->dbb_backup_manager->writeDifference(tdbb, status,
bdb->bdb_difference_page, bdb->bdb_buffer))
Expand Down Expand Up @@ -5113,7 +5145,7 @@ static bool write_page(thread_db* tdbb, BufferDesc* bdb, FbStatusVector* const s
if (!(bdb->bdb_bcb->bcb_flags & BCB_keep_pages))
removeDirty(bdb->bdb_bcb, bdb);

bdb->bdb_flags &= ~(BDB_must_write | BDB_system_dirty);
bdb->bdb_flags &= ~(BDB_must_write | BDB_system_dirty | BDB_merge);
clear_dirty_flag_and_nbak_state(tdbb, bdb);

if (bdb->bdb_flags & BDB_io_error)
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/cch.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ inline constexpr int BDB_writer = 0x0004; // someone is updating the page
inline constexpr int BDB_marked = 0x0008; // page has been updated
inline constexpr int BDB_must_write = 0x0010; // forces a write as soon as the page is released
inline constexpr int BDB_faked = 0x0020; // page was just allocated
//inline constexpr int BDB_merge = 0x0040;
inline constexpr int BDB_merge = 0x0040; // read from delta by merge and must not go back into it
inline constexpr int BDB_system_dirty = 0x0080; // system transaction has marked dirty
inline constexpr int BDB_io_error = 0x0100; // page i/o error
inline constexpr int BDB_read_pending = 0x0200; // read is pending
Expand Down
27 changes: 9 additions & 18 deletions src/jrd/cch_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Ods::pag* CCH_handoff(Jrd::thread_db*, Jrd::win*, Jrd::PageNumber, int, SCHAR, i
void CCH_init(Jrd::thread_db*, ULONG);
void CCH_init2(Jrd::thread_db*);
void CCH_mark(Jrd::thread_db*, Jrd::win*, bool, bool);
void CCH_mark_merge(Jrd::thread_db*, Jrd::win*);
void CCH_must_write(Jrd::thread_db*, Jrd::win*);
void CCH_precedence(Jrd::thread_db*, Jrd::win*, ULONG);
void CCH_precedence(Jrd::thread_db*, Jrd::win*, Jrd::PageNumber);
Expand Down Expand Up @@ -107,12 +108,17 @@ inline void CCH_RELEASE_TAIL(Jrd::thread_db* tdbb, Jrd::win* window)

inline void CCH_MARK(Jrd::thread_db* tdbb, Jrd::win* window)
{
CCH_mark (tdbb, window, 0, 0);
CCH_mark (tdbb, window, false, false);
}

inline void CCH_MARK_SYSTEM(Jrd::thread_db* tdbb, Jrd::win* window)
{
CCH_mark (tdbb, window, 1, 0);
CCH_mark (tdbb, window, true, false);
}

inline void CCH_MARK_MERGE(Jrd::thread_db* tdbb, Jrd::win* window)
{
CCH_mark_merge (tdbb, window);
}

inline Ods::pag* CCH_HANDOFF(Jrd::thread_db* tdbb, Jrd::win* window, ULONG page, SSHORT lock, SCHAR page_type)
Expand All @@ -137,7 +143,7 @@ inline Ods::pag* CCH_HANDOFF(Jrd::thread_db* tdbb, Jrd::win* window, Jrd::PageNu

inline void CCH_MARK_MUST_WRITE(Jrd::thread_db* tdbb, Jrd::win* window)
{
CCH_mark(tdbb, window, 0, 1);
CCH_mark(tdbb, window, false, true);
}

#ifdef SUPERSERVER_V2
Expand All @@ -147,21 +153,6 @@ inline void CCH_PREFETCH(Jrd::thread_db* tdbb, SLONG* pages, SSHORT count)
}
#endif

//#define CCH_FETCH(tdbb, window, lock, type) CCH_fetch (tdbb, window, lock, type, 1, true)
//#define CCH_FETCH_NO_SHADOW(tdbb, window, lock, type) CCH_fetch (tdbb, window, lock, type, 1, false)
//#define CCH_FETCH_TIMEOUT(tdbb, window, lock, type, latch_wait) CCH_fetch (tdbb, window, lock, type, latch_wait, true)
//#define CCH_FETCH_LOCK(tdbb, window, lock, wait, type) CCH_fetch_lock (tdbb, window, lock, wait, type)
//#define CCH_FETCH_PAGE(tdbb, window, read_shadow) CCH_fetch_page (tdbb, window, read_shadow)
//#define CCH_RELEASE(tdbb, window) CCH_release (tdbb, window, false)
//#define CCH_RELEASE_TAIL(tdbb, window) CCH_release (tdbb, window, true)
//#define CCH_MARK(tdbb, window) CCH_mark (tdbb, window, 0)
//#define CCH_MARK_SYSTEM(tdbb, window) CCH_mark (tdbb, window, 1)
//#define CCH_HANDOFF(tdbb, window, page, lock, type) CCH_handoff (tdbb, window, page, lock, type, 1, false)
//#define CCH_HANDOFF_TIMEOUT(tdbb, window, page, lock, type, latch_wait) CCH_handoff (tdbb, window, page, lock, type, latch_wait, false)
//#define CCH_HANDOFF_TAIL(tdbb, window, page, lock, type) CCH_handoff (tdbb, window, page, lock, type, 1, true)
//#define CCH_MARK_MUST_WRITE(tdbb, window) CCH_mark_must_write (tdbb, window)
//#define CCH_PREFETCH(tdbb, pages, count) CCH_prefetch (tdbb, pages, count)

// Flush flags

inline constexpr USHORT FLUSH_ALL = 1; // flush all dirty buffers in cache
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/nbak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ void BackupManager::endBackup(thread_db* tdbb, bool recover)
NBAK_TRACE(("Merge: page %d is fetched", all.current().db_page));
if (page->pag_scn != current_scn)
{
CCH_MARK_SYSTEM(tdbb, &window2);
CCH_MARK_MERGE(tdbb, &window2);
NBAK_TRACE(("Merge: page %d is marked", all.current().db_page));
}
CCH_RELEASE(tdbb, &window2);
Expand Down