Skip to content

Comments

Improve replication since_seq parameter#5881

Merged
jiahuili430 merged 1 commit intomainfrom
improve-replication
Feb 13, 2026
Merged

Improve replication since_seq parameter#5881
jiahuili430 merged 1 commit intomainfrom
improve-replication

Conversation

@jiahuili430
Copy link
Contributor

@jiahuili430 jiahuili430 commented Feb 6, 2026

Overview

  • If there is no checkpoint and no since_seq, then replicate from scratch.
  • If there is no checkpoint but since_seq is defined, then replicate with
    the since_seq field.
  • If both checkpoint and since_seq exist, use the checkpoint to replicate.
  • If the request includes since_seq field, the replication ID will be changed.

Testing recommendations

Related Issues or Pull Requests

Related issue: #5867

Checklist

  • This is my own work, I did not use AI, LLM's or similar technology
  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • Documentation changes were made in the src/docs folder
  • Documentation changes were backported (separated PR) to affected branches

@jiahuili430 jiahuili430 changed the title Improve replication Improve replication since_seq parameter Feb 6, 2026
@jiahuili430 jiahuili430 force-pushed the improve-replication branch 7 times, most recently from d171417 to d0217ec Compare February 10, 2026 22:42
@jiahuili430 jiahuili430 marked this pull request as ready for review February 10, 2026 22:43
- If there is no checkpoint and no `since_seq`, then replicate from scratch.
- If there is no checkpoint but `since_seq` is defined, then replicate with
  the `since_seq` field.
- If both checkpoint and `since_seq` exist, use the checkpoint to replicate.
- If the request includes `since_seq` field, the replication ID will be changed.
Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

end,
ok = couch_replicator_scheduler:remove_job(Rep#rep.id).
ok = couch_replicator_scheduler:remove_job(Rep#rep.id),
{ok, Rep#rep.id}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very neat idea so we can compare replication IDs!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to your original code, it's very concise and easy to extend! I reused most of them.

@nickva
Copy link
Contributor

nickva commented Feb 13, 2026

Let's wait for @rnewson's review as well since this implements his idea

@nickva nickva requested a review from rnewson February 13, 2026 19:05
Copy link
Member

@rnewson rnewson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very neatly done and a welcome improvement to since_seq behaviour.

I spun up a 3 node dev cluster and took this through some manual testing and observed the correct behavior.

Specifically;

  1. I made a database and filled it with thousands of documents
  2. I called _replicate with source/target and a since_seq of the current update seq of the db after step 1
  3. I observed that the response correctly said "no_changes". and no checkpoint was made, as no work was done.
  4. I then added ten more documents.
  5. I called _replicate against with same args as step 2 and the response correctly said docs_read:10 and docs_written:10. the log confirmed it called _changes with my original since_seq
  6. I did step 5 again and got a "no_changes" response and confirmed in the log that _changes was called with the update_seq from the checkpoint made at the end of step 5.

@jiahuili430 jiahuili430 merged commit 437a586 into main Feb 13, 2026
54 checks passed
@jiahuili430 jiahuili430 deleted the improve-replication branch February 13, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants