Skip to content

Comments

Ensure sequences are replicated even if changed in de-facto read-only transactions#8858

Merged
dyemanov merged 5 commits intoFirebirdSQL:masterfrom
XaBbl4:add_flush_sequences_to_repl
Feb 25, 2026
Merged

Ensure sequences are replicated even if changed in de-facto read-only transactions#8858
dyemanov merged 5 commits intoFirebirdSQL:masterfrom
XaBbl4:add_flush_sequences_to_repl

Conversation

@XaBbl4
Copy link
Contributor

@XaBbl4 XaBbl4 commented Jan 14, 2026

Add a new method to the replication API to ensure generators are always replicated (both on commit and rollback).

Previously, if execute:

select gen_id(t_gen, 1) from rdb$database;
rollback;

The generator on the master and replica stored different values.

If decide to backport this to 5.0, might consider:

version: // 5.0 => 5.0.4
    void flushSequences(Status status);

version: // 5.0.4 => 6.0 Alpha1
    void setSequence2(...);

@dyemanov
Copy link
Member

In practice this PR avoids inconsistent replica when applications use an attachment-level sequence cache (IDs are prefetched and distributed among rows being inserted). This does not allow sharing the cached IDs among different attachments, but so far we haven't seen such an use case.

Custom replication plugins are free to choose between synchronous or delayed (conditional or unconditional) sequence replication.

…ons in transaction before

This allows to remove the new method from the replication API
@dyemanov dyemanov changed the title Add flush sequences to replication API Ensure sequences are replicated even if changed in de-facto read-only transactions Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants