Skip to content

Some changes could be lost during the merge of delta file into main database file [CORE3466] #3827

Open

Description

@firebird-automations

Submitted by: @hvlad

When merge is in progress engine writes changes into both delta and main file. This creates additional IO load of course.
Therefore in v2.5 merge process was optimized - when page is read from delta file for merging purposes it is marked (with
BDB_merge flag) and not writed back into delta. It is OK if page not leave the cache until merge done. But there is a scenario
when this optimization is wrong :
a) page is read by merge process and marked by BDB_merge flag
b) page is changed by some user attachment and written into database file only
c) page is evicted from the page cache
d) user attachment going to change that page again
e) page is read from delta, this copy have no changes by (b) !
f) page is changed and written into both database and delta, overwriting changes by (b) in database

Commits: 4a916be d578149

Activity

  1. firebird-automations commented on May 5, 2011

    @firebird-automations
    CollaboratorAuthor
    Modified by: @hvlad

    assignee: Vlad Khorsun [ hvlad ]

  2. firebird-automations commented on May 5, 2011

    @firebird-automations
    CollaboratorAuthor

    Commented by: @hvlad

    Classic is not affected as there is no other activity except of merge itself in the same page cache instance. I.e. there is no user process which could
    change page marked with BDB_merge flag. Note, this optimization not applicable for Classic.

    Solution is to undo such optimization. Another way to avoid double writes could be implemented but not in this ticket.

  3. firebird-automations commented on Jun 15, 2011

    @firebird-automations
    CollaboratorAuthor
    Modified by: @hvlad

    status: Open [ 1 ] => Resolved [ 5 ]

    resolution: Fixed [ 1 ]

    Fix Version: 2.5.1 [ 10333 ]

    Fix Version: 3.0 Alpha 1 [ 10331 ]

  4. firebird-automations commented on Mar 28, 2012

    @firebird-automations
    CollaboratorAuthor
    Modified by: @dyemanov

    security: Developers [ 10012 ] =>

  5. firebird-automations commented on Apr 23, 2013

    @firebird-automations
    CollaboratorAuthor
    Modified by: @pcisar

    status: Resolved [ 5 ] => Closed [ 6 ]

  6. firebird-automations commented on Jul 15, 2015

    @firebird-automations
    CollaboratorAuthor
    Modified by: @pavel-zotov

    status: Closed [ 6 ] => Closed [ 6 ]

    QA Status: Cannot be tested

  7. romansimakov commented on Aug 11, 2023

    @romansimakov
    Contributor

    What if just clear BDB_merge in CCH_MARK?

  8. hvlad commented on Aug 12, 2023

    @hvlad
    Member

    Hmm... looks like good idea

  9. hvlad commented on Aug 13, 2023

    @hvlad
    Member

    May I ask you to not restore old code as is - instead of add new argument into CCH_fetch_page() (and all callers), consider CCH_mark_merge() or something like it.

  10. romansimakov commented on Aug 13, 2023

    @romansimakov
    Contributor

    I thought about the same. I'll try to minimize changes.

  11. mrotteveel commented on Oct 14, 2026

    @mrotteveel
    Member

    @hvlad This issue is still open, but is marked as fixed in 2.5.1. Given the subsequent discussion, what is it's real status? Or can it just be closed?

  12. hvlad commented on Oct 14, 2026

    @hvlad
    Member

    Hmm... I see in history it was closed many years ago, but can't find when it was re-opened.
    There was no new commits, AFAIK, in this regards.
    May be @romansimakov can add more details.

  13. Cool-Hunter commented on Nov 24, 2026

    @Cool-Hunter

    I hope I can) I've made a new PR for the optimization. #9338

    BTW. I thought about your original steps to reproduce the bug. But doing
    "b) page is changed by some user attachment and written into database file only" "some user attachment" must FETCH the page. Such fetching must reset BDB_merge.

    But I found that in CCH_fetch_page !merge_flag prevent refetching an allocated but not written to delta page from a database file. Later such page could go to the DB file. May be some bugs were related to this.

    Anycase new PR looks more reliable and I'll wait your feedback @hvlad

    P.S. @romansimakov accound is suspended unfortunately. I use this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions