Skip to content

Commit

Permalink
MB-37039 Initialize in_flight_backfills_per_node correctly.
Browse files Browse the repository at this point in the history
We changed the way we decide if a node is considered to have a
backfill for a particular move. Yet the initialization code assumed
the old definition. So in some corner cases the initial value wouldn't
have all nodes that would be involved in backfills. That would lead to
a crash when we tried to increment a backfill counter for such node.

This whole module needs to be cleaned up quite a bit, but for now I
just made a minimal change to fix the issue at hand.

Change-Id: I38bcc262ba7ccf4120465e82adde15f73e74e3be
Reviewed-on: http://review.couchbase.org/118451
Tested-by: Aliaksey Artamonau <aliaksey.artamonau@couchbase.com>
Reviewed-by: Dave Finlay <dave.finlay@couchbase.com>
Well-Formed: Build Bot <build@couchbase.com>
  • Loading branch information
aartamonau authored and dave-finlay committed Nov 26, 2019
1 parent 6d04f26 commit 1907a7e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/vbucket_move_scheduler.erl
Expand Up @@ -203,7 +203,13 @@ prepare(CurrentMap, TargetMap, Quirks,
end, InitialMoveCounts),

InFlight = dict:map(fun (_K, _V) -> 0 end, InitialMoveCounts),

BackfillNodes =
lists:foldl(
fun ({_V, OldChain, NewChain, _Quirks}, Acc) ->
MoveNodes = backfill_nodes(OldChain, NewChain),
sets:union(sets:from_list(MoveNodes), Acc)
end, sets:new(), Moves),
Backfills = dict:from_list([{N, 0} || N <- sets:to_list(BackfillNodes)]),

State = #state{backfills_limit = BackfillsLimit,
moves_before_compaction = MovesBeforeCompaction,
Expand All @@ -213,7 +219,7 @@ prepare(CurrentMap, TargetMap, Quirks,
moves_left = Moves,
moves_from_undefineds = UndefinedMoves,
compaction_countdown_per_node = CompactionCountdownPerNode,
in_flight_backfills_per_node = InFlight,
in_flight_backfills_per_node = Backfills,
in_flight_per_node = InFlight,
in_flight_compactions = sets:new(),
initial_move_counts = InitialMoveCounts,
Expand Down

0 comments on commit 1907a7e

Please sign in to comment.