You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/11/27 19:53:19 UTC
(couchdb) 03/26: Handle replicator instance start time during upgrades better
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch 3.3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 61477848783daa7c02e5e7f0055aa3b058e750ca
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Wed May 24 23:34:45 2023 -0400
Handle replicator instance start time during upgrades better
During cluster upgrades from 3.2 to 3.3 when instance start time switched from
being always `0` to an actual timestamp, replication jobs will crash when
endpoints are upgraded. Replication jobs were started when endpoint
emitted a `0` and then it becomes a non-`0` value which will crash the next checkpoint attempt.
After the crash jobs will restart and continue fine were they left off without
rewinding. However they will make a logging mess while they crash. All four
workers will exit the `{checkpoint_commit_failure,...}` error. This commit make
it the checkpoint ignore mismatches if one of the instance start times is 0.
---
src/couch_replicator/src/couch_replicator_scheduler_job.erl | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/couch_replicator/src/couch_replicator_scheduler_job.erl b/src/couch_replicator/src/couch_replicator_scheduler_job.erl
index e16412e4a..38533c7f2 100644
--- a/src/couch_replicator/src/couch_replicator_scheduler_job.erl
+++ b/src/couch_replicator/src/couch_replicator_scheduler_job.erl
@@ -799,7 +799,15 @@ do_checkpoint(State) ->
{target_error, Reason} ->
{checkpoint_commit_failure,
<<"Failure on target commit: ", (to_binary(Reason))/binary>>};
- {SrcInstanceStartTime, TgtInstanceStartTime} ->
+ {<<S/binary>>, <<T/binary>>} when
+ % Handle upgrades from 3.2 to 3.3 better by expecting 0 to be
+ % returned if endpoints are upgraded while the replication job is running.
+ % TODO: Remove the `0` special case in a future release (4.x or 5.x)
+ (S =:= SrcInstanceStartTime orelse S =:= <<"0">> orelse
+ SrcInstanceStartTime =:= <<"0">>) andalso
+ (T =:= TgtInstanceStartTime orelse T =:= <<"0">> orelse
+ TgtInstanceStartTime =:= <<"0">>)
+ ->
couch_log:notice(
"recording a checkpoint for `~s` -> `~s` at source update_seq ~p",
[SourceName, TargetName, NewSeq]