This is an automated email from the ASF dual-hosted git repository.

nickva pushed a commit to branch fix-replicator-mango-checkpoints
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2a275a7a3cc51f21e832f0aceaf611fe61271949
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Tue Jun 16 16:05:12 2026 -0400

    Fix replication job rewinds
    
    This is due to https://github.com/apache/couchdb/pull/5869 (Faster selector
    execution by pre-parsing fields) where normalized form changed which 
results in
    all the replication jobs with selector to change their IDs and rewind.
    
    To fix, bring back the binary dotted format.
---
 .../src/couch_replicator_filters.erl                | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/couch_replicator/src/couch_replicator_filters.erl 
b/src/couch_replicator/src/couch_replicator_filters.erl
index c6f51d724..279a3f14c 100644
--- a/src/couch_replicator/src/couch_replicator_filters.erl
+++ b/src/couch_replicator/src/couch_replicator_filters.erl
@@ -52,7 +52,10 @@ parse(Options) ->
         {undefined, _, undefined} ->
             {ok, {docids, DocIds}};
         {undefined, undefined, _} ->
-            {ok, {mango, ejsort(mango_selector:normalize(Selector))}};
+            % We need paths to hashed with <<"a.b">> form not the new
+            % normalized [<<"a">>, <<"b">>] form
+            Normalized = 
mango_util:join_keys(mango_selector:normalize(Selector)),
+            {ok, {mango, ejsort(Normalized)}};
         _ ->
             Err = "`selector`, `filter` and `doc_ids` are mutually exclusive",
             {error, list_to_binary(Err)}
@@ -217,4 +220,20 @@ ejsort_compound_values_test() ->
         {[{<<"x">>, Ej1s}, {<<"y">>, [Ej1s, Ej1s]}, {<<"z">>, Ej1s}]}
     ).
 
+% Regression tests for replication checkpoint stability. The hashed mango
+% selector must use field paths with dots: <<"a.b">> or we get rewinds!
+mango_selector_single_field_path_test() ->
+    Sel = {[{<<"name">>, <<"x">>}]},
+    ?assertEqual(
+        {ok, {mango, {[{<<"name">>, {[{<<"$eq">>, <<"x">>}]}}]}}},
+        parse([{selector, Sel}])
+    ).
+
+mango_selector_nested_field_path_test() ->
+    Sel = {[{<<"a">>, {[{<<"b">>, 1}]}}]},
+    ?assertEqual(
+        {ok, {mango, {[{<<"a.b">>, {[{<<"$eq">>, 1}]}}]}}},
+        parse([{selector, Sel}])
+    ).
+
 -endif.

Reply via email to