Skip to content

Commit 5f38660

Browse files
anuthanAliaksey Artamonau
authored andcommitted
Add persistence stats to rebalance kv stats.
Helps with, MB-30803: Collect rebalance related stats Part of EPIC, MB-30894: Rebalance visibility and reporting Change-Id: I944ef894f5eda6756c3bca5bbd3fd7da26099211 Reviewed-on: http://review.couchbase.org/101826 Reviewed-by: Aliaksey Artamonau <[email protected]> Well-Formed: Build Bot <[email protected]> Tested-by: Aliaksey Artamonau <[email protected]>
1 parent dba72aa commit 5f38660

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/ns_rebalance_observer.erl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@
4747
stats :: [#replica_building_stats{}],
4848
move = #stat_info{},
4949
backfill = #stat_info{},
50-
takeover = #stat_info{}}).
50+
takeover = #stat_info{},
51+
persistence = #stat_info{}}).
5152

5253
-record(total_stat_info, {total_time = 0,
5354
completed_count = 0}).
5455

5556
-record(vbucket_level_info, {move = #total_stat_info{},
5657
backfill = #total_stat_info{},
5758
takeover = #total_stat_info{},
59+
persistence = #total_stat_info{},
5860
vbucket_info = dict:new()}).
5961

6062
-record(compaction_info, {per_node = [] :: [{node(), #total_stat_info{}}],
@@ -126,6 +128,10 @@ is_interesting_master_event({_, backfill_phase_started, _BucketName, _VBucketId}
126128
fun handle_generic_vb_stat_event/2;
127129
is_interesting_master_event({_, backfill_phase_ended, _BucketName, _VBucketId}) ->
128130
fun handle_generic_vb_stat_event/2;
131+
is_interesting_master_event({_, seqno_waiting_started, _BucketName, _VBucketId, _, _}) ->
132+
fun handle_persistence/2;
133+
is_interesting_master_event({_, seqno_waiting_ended, _BucketName, _VBucketId, _, _}) ->
134+
fun handle_persistence/2;
129135
is_interesting_master_event(_) ->
130136
undefined.
131137

@@ -392,6 +398,9 @@ handle_takeover({TS, Event, BucketName, VBucket, _, _}, State) ->
392398
handle_generic_vb_stat_event({TS, Event, BucketName, VBucket}, State) ->
393399
{noreply, update_info(Event, State, {TS, BucketName, VBucket})}.
394400

401+
handle_persistence({TS, Event, BucketName, VBucket, _, _}, State) ->
402+
{noreply, update_info(Event, State, {TS, BucketName, VBucket})}.
403+
395404
update_move(State, BucketName, VBucket, Fun) ->
396405
update_all_vb_info(State, BucketName,
397406
dict:update(VBucket, Fun,
@@ -707,7 +716,12 @@ find_event_action(Event) ->
707716
{takeover_started, undefined,
708717
#vbucket_info.takeover, start_time},
709718
{takeover_ended, #vbucket_level_info.takeover,
710-
#vbucket_info.takeover, end_time}
719+
#vbucket_info.takeover, end_time},
720+
721+
{seqno_waiting_started, undefined,
722+
#vbucket_info.persistence, start_time},
723+
{seqno_waiting_ended, #vbucket_level_info.persistence,
724+
#vbucket_info.persistence, end_time}
711725
],
712726
lists:keyfind(Event, 1, EventAction).
713727

@@ -806,14 +820,16 @@ construct_vbucket_info_json(Id, #vbucket_info{before_chain = BC,
806820
stats = RBS,
807821
move = Move,
808822
backfill = Backfill,
809-
takeover = Takeover}) ->
823+
takeover = Takeover,
824+
persistence = Persistence}) ->
810825
{[{id, Id},
811826
{beforeChain, BC},
812827
{afterChain, AC},
813828
{stats, {[construct_replica_building_stats_json(X) || X <- RBS]}},
814829
{move, construct_stat_info_json(Move)},
815830
{backfill, construct_stat_info_json(Backfill)},
816-
{takeover, construct_stat_info_json(Takeover)}]}.
831+
{takeover, construct_stat_info_json(Takeover)},
832+
{persistence, construct_stat_info_json(Persistence)}]}.
817833

818834
construct_vbucket_level_info_json(VBLevelInfo, Options) ->
819835
case dict:is_empty(VBLevelInfo#vbucket_level_info.vbucket_info) of
@@ -828,6 +844,7 @@ construct_vbucket_level_info_json_inner(
828844
#vbucket_level_info{move = Move,
829845
backfill = Backfill,
830846
takeover = Takeover,
847+
persistence = Persistence,
831848
vbucket_info = AllVBInfo}, Options) ->
832849
VBI = case proplists:get_bool(add_vbucket_info, Options) of
833850
true ->
@@ -840,7 +857,8 @@ construct_vbucket_level_info_json_inner(
840857
end,
841858
{[{move, construct_total_stat_info_json(Move)},
842859
{backfill, construct_total_stat_info_json(Backfill)},
843-
{takeover, construct_total_stat_info_json(Takeover)}]
860+
{takeover, construct_total_stat_info_json(Takeover)},
861+
{persistence, construct_total_stat_info_json(Persistence)}]
844862
++ VBI}.
845863

846864
get_all_stage_rebalance_details(#state{bucket_info = BucketLevelInfo},

0 commit comments

Comments
 (0)