-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelixir.txt
1891 lines (1263 loc) · 76.7 KB
/
elixir.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
new_bucket_default_params(memcached) ->
Nodes = ns_cluster_membership:service_active_nodes(kv),
[{type, memcached},
{num_vbuckets, 0},
{num_replicas, 0},
{servers, Nodes},
{map, []},
{ram_quota, 0}].
ns_bucket:set_servers(Bucket, Servers) ->
set_property(Bucket, servers, Servers).
ns_janitor:check_server_list(Bucket, BucketConfig) ->
- sets bucket servers to active kv nodes
handle_local_random_key(Bucket, Req) ->
needs to be fixed to use servers
Assumptions:
1. ns_server is agnostic to subclusters. subclusters are stored and managed by Elixir Control Panel
2. Everything is done by REST API's. ns_server UI support might require some extra stuff
List of the topology API behaviors we need for the subclusters support.
1. Allow to assign the list of kv nodes to the bucket at bucket creation time
2. Allow to add/remove existing servers to/from the bucket manually. That will mark certain servers as to_be_removed or to_be_added and subsequent rebalance should take care of rebuilding the map correctly
3. Do not allow to rebalance out the last server for the bucket
4. Provide API to return list of unbalanced buckets
5. Provide API to to rebalance a list of buckets. With this functionality the new node will be activated if it is activated on at least one bucket and ejected if it is deactivated on all buckets.
6. Auto-failover: do not limit the number of autofailover events. The unhealthy node should be automatically failed over if there's no data loss (alternative: if at least 2 partitions are left in each chain)
new rebalance API to accept full kv topology: bucket[servers], bucket[servers]...
width - how many nodes in SG the bucket should reside on
weight - how many virtual space slots the bucket reserves if it resides on a node
weight_limit - how many virtual space slots are available on each node
weight not consistent with current placement
-----------------------
Bucket rename
-----------------------
chronicle:
bucket_names => ["blahbucket"]
{bucket,"blahbucket",collections}
{bucket,"blahbucket",props}
{bucket,"blahbucket",uuid}
{<<"65af2f16bb9dce18baccaa01b2854473">>,
{<<"693de97ae64228e67f91185709c596f0">>,17}},
{node,'[email protected]',buckets_with_data} =>
{[{"blahbucket",<<"65af2f16bb9dce18baccaa01b2854473">>}],
{node,'[email protected]',
{"blahbucket",last_seen_collection_ids}} =>
{[1,8,8],{<<"693de97ae64228e67f91185709c596f0">>,25}},
???? {node,'[email protected]',failover_vbuckets} =>
{[],{<<"693de97ae64228e67f91185709c596f0">>,36}},
ns_config:
none
user_storage:
ddocs:
------------------------------------------------
[ns_server:debug,2022-06-01T15:12:56.332-07:00,[email protected]:ns_config_rep<0.475.0>:ns_config_rep:do_push_keys:383]Replicating some config keys ([{local_changes_count,
<<"6ea558df4dc6ebfd5b27b7b7e87e8a7a">>},
{metakv,
<<"/throttle/report/kv/6ea558df4dc6ebfd5b27b7b7e87e8a7a">>}]..)
[ns_server:debug,2022-06-01T15:12:56.332-07:00,[email protected]:ns_config_log<0.271.0>:ns_config_log:log_common:277]config change:
{metakv,<<"/throttle/report/kv/6ea558df4dc6ebfd5b27b7b7e87e8a7a">>} ->
[{'_vclock',63821327610,
[{<<"6ea558df4dc6ebfd5b27b7b7e87e8a7a">>,{95,63821340776}},
{<<"a1b575e4c04cc4309887f8e380480e29">>,{4,63821340726}}]}|
<<1,138,239,208,138,146,48,4,116,101,115,116,0,0,0,0,0,0>>]
[ns_server:debug,2022-06-01T15:12:56.334-07:00,[email protected]:ns_config_log<0.324.0>:ns_config_log:log_common:277]config change:
{local_changes_count,<<"6ea558df4dc6ebfd5b27b7b7e87e8a7a">>} ->
[{'_vclock',[{<<"6ea558df4dc6ebfd5b27b7b7e87e8a7a">>,{112,63821340776}}]}]
--------------------------------------------------
new bucket fields
placer = [{width, X}, {weight, X}, {desired_servers, []}]
ns_orchestrator:start_rebalance_for_buckets(['[email protected]', '[email protected]'], [], ["test"]).
Implement check for Ejected nodes!!
POST http://127.0.0.1:9000/pools/default/buckets
name=test&bucketType=membase&storageBackend=couchstore&autoCompactionDefined=false&evictionPolicy=valueOnly&threadsNumber=3&replicaNumber=1&durabilityMinLevel=none&compressionMode=passive&maxTTL=0&replicaIndex=0&conflictResolutionType=seqno&ramQuotaMB=1899&flushEnabled=0
name=test&
bucketType=membase&
storageBackend=couchstore&
autoCompactionDefined=false&
evictionPolicy=valueOnly&
threadsNumber=3&
replicaNumber=1&
durabilityMinLevel=none&
compressionMode=passive&
maxTTL=0&
replicaIndex=0&
conflictResolutionType=seqno&
ramQuotaMB=1899&
flushEnabled=0
name=test&
storageBackend=couchstore&
autoCompactionDefined=true&
evictionPolicy=valueOnly&
threadsNumber=3&
replicaNumber=1&
durabilityMinLevel=none&
compressionMode=passive&
maxTTL=0&
indexCompactionMode=circular&
databaseFragmentationThreshold%5Bpercentage%5D=30&
databaseFragmentationThreshold%5Bsize%5D=undefined&
viewFragmentationThreshold%5Bpercentage%5D=30&
viewFragmentationThreshold%5Bsize%5D=undefined&
parallelDBAndViewCompaction=false&
purgeInterval=3&
ramQuotaMB=1899&
flushEnabled=0
New parameters needed
width
weight
NO - desiredServers
width and weight has to be specified if bucket placer is enabled
name=t&bucketType=membase&ramQuotaMB=400&replicaNumber=2
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t&bucketType=membase&ramQuotaMB=400&replicaNumber=2'
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets/t -d 'width=2&weight=1'
ns_orchestrator:start_rebalance_for_buckets(['[email protected]','[email protected]', '[email protected]'], [], ["t"]).
mb_map:generate_map([[c,b], [a,c], [b,c]], 1, [a,b], [{maps_history, []}, {replication_topology,star}, {tags,undefined}, {max_slaves,10}]).
rebalance:
no_kv_nodes_left
no_active_nodes_left
failover:
last_node
-----------------------------------
failover:
1. disallow emptying servers
2. remove node from desired servers
rebalance:
disallow ejecting node if it is in the servers of one of the buckets that is not getting rebalanced
disallow ejecting node if it leaves desired_servers empty
disallow rebalance if desired servers are empty
substruct ejected and failed over nodes from desired servers
should this be optimized?
deactivate_bucket_data_on_unknown_nodes
---------------------------------------------
before rebalance:
1. remove ejected nodes from desired servers
2. check if width corresponds to desired_servers and replace the buckets
bucket_placer:rebalance(KeepNodes)
%% rebalance
%%
%% ! 1. construct zone
%% 2. ??? remove ejected nodes from buckets
%% ! 3. remove ejected nodes from zone
%% ! 4. sort buckets by weight
%% 5. place all buckets on constructed zone
%% 6. if success => return servers for the buckets
%% 7. place all the buckets on empty zone
Need to add new nodes to the group before rebalance!!!
2 nodes
bucket, width = 2
eject one node
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t&bucketType=membase&ramQuotaMB=400&replicaNumber=2&width=1&weight=2'
2 nodes
bucket, width = 2
eject one, add 2 -> rebalance
MB-52265
bucket create/update rest api's in serverless mode now support
2 additional parameters: weight and width. These parameters
instruct bucket placer how to assign servers to the bucket
width: how many servers should be assigned to the bucket
in each availability zone
weight: how many virtual space slots should the bucket occupies
when residing on the node.
Examples of the api calls:
create:
POST /pools/default/buckets -d 'name=t&bucketType=membase&ramQuota=4000&width=2&weight=1'
update:
POST /pools/default/buckets/t -d 'width=2&weight=1'
Change-Id: I447b78a830d8cfc355bd50881295a84ce0c38955
--------------------------
\
2097123456
1. Discuss more detailed error messages.
menelaus_web_pools:check_and_handle_pool_info
handle_pool_info(Id, Req)
build_pool_info
do_build_pool_info - cached!!!!
menelaus_web_node:build_nodes_info
build_nodes_info_fun
"summaries":{"ramSummary":{"total":19917701120,"otherBuckets":0,"nodesCount":1,"perNodeMegs":18995,"thisAlloc":19917701120,"thisUsed":0,"free":0},"hddSummary":{"total":499963174912,"otherData":109991898480,"otherBuckets":0,"thisUsed":0,"free":389971276432}}}
In 6.5 created 2 buckets, one using the following commend line:
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t&bucketType=membase&ramQuotaMB=400'
Another one using UI with default settings.
Bucket "t": {replica_index,true},
Bucket "ui": {replica_index,false}
Same result for elixir:
Bucket "t": {replica_index,true},
Bucket "ui": {replica_index,false}
Replicate view indexes
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "knownNodes='[email protected]','[email protected]'"
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&defragmentZones=Group 1"
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&defragmentZones=Group 1"
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&defragmentZones=Group 1,Group 2"
POST /controller/rebalance -d "knownNodes=node1,node2&defragmentZones=AZ1,AZ2"
Disable auto-retry rebalance for elixir.
["pools", "default", "bucketsStreaming", Id] ->
{{[{bucket, Id}, settings], read},
fun menelaus_web_buckets:handle_bucket_info_streaming/3,
["default", Id]};
["settings", "throttle", BucketId] ->
{{[admin, settings], read},
fun throttle_service_settings:handle_settings_throttle_get/2, [BucketId]};
{memory,16672},
{message_queue_len,0},
{reductions,1439},
{memory,15994976},
{message_queue_len,0},
{reductions,554524},
{garbage_collection,
[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
{min_bin_vheap_size,46422},
{min_heap_size,233},
{fullsweep_after,512},
{minor_gcs,4}]},
{garbage_collection_info,
[{old_heap_block_size,376},
{heap_block_size,1598},
{mbuf_size,0},
{recent_size,22},
{stack_size,10},
{old_heap_size,58},
{heap_size,572},
{bin_vheap_size,0},
{bin_vheap_block_size,46422},
{bin_old_vheap_size,0},
{bin_old_vheap_block_size,46422}]},
{garbage_collection,
[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
{min_bin_vheap_size,46422},
{min_heap_size,233},
{fullsweep_after,512},
-- {minor_gcs,26}]},
{garbage_collection_info,
-- [{old_heap_block_size,999631},
-- {heap_block_size,999631},
-- {mbuf_size,0},
{recent_size,303791},
{stack_size,10},
{old_heap_size,54},
-- {heap_size,304208},
{bin_vheap_size,714},
{bin_vheap_block_size,46422},
{bin_old_vheap_size,0},
{bin_old_vheap_block_size,46422}]},
{garbage_collection,
[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
{min_bin_vheap_size,46422},
{min_heap_size,233},
{fullsweep_after,512},
-- {minor_gcs,270}]},
{garbage_collection_info,
-- [{old_heap_block_size,1727361},
-- {heap_block_size,1439468},
{mbuf_size,0},
-- {recent_size,437151},
{stack_size,10},
{old_heap_size,130},
-- {heap_size,440904},
{bin_vheap_size,9548},
{bin_vheap_block_size,46422},
{bin_old_vheap_size,0},
{bin_old_vheap_block_size,75110}]},
25335512
--------------------
{memory,25335512},
{reductions,279058974},
{memory, Size}
Size is the size in bytes of the process. This includes call stack, heap, and internal structures.
{reductions, Number}
Number is the number of reductions executed by the process.
----------------------------------------------------
auto_failover:validate_kv - validates if kv failover is safe
auto_failover:trim_nodes - max count enforcement
validate_bucket_safety(_BucketName, Map, Nodes)
check Delta Recovery!!!!!!
parse_validate_max_count(Args, CurrRV, Config) ->
CurrMax =
case proplists:get_value(?MAX_EVENTS_CONFIG_KEY, Config) of
infinity ->
"infinity";
X ->
integer_to_list(X)
end,
Min = ?MIN_EVENTS_ALLOWED,
Max = max_events_allowed(),
MaxCount = proplists:get_value("maxCount", Args, CurrMax),
case proplists:get_value("maxCount", Args, CurrMax) of
"infinity" ->
case cluster_compat_mode:is_cluster_elixir() of
true ->
[{maxCount, infinity} | CurrRV];
false ->
{error, [{maxCount, <<"Value ">>
end;
MaxCount ->
case parse_validate_number(MaxCount, Min, Max) of
{ok, Val} ->
[{maxCount, Val} | CurrRV];
_ ->
range_err(maxCount, Min, Max)
end
end.
case extract_value(InternalName, Values) of
not_found ->
case maps:find(default, Spec) of
{value, V} ->
{true, {FormattedKey, V}};
error ->
false;
-----
enabled: true
timeout: 12
failoverOnDataDiskIssues[enabled]: false
failoverOnDataDiskIssues[timePeriod]: 120
maxCount: 1
GET /pools/default/services/<service>/defragmented
o
Proposed API to
Auto-Scaling & Auto-Rebalancing APIs
------------------------------------
https://docs.google.com/document/d/1849K4MuUxGKSyHH8I_QWzzoOevwGTOvZMbszCj81XuU
GET /pools/default/services/<service>/defragmented
GetDefragmentedUtilization
{
"[email protected]": {
"memory": 3840,
"billableUnits": 1500,
"tenants":5
},
........
}
~/work/elixir/goproj/src/github.com/couchbase
-define(, ?get_timeout(get_defragmented_utilization, 30000)).
service_safety_check(Service, DownNodes, UUIDDict) ->
ActiveNodes = ns_cluster_membership:service_active_nodes(Service),
case ActiveNodes -- DownNodes of
[] ->
{error, mail_too_small};
[FirstNode | _] = ServiceAliveNodes ->
NodeToCall =
case lists:member(node(), ServiceAliveNodes) of
true ->
node();
false ->
FirstNode
end,
ServiceDownNodes = ActiveNodes -- ServiceAliveNodes,
NodeIds = ns_cluster_membership:get_node_uuids(ServiceDownNodes,
UUIDDict),
case rpc:call(NodeToCall, service_api, is_safe, [Service, NodeIds],
?SAFETY_CHECK_TIMEOUT) of
{badrpc, Error} ->
?log_warning("Failed to execute safety check for service ~p"
" on node ~p. Error = ~p",
[Service, NodeToCall, Error]),
{error, "Safety check failed."};
Other ->
Other
end
end.
curl -v http://Administrator:asdasd@localhost:9000/pools/default/services/index/defragmented
[json_rpc:debug,2022-09-19T12:45:10.755-07:00,[email protected]:json_rpc_connection-fts-service_api<0.867.0>:json_rpc_connection:handle_call:156]sending jsonrpc call:{[{jsonrpc,<<"2.0">>},
{id,5},
{method,<<"ServiceAPI.GetDefragmentedUtilization">>},
{params,[{[{serviceApiVersion,"1.0"}]}]}]}
[json_rpc:debug,2022-09-19T12:45:10.755-07:00,[email protected]:json_rpc_connection-fts-service_api<0.867.0>:json_rpc_connection:handle_info:89]got response: [{<<"id">>,5},
{<<"result">>,null},
{<<"error">>,
<<"json: cannot unmarshal array into Go value of type map[string]int">>}]
c.enc.Encode(resp)
type serverResponse struct {
Id *json.RawMessage `json:"id"`
Result any `json:"result"`
Error any `json:"error"`
}
enc *json.Encoder // for writing JSON values
repo init -u https://github.com/couchbase/build-manifests.git -g all -m couchbase-server/neo/7.1.2.xml
Upgrading config by changes
chronicle_upgrade
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t1&bucketType=membase&ramQuota=4000&width=1&weight=1'
POST http://127.0.0.1:9000/controller/rebalance
ejectedNodes:
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "knownNodes='[email protected], [email protected], [email protected], [email protected]'"
[ns_server:info,2022-10-05T16:42:24.139-07:00,[email protected]:<0.4173.0>:ns_orchestrator:idle:806]Starting rebalance, KeepNodes = ['[email protected]','[email protected]',
'[email protected]','[email protected]'], EjectNodes = [], Failed over and being ejected nodes = [], Delta recovery nodes = ['[email protected]'], Delta recovery buckets = all; Operation Id = 948dc45db598c3d9a75cd633df43be43
[rebalance:debug,2022-10-05T16:42:24.141-07:00,[email protected]:<0.25372.0>:ns_rebalancer:handle_one_delta_recovery_bucket:1070]Couldn't delta recover bucket t2 because suitable vbucket map is not found in the history
[rebalance:debug,2022-10-05T16:42:24.141-07:00,[email protected]:<0.25372.0>:ns_rebalancer:handle_one_delta_recovery_bucket:1070]Couldn't delta recover bucket t1 because suitable vbucket map is not found in the history
[ns_server:info,2022-10-05T16:42:24.141-07:00,[email protected]:<0.4173.0>:ns_orchestrator:idle:830]Rebalance <<"948dc45db598c3d9a75cd633df43be43">> was not started due to error: delta_recovery_not_possible
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected],[email protected],[email protected]"
{"deltaRecoveryNotPossible":1}
[ns_server:debug,2022-10-05T17:29:49.404-07:00,[email protected]:<0.1482.0>:ns_rebalancer:start_link_rebalance:231]BLAH START {['[email protected]','[email protected]','[email protected]',
[],[],
['[email protected]'],
all}
DeltaNodes = ['[email protected]']
delta_recovery_buckets = all
[rebalance:debug,2022-10-05T17:31:55.542-07:00,[email protected]:<0.12879.0>:ns_rebalancer:handle_one_delta_recovery_bucket:1072]Couldn't delta recover bucket t2 because suitable vbucket map is not found in the history
[rebalance:debug,2022-10-05T17:31:55.544-07:00,[email protected]:<0.12879.0>:ns_rebalancer:handle_one_delta_recovery_bucket:1072]Couldn't delta recover bucket t1 because suitable vbucket map is not found in the history
-----------------------------------------------
[ns_server:debug,2022-10-05T17:36:22.601-07:00,[email protected]:<0.2566.0>:ns_rebalancer:find_delta_recovery_map:1000]BLAH CurrentOptions [{replication_topology,star},
{tags,
[{'[email protected]',<<"0">>},
{'[email protected]',<<"0">>},
<<"9b13eeaec160eb07d323c2314d2592d9">>},
<<"9b13eeaec160eb07d323c2314d2592d9">>}]},
{use_vbmap_greedy_optimization,true},
{max_slaves,10}]
[ns_server:debug,2022-10-05T17:36:22.602-07:00,[email protected]:<0.2566.0>:ns_rebalancer:find_delta_recovery_map:1001]BLAH History [{[['[email protected]','[email protected]'],
['[email protected]','[email protected]']],
[{replication_topology,star},
{tags,
[{'[email protected]',<<"0">>},
<<"9b13eeaec160eb07d323c2314d2592d9">>}]},
{use_vbmap_greedy_optimization,true},
{max_slaves,10}]},
{[['[email protected]','[email protected]'],
['[email protected]','[email protected]']],
[{replication_topology,star},
{tags,
[{'[email protected]',<<"0">>},
<<"9b13eeaec160eb07d323c2314d2592d9">>}]},
{use_vbmap_greedy_optimization,true},
{max_slaves,10}]},
{[['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined],
['[email protected]',undefined]],
[{replication_topology,star},
{tags,undefined},
{use_vbmap_greedy_optimization,true},
{max_slaves,10}]}]
[ns_server:debug,2022-10-05T17:36:22.603-07:00,[email protected]:<0.2566.0>:ns_rebalancer:find_delta_recovery_map:1002]BLAH MatchingMaps []
[ns_server:debug,2022-10-05T17:36:22.603-07:00,[email protected]:<0.2566.0>:ns_rebalancer:find_delta_recovery_map:1003]BLAH FailoverVBs {dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],
[['[email protected]',0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,
15]],
[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
----------------------------------------------
check_service_quota(kv, Quota, Snapshot) ->
BucketsQuota = get_total_buckets_ram_quota(Snapshot) div ?MIB,
MinMemoryMB = erlang:max(min_quota(kv), BucketsQuota),
check_min_quota(kv, MinMemoryMB, Quota);
handle_pool_settings_post(Req)
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t1&bucketType=membase&ramQuotaMB=500&replicaNumber=2&width=1&weight=1'
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "knownNodes='[email protected]','[email protected]'"
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default -d 'memoryQuota=500'
curl -v -X GET http://Administrator:asdasd@localhost:9000/pools/default | jq
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]"
([email protected])2> ns_cluster_membership:node_services('[email protected]').
[index]
([email protected])3> ns_cluster_membership:get_service_map(direct, index).
([email protected])4> ns_cluster_membership:get_service_map(direct, kv).
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&[email protected]&services=kv"
([email protected])2> ns_cluster_membership:get_service_map(direct, index).
([email protected])3> ns_cluster_membership:node_services('[email protected]').
[index]
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&[email protected]&services=kv"
{error, io_lib:format("Unknown server given: ~p", [Bad])}
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/failOver -d "otpNode=blah"
[85,110,107,110,111,119,110,32,115,101,114,118,101,114,32,103,105,118,101,110,58,32,[91,["\"blah\""],93]]
[ns_server:debug,2022-10-21T16:32:50.825-07:00,[email protected]:<0.1431.0>:ns_orchestrator:get_unitialized_services:1621]BLAH SN #{bucket_names =>
{["test"],{<<"11c039b0a5b190131bb5bd1422ec7587">>,208}},
nodes_wanted =>
{['[email protected]','[email protected]'],
{<<"11c039b0a5b190131bb5bd1422ec7587">>,192}},
server_groups =>
{[[{uuid,<<"0">>},
{name,<<"Group 1">>},
{nodes,['[email protected]','[email protected]']}]],
{<<"11c039b0a5b190131bb5bd1422ec7587">>,192}},
{service_map,index} =>
{['[email protected]','[email protected]'],
{<<"11c039b0a5b190131bb5bd1422ec7587">>,237}},
{service_map,n1ql} =>
{['[email protected]'],{<<"11c039b0a5b190131bb5bd1422ec7587">>,236}},
{bucket,"test",props} =>
{[{deltaRecoveryMap,undefined},
{num_replicas,1},
{replica_index,false},
{ram_quota,1991245824},
{durability_min_level,none},
{num_vbuckets,16},
{pitr_enabled,false},
{pitr_granularity,600},
{pitr_max_history_age,86400},
{autocompaction,false},
{purge_interval,undefined},
{flush_enabled,false},
{num_threads,3},
{eviction_policy,value_only},
{conflict_resolution_type,seqno},
{storage_mode,couchstore},
{max_ttl,0},
{compression_mode,passive},
{type,membase},
{replication_topology,star},
{repl_type,dcp},
{servers,['[email protected]','[email protected]']},
{map_opts_hash,42591107},
{map,[['[email protected]','[email protected]'],
['[email protected]','[email protected]']]},
{fastForwardMap,undefined}],
{<<"11c039b0a5b190131bb5bd1422ec7587">>,235}},
{bucket,"test",uuid} =>
{<<"398cb13ad224980052f2fbf89fe481b4">>,
{<<"11c039b0a5b190131bb5bd1422ec7587">>,208}},
{node,'[email protected]',membership} =>
{active,{<<"11c039b0a5b190131bb5bd1422ec7587">>,220}},
{node,'[email protected]',recovery_type} =>
{none,{<<"11c039b0a5b190131bb5bd1422ec7587">>,216}},
{node,'[email protected]',services} =>
{[index,kv],{<<"11c039b0a5b190131bb5bd1422ec7587">>,14}},
{node,'[email protected]',membership} =>
{active,{<<"11c039b0a5b190131bb5bd1422ec7587">>,220}},
{node,'[email protected]',recovery_type} =>
{none,{<<"11c039b0a5b190131bb5bd1422ec7587">>,216}},
{node,'[email protected]',services} =>
{[index,kv,n1ql],{<<"11c039b0a5b190131bb5bd1422ec7587">>,192}}}
--------------------------------------
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t&bucketType=membase&ramQuotaMB=400&replicaNumber=2&width=1&weight=2'
ns_orchestrator:needs_rebalance()
-spec needs_rebalance() -> boolean().
needs_rebalance() ->
NodesWanted = ns_node_disco:nodes_wanted(),
ServicesNeedRebalance =
lists:any(fun (S) ->
service_needs_rebalance(S, NodesWanted)
end, ns_cluster_membership:cluster_supported_services()),
ServicesNeedRebalance orelse buckets_need_rebalance(NodesWanted).
service_needs_rebalance(Service, NodesWanted) ->
ServiceNodes = ns_cluster_membership:service_nodes(NodesWanted, Service),
ActiveServiceNodes = ns_cluster_membership:service_active_nodes(Service),
lists:sort(ServiceNodes) =/= lists:sort(ActiveServiceNodes) orelse
topology_aware_service_needs_rebalance(Service, ActiveServiceNodes).
{node, Node, services} = get_service_map(Snapshot, Service)
{service_status, Service}, needs_rebalance
ns_rebalancer:bucket_needs_rebalance
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&[email protected]&services=kv"
--------------------------------------------------------
There could potential be one issue here in the following example.
1. On a single node cluster (n1: [kv, index, fts]) we seem to set the service_map in the janitor ->
https://src.couchbase.org/source/xref/trunk/ns_server/src/service_janitor.erl?r=91e43c8d#118
2. If a rebalance request (n1: [kv, index, fts], n2: [kv], services: [kv]) is attempted before the janitor is run - we might reject it because the service_map for that service isn't updated yet.
--------------------------------------------------------
prepare_rebalance(LiveNodes),
It feels like there is a lot of code in this function that need not be run when only Services "other than kv" are being rebalanced, Artem. Like for example:
1. This prepare_rebalance call and unprepare_rebalance vall which sets/unsets the Pid of ns_rebalancer on each of the rebalance_agent on 'LiveNodes'.
2. master_activity_events for kv below at line 527 and 572 could be avoided.
3. Not sure - but will it be guaranteed that delta-recovery buckets list will be empty when non-kv services are being rebalanced? Else code in line 549 might execute.
1. I'm not sure that this is so and I'm playing safe for now. It doesn't harm to call these 2 funs. But I'll research if these calls can be skipped.
2. I left these calls there since we still doing some work in this section. Not too pretty, but I'm not ready to drop them.
3. I'll add the validation check on this in subsequent commit.
rebalance_agent: https://review.couchbase.org/c/ns_server/+/109779/
Suggestion:
1. rebalance_agent should run on KV nodes only and only if KV is being rebalanced
2. deactivate_bucket_data_on_unknown_nodes should be done only if KV is being rebalanced
3. should we do run_janitor_pre_rebalance(Bucket) if kv is not being rebalanced?
%% We run the janitor here to make sure that the vbucket map is in sync
%% with the vbucket states.
%% Unfortunately, we need to run it once more in rebalance_kv after
%% the server list for the bucket is updated. So that the states of the
%% vbucket on newly added nodes are applied.
2 purposes:
delta_recovery
deactivate_bucket_data_on_unknown_nodes https://review.couchbase.org/c/ns_server/+/115299/
activate:
janitor_agent - mark_warmed
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t&bucketType=membase&ramQuotaMB=400&replicaNumber=2&width=1&weight=2'
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&services=index"
UninitializedServices = []
[ns_server:debug,2022-11-28T16:28:18.201-08:00,[email protected]:<0.1305.0>:ns_orchestrator:get_uninitialized_services:1663]BLAH 2 [[kv],[index,kv]]
[ns_server:debug,2022-11-28T16:28:18.201-08:00,[email protected]:<0.1305.0>:ns_orchestrator:get_uninitialized_services:1664]BLAH 3 []
[ns_server:debug,2022-11-28T16:28:18.201-08:00,[email protected]:<0.1305.0>:ns_orchestrator:validate_services:1635]BLAH 1 {['[email protected]','[email protected]'],[index],[kv],[]}
[[],
--------------------------------
2 nodes, one bucket width 2, remove one node.
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets -d 'name=t1&bucketType=membase&ramQuotaMB=500&replicaNumber=2&width=1&weight=1'
curl -v -X POST http://Administrator:asdasd@localhost:9000/pools/default/buckets/t1 -d 'width=2'
curl -v -X POST http://Administrator:asdasd@localhost:9000/controller/rebalance -d "[email protected],[email protected]&[email protected]&services=kv"
curl -v -X GET http://Administrator:asdasd@localhost:9000/pools/default/buckets | jq
--------------------------------------------
delete_unused_buckets_db_files
maybe_cleanup_old_buckets
6 node cluster (2 nodes on each server_group)
Created magma bucket with width=1
Updated width=2 then rebalance
Again update bucket_width=1 and rebalance (defragment method)
Rebalace again (defragment)
parse_ini_file(IniFile, Dict) ->
...................
%% ets:delete(TableId, {AccSectionName, ValueName}),
dict:erase({AccSectionName, ValueName},
-----------------------------------
vbucket_map_history
SET update_vbucket_map_history
janitor, set_initial_map, when the map is balanced
rebalancer, before running mover
GET past_vbucket_maps
MB-28829 Make the check for delta recovery map stricter.
It will not only check that the delta recovery nodes have the desired
vbuckets, but also that the set of vbuckets on other nodes does not
change.