You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/09/15 17:49:17 UTC

[couchdb] 02/03: Optimize view indexer batch sizes

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

davisp pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit a626125ad536f0a8003a50136bcbd7841264aa15
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Sep 3 12:04:56 2020 -0500

    Optimize view indexer batch sizes
    
    The couch_views_batch module is responsible for sensing the largest
    batch sizes that can be successfully processed for a given indexer
    process. It works by initially searching for the maximum number of
    documents that can be included in a batch. Once this threshold is found
    it then works by slowly increasing the batch size and decreasing when
    its found again.
    
    This approach works to maximise batch sizes while being reactive to when
    a larger batch would cross over the FoundationDB transaction limits
    which causes the entire batch to be aborted and retried which wastes
    time during view builds.
---
 rel/overlay/etc/default.ini                        |   8 +
 src/couch_views/README.md                          |  17 ++
 src/couch_views/src/couch_views_batch.erl          |  86 +++++++
 src/couch_views/src/couch_views_batch_impl.erl     | 248 +++++++++++++++++++++
 src/couch_views/src/couch_views_indexer.erl        |  87 ++++++--
 .../test/couch_views_active_tasks_test.erl         |   4 +-
 src/couch_views/test/couch_views_batch_test.erl    |  90 ++++++++
 src/couch_views/test/couch_views_indexer_test.erl  |   2 +-
 8 files changed, 516 insertions(+), 26 deletions(-)

diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 8f2b25e..b837082 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -312,6 +312,14 @@ iterations = 10 ; iterations for password hashing
 ;
 ; The maximum allowed value size emitted from a view for a document (in bytes)
 ;value_size_limit = 64000
+;
+; Batch size sensing parameters
+; batch_initial_size = 100 ; Initial batch size in number of documents
+; batch_search_increment = 500 ; Size change when searching for the threshold
+; batch_sense_increment = 100 ; Size change increment after hitting a threshold
+; batch_max_tx_size_bytes = 9000000 ; Maximum transaction size in bytes
+; batch_max_tx_time_msec = 4500 ; Maximum transaction time in milliseconds
+; batch_thresold_penalty = 0.2 ; Amount to reduce batch size when crossing a threshold
 
 ; CSP (Content Security Policy) Support for _utils
 [csp]
diff --git a/src/couch_views/README.md b/src/couch_views/README.md
index 09696da..181f48e 100644
--- a/src/couch_views/README.md
+++ b/src/couch_views/README.md
@@ -7,6 +7,8 @@ Currently only map indexes are supported and it will always return the full inde
 Code layout:
 
 * `couch_views` - Main entry point to query a view
+* `couch_views_batch` - Dynamically determine optimal batch sizes for view indexers.
+* `couch_views_batch_impl` - Default implementation for optimizing batch sizes.
 * `couch_views_encoding` - Encodes view keys that are byte comparable following CouchDB view sort order.
 * `couch_views_fdb` - Maps view operations to FoundationDB logic.
 * `couch_views_http` - View specific helpers for chttpd
@@ -16,3 +18,18 @@ Code layout:
 * `couch_views_server` - Spawns `couch_views_indexer` workers to handle index update jobs.
 * `couch_views_updater` - Update interactive indexes during doc update transactions
 * `couch_views_util` - Various utility functions
+
+# Configuration
+
+; Batch size sensing parameters
+; batch_initial_size = 100 ; Initial batch size in number of documents
+; batch_search_increment = 500 ; Size change when searching for the threshold
+; batch_sense_increment = 100 ; Size change increment after hitting a threshold
+; batch_max_tx_size_bytes = 9000000 ; Maximum transaction size in bytes
+; batch_max_tx_time_msec = 4500 ; Maximum transaction time in milliseconds
+; batch_thresold_penalty = 0.2 ; Amount to reduce batch size when crossing a threshold
+
+The default batch size sensing parameters are fairly straight forward. These
+values can be tweaked in the config if desired. If you find that you need to
+tweak these values for any reason please open an issue on GitHub reporting your
+experience in case we need to adjust them for common cases.
diff --git a/src/couch_views/src/couch_views_batch.erl b/src/couch_views/src/couch_views_batch.erl
new file mode 100644
index 0000000..ba2a227
--- /dev/null
+++ b/src/couch_views/src/couch_views_batch.erl
@@ -0,0 +1,86 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_views_batch).
+
+
+-export([
+    start/1,
+    success/2,
+    failure/1
+]).
+
+
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+-type update_stats() :: #{
+    docs_read => non_neg_integer(),
+    tx_size => non_neg_integer(),
+    total_kvs => non_neg_integer()
+}.
+
+-export_type([update_stats/0]).
+
+-callback start(
+            Mrst::#mrst{},
+            State::term()
+        ) -> {NewState::term(), BatchSize::pos_integer()}.
+
+-callback success(
+            Mrst::#mrst{},
+            UpdateStats::update_stats(),
+            State::term()
+        ) -> NewState::term().
+
+-callback failure(Mrst::#mrst{}, State::term()) -> NewState::term().
+
+
+-define(DEFAULT_MOD, "couch_views_batch_impl").
+
+
+-spec start(#mrst{}) -> pos_integer().
+start(#mrst{} = Mrst) ->
+    {Mod, State} = case load_state() of
+        {M, S} ->
+            {M, S};
+        undefined ->
+            ModStr = config:get("couch_views", "batch_module", ?DEFAULT_MOD),
+            ModAtom = list_to_existing_atom(ModStr),
+            {ModAtom, undefined}
+    end,
+    {NewState, BatchSize} = Mod:start(Mrst, State),
+    save_state(Mod, NewState),
+    BatchSize.
+
+
+-spec success(#mrst{}, UpdateStats::update_stats()) -> ok.
+success(#mrst{} = Mrst, UpdateStats) ->
+    {Mod, State} = load_state(),
+    NewState = Mod:success(Mrst, UpdateStats, State),
+    save_state(Mod, NewState),
+    ok.
+
+
+-spec failure(#mrst{}) -> ok.
+failure(#mrst{} = Mrst) ->
+    {Mod, State} = load_state(),
+    NewState = Mod:failure(Mrst, State),
+    save_state(Mod, NewState),
+    ok.
+
+
+load_state() ->
+    get(?MODULE).
+
+
+save_state(Mod, State) ->
+    put(?MODULE, {Mod, State}).
diff --git a/src/couch_views/src/couch_views_batch_impl.erl b/src/couch_views/src/couch_views_batch_impl.erl
new file mode 100644
index 0000000..cacd53b
--- /dev/null
+++ b/src/couch_views/src/couch_views_batch_impl.erl
@@ -0,0 +1,248 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_views_batch_impl).
+
+-behavior(couch_views_batch).
+
+
+-export([
+    start/2,
+    success/3,
+    failure/2
+]).
+
+
+-include("couch_mrview/include/couch_mrview.hrl").
+
+
+-record(batch_st, {
+    start_time,
+    state,
+    size,
+    search_incr,
+    sense_incr,
+    max_tx_size_bytes,
+    max_tx_time_msec,
+    threshold_penalty
+}).
+
+
+-spec start(
+        Mrst::#mrst{},
+        State::term()
+    ) -> {NewState::term(), BatchSize::pos_integer()}.
+start(Mrst, undefined) ->
+    St = #batch_st{
+        state = search,
+        size = get_config(batch_initial_size, "100"),
+        search_incr = get_config(batch_search_increment, "500"),
+        sense_incr = get_config(batch_sense_increment, "100"),
+        max_tx_size_bytes = get_config(batch_max_tx_size_bytes, "9000000"),
+        max_tx_time_msec = get_config(batch_max_tx_time_msec, "4500"),
+        threshold_penalty = get_config(
+                batch_threshold_penalty,
+                "0.2",
+                fun float_0_to_1/2
+            )
+    },
+    start(Mrst, St);
+
+start(_Mrst, #batch_st{size = Size} = St) ->
+    NewSt = St#batch_st{
+        start_time = erlang:monotonic_time()
+    },
+    {NewSt, Size}.
+
+
+-spec success(
+        Mrst::#mrst{},
+        UpdateStats::couch_views_batch:update_stats(),
+        State::term()
+    ) -> NewState::term().
+success(_Mrst, #{tx_size := TxSize}, #batch_st{} = St) ->
+    #batch_st{
+        start_time = StartTime,
+        size = Size,
+        state = State,
+        search_incr = SearchIncr,
+        sense_incr = SenseIncr,
+        max_tx_size_bytes = MaxTxSize,
+        max_tx_time_msec = MaxTxTime,
+        threshold_penalty = ThresholdPenalty
+    } = St,
+
+    TxTimeNative = erlang:monotonic_time() - StartTime,
+    TxTime = erlang:convert_time_unit(TxTimeNative, native, millisecond),
+
+    {NewSize, NewState} = case TxSize > MaxTxSize orelse TxTime > MaxTxTime of
+        true ->
+            {round(Size * (1.0 - ThresholdPenalty)), sense};
+        false when State == search ->
+            {Size + SearchIncr, State};
+        false when State == sense ->
+            {Size + SenseIncr, State}
+    end,
+
+    St#batch_st{
+        size = erlang:max(1, NewSize),
+        state = NewState
+    }.
+
+
+-spec failure(Mrst::#mrst{}, State::term()) -> NewState::term().
+failure(_Mrst, #batch_st{} = St) ->
+    St#batch_st{
+        size = erlang:max(1, St#batch_st.size div 2),
+        state = sense
+    }.
+
+
+get_config(Key, Default) ->
+    get_config(Key, Default, fun non_neg_integer/2).
+
+
+get_config(Key, Default, Validator) ->
+    StrVal = config:get("couch_views", atom_to_list(Key), Default),
+    Validator(Key, StrVal).
+
+
+non_neg_integer(Name, Str) ->
+    try
+        Val = list_to_integer(Str),
+        true = Val > 0,
+        Val
+    catch _:_ ->
+        erlang:error({invalid_non_neg_integer, {couch_views, Name, Str}})
+    end.
+
+
+float_0_to_1(Name, Str) ->
+    Val = try
+        list_to_float(Str)
+    catch error:badarg ->
+        erlang:error({invalid_float, {couch_views, Name, Str}})
+    end,
+    if Val >= 0.0 andalso Val =< 1.0 -> Val; true ->
+        erlang:error({float_out_of_range, {couch_views, Name, Str}})
+    end.
+
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+
+
+good_config_test() ->
+    with_good_config(fun() ->
+        {St, 1} = start(#mrst{}, undefined),
+        ?assertMatch(
+            #batch_st{
+                state = search,
+                size = 1,
+                search_incr = 2,
+                sense_incr = 3,
+                max_tx_size_bytes = 4,
+                max_tx_time_msec = 5,
+                threshold_penalty = 0.6
+            },
+            St
+        )
+    end).
+
+
+bad_config_test() ->
+    Fields = [
+        {batch_initial_size, invalid_non_neg_integer},
+        {batch_search_increment, invalid_non_neg_integer},
+        {batch_sense_increment, invalid_non_neg_integer},
+        {batch_max_tx_size_bytes, invalid_non_neg_integer},
+        {batch_max_tx_time_msec, invalid_non_neg_integer},
+        {batch_threshold_penalty, invalid_float}
+    ],
+    lists:foreach(fun({Field, Error}) ->
+        with_bad_config(atom_to_list(Field), fun() ->
+            ?assertError(
+                {Error, {couch_views, Field, _}},
+                start(#mrst{}, undefined)
+            )
+        end)
+    end, Fields).
+
+
+float_range_test() ->
+    with_bad_float_config("batch_threshold_penalty", fun() ->
+        lists:foreach(fun(_) ->
+            ?assertError(
+                {float_out_of_range, {couch_views, batch_threshold_penalty, _}},
+                start(#mrst{}, undefined)
+            )
+        end, lists:seq(1, 10))
+    end).
+
+
+with_good_config(Fun) ->
+    meck:new(config),
+    meck:expect(config, get, fun
+        ("couch_views", "batch_initial_size", _) -> "1";
+        ("couch_views", "batch_search_increment", _) -> "2";
+        ("couch_views", "batch_sense_increment", _) -> "3";
+        ("couch_views", "batch_max_tx_size_bytes", _) -> "4";
+        ("couch_views", "batch_max_tx_time_msec", _) -> "5";
+        ("couch_views", "batch_threshold_penalty", _) -> "0.6"
+    end),
+    try
+        Fun()
+    after
+        meck:unload()
+    end.
+
+
+with_bad_config(FieldName, Fun) ->
+    meck:new(config),
+    meck:expect(config, get, fun("couch_views", Field, Default) ->
+        case Field == FieldName of
+            true ->
+                case rand:uniform() < 0.5 of
+                    true -> "foo";
+                    false -> -10
+                end;
+            false ->
+                Default
+        end
+    end),
+    try
+        Fun()
+    after
+        meck:unload()
+    end.
+
+
+with_bad_float_config(FieldName, Fun) ->
+    meck:new(config),
+    meck:expect(config, get, fun("couch_views", Field, Default) ->
+        case Field == FieldName of
+            true ->
+                case rand:uniform() < 0.5 of
+                    true -> "100.0";
+                    false -> "-0.5"
+                end;
+            false ->
+                Default
+        end
+    end),
+    try
+        Fun()
+    after
+        meck:unload()
+    end.
+
+-endif.
diff --git a/src/couch_views/src/couch_views_indexer.erl b/src/couch_views/src/couch_views_indexer.erl
index 737b6f8..17b0daa 100644
--- a/src/couch_views/src/couch_views_indexer.erl
+++ b/src/couch_views/src/couch_views_indexer.erl
@@ -33,12 +33,20 @@
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 -include_lib("fabric/include/fabric2.hrl").
 
-% TODO:
-%  * Handle timeouts of transaction and other errors
 
 -define(KEY_SIZE_LIMIT, 8000).
 -define(VALUE_SIZE_LIMIT, 64000).
 
+% These are all of the errors that we can fix by using
+% a smaller batch size.
+-define(IS_RECOVERABLE_ERROR(Code), (
+    (Code == 1004) % timed_out
+    orelse (Code == 1007) % transaction_too_old
+    orelse (Code == 1031) % transaction_timed_out
+    orelse (Code == 2101) % transaction_too_large
+)).
+
+
 spawn_link() ->
     proc_lib:spawn_link(?MODULE, init, []).
 
@@ -88,10 +96,10 @@ init() ->
         job => Job,
         job_data => Data,
         count => 0,
-        limit => num_changes(),
         changes_done => 0,
         doc_acc => [],
-        design_opts => Mrst#mrst.design_opts
+        design_opts => Mrst#mrst.design_opts,
+        update_stats => #{}
     },
 
     try
@@ -162,7 +170,32 @@ add_error(Error, Reason, Data) ->
 
 
 update(#{} = Db, Mrst0, State0) ->
-    {Mrst2, State4} = fabric2_fdb:transactional(Db, fun(TxDb) ->
+    Limit = couch_views_batch:start(Mrst0),
+    {Mrst1, State1} = try
+        do_update(Db, Mrst0, State0#{limit => Limit})
+    catch
+        error:{erlfdb_error, Error} when ?IS_RECOVERABLE_ERROR(Error) ->
+            couch_views_batch:failure(Mrst0),
+            update(Db, Mrst0, State0)
+    end,
+    case State1 of
+        finished ->
+            couch_eval:release_map_context(Mrst1#mrst.qserver);
+        _ ->
+            #{
+                update_stats := UpdateStats
+            } = State1,
+            couch_views_batch:success(Mrst1, UpdateStats),
+            update(Db, Mrst1, State1)
+    end.
+
+
+do_update(Db, Mrst0, State0) ->
+    fabric2_fdb:transactional(Db, fun(TxDb) ->
+        #{
+            tx := Tx
+        } = TxDb,
+
         State1 = get_update_start_state(TxDb, Mrst0, State0),
 
         {ok, State2} = fold_changes(State1),
@@ -180,10 +213,16 @@ update(#{} = Db, Mrst0, State0) ->
         DocAcc1 = fetch_docs(TxDb, DesignOpts, DocAcc),
 
         {Mrst1, MappedDocs} = map_docs(Mrst0, DocAcc1),
-        write_docs(TxDb, Mrst1, MappedDocs, State2),
+        TotalKVs = write_docs(TxDb, Mrst1, MappedDocs, State2),
 
         ChangesDone = ChangesDone0 + length(DocAcc),
 
+        UpdateStats = #{
+            docs_read => length(DocAcc),
+            tx_size => erlfdb:wait(erlfdb:get_approximate_size(Tx)),
+            total_kvs => TotalKVs
+        },
+
         case Count < Limit of
             true ->
                 maybe_set_build_status(TxDb, Mrst1, ViewVS,
@@ -198,17 +237,11 @@ update(#{} = Db, Mrst0, State0) ->
                     count := 0,
                     doc_acc := [],
                     changes_done := ChangesDone,
-                    view_seq := LastSeq
+                    view_seq := LastSeq,
+                    update_stats := UpdateStats
                 }}
         end
-    end),
-
-    case State4 of
-        finished ->
-            couch_eval:release_map_context(Mrst2#mrst.qserver);
-        _ ->
-        update(Db, Mrst2, State4)
-    end.
+    end).
 
 
 maybe_set_build_status(_TxDb, _Mrst1, not_found, _State) ->
@@ -351,14 +384,17 @@ write_docs(TxDb, Mrst, Docs, State) ->
     KeyLimit = key_size_limit(),
     ValLimit = value_size_limit(),
 
-    lists:foreach(fun(Doc0) ->
+    TotalKVCount = lists:foldl(fun(Doc0, KVCount) ->
         Doc1 = calculate_kv_sizes(Mrst, Doc0, KeyLimit, ValLimit),
-        couch_views_fdb:write_doc(TxDb, Sig, ViewIds, Doc1)
-    end, Docs),
+        couch_views_fdb:write_doc(TxDb, Sig, ViewIds, Doc1),
+        KVCount + count_kvs(Doc1)
+    end, 0, Docs),
 
     if LastSeq == false -> ok; true ->
         couch_views_fdb:set_update_seq(TxDb, Sig, LastSeq)
-    end.
+    end,
+
+    TotalKVCount.
 
 
 fetch_docs(Db, DesignOpts, Changes) ->
@@ -478,6 +514,15 @@ calculate_kv_sizes(Mrst, Doc, KeyLimit, ValLimit) ->
     end.
 
 
+count_kvs(Doc) ->
+    #{
+        results := Results
+    } = Doc,
+    lists:foldl(fun(ViewRows, Count) ->
+        Count + length(ViewRows)
+    end, 0, Results).
+
+
 report_progress(State, UpdateType) ->
     #{
         tx_db := TxDb,
@@ -544,10 +589,6 @@ fail_job(Job, Data, Error, Reason) ->
     exit(normal).
 
 
-num_changes() ->
-    config:get_integer("couch_views", "change_limit", 100).
-
-
 retry_limit() ->
     config:get_integer("couch_views", "retry_limit", 3).
 
diff --git a/src/couch_views/test/couch_views_active_tasks_test.erl b/src/couch_views/test/couch_views_active_tasks_test.erl
index 6085d73..b7f36a3 100644
--- a/src/couch_views/test/couch_views_active_tasks_test.erl
+++ b/src/couch_views/test/couch_views_active_tasks_test.erl
@@ -47,8 +47,8 @@ foreach_setup() ->
     Docs = make_docs(?TOTAL_DOCS),
     fabric2_db:update_docs(Db, [DDoc | Docs]),
 
-    meck:new(couch_rate, [passthrough]),
-    meck:expect(couch_rate, budget, fun(_) -> 100 end),
+    meck:new(couch_views_batch, [passthrough]),
+    meck:expect(couch_views_batch, success, fun(_, _) -> 100 end),
 
     {Db, DDoc}.
 
diff --git a/src/couch_views/test/couch_views_batch_test.erl b/src/couch_views/test/couch_views_batch_test.erl
new file mode 100644
index 0000000..78e6892
--- /dev/null
+++ b/src/couch_views/test/couch_views_batch_test.erl
@@ -0,0 +1,90 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_views_batch_test).
+
+
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("fabric/test/fabric2_test.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+
+batch_test_() ->
+    {
+        "Test view batch sizing",
+        {
+            setup,
+            fun setup/0,
+            fun cleanup/1,
+            with([
+                ?TDEF(basic),
+                ?TDEF(search_success),
+                ?TDEF(sense_success),
+                ?TDEF(failure),
+                ?TDEF(failure_switches_to_sense)
+            ])
+        }
+    }.
+
+
+setup() ->
+    test_util:start_couch().
+
+
+cleanup(Ctx) ->
+    test_util:stop_couch(Ctx).
+
+
+basic(_) ->
+    erase(couch_views_batch),
+    ?assertEqual(100, couch_views_batch:start(#mrst{})).
+
+
+search_success(_) ->
+    erase(couch_views_batch),
+    couch_views_batch:start(#mrst{}),
+    couch_views_batch:success(#mrst{}, ustats(0, 0, 0)),
+    ?assertEqual(600, couch_views_batch:start(#mrst{})).
+
+
+sense_success(_) ->
+    erase(couch_views_batch),
+    couch_views_batch:start(#mrst{}),
+    % Exceeding our threshold switches from search to sense
+    couch_views_batch:success(#mrst{}, ustats(5000, 10000000, 10000)),
+    ?assertEqual(80, couch_views_batch:start(#mrst{})),
+    couch_views_batch:success(#mrst{}, ustats(0, 0, 0)),
+    ?assertEqual(180, couch_views_batch:start(#mrst{})).
+
+
+failure(_) ->
+    erase(couch_views_batch),
+    couch_views_batch:start(#mrst{}),
+    couch_views_batch:failure(#mrst{}),
+    ?assertEqual(50, couch_views_batch:start(#mrst{})).
+
+
+failure_switches_to_sense(_) ->
+    erase(couch_views_batch),
+    couch_views_batch:start(#mrst{}),
+    couch_views_batch:failure(#mrst{}),
+    couch_views_batch:start(#mrst{}),
+    couch_views_batch:success(#mrst{}, ustats(0, 0, 0)),
+    ?assertEqual(150, couch_views_batch:start(#mrst{})).
+
+
+ustats(DocsRead, TxSize, TotalKVs) ->
+    #{
+        docs_read => DocsRead,
+        tx_size => TxSize,
+        total_kvs => TotalKVs
+    }.
diff --git a/src/couch_views/test/couch_views_indexer_test.erl b/src/couch_views/test/couch_views_indexer_test.erl
index cff3a2e..86c0a81 100644
--- a/src/couch_views/test/couch_views_indexer_test.erl
+++ b/src/couch_views/test/couch_views_indexer_test.erl
@@ -437,7 +437,7 @@ handle_db_recreated_when_running(Db) ->
 
     % To intercept job building while it is running ensure updates happen one
     % row at a time.
-    config:set("couch_view", "change_limit", "1", false),
+    config:set("couch_views", "batch_initial_size", "1", false),
 
     meck_intercept_job_update(self()),