-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1423 lines (1234 loc) · 42.1 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>LogCabin - usage, operation, and internals</title>
<meta name="description" content="Usage, operations, and internals of LogCabin, a Raft-based storage system">
<meta name="author" content="Diego Ongaro">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="reveal.js/css/theme/solarized.css" id="theme">
<style>
.reveal .slides {
text-align: left;
}
.reveal h1 {
font-size: 2.0em;
}
.reveal h2 {
font-size: 1.8em;
}
.reveal h1,
.reveal h2,
.reveal h3,
.reveal h4,
.reveal h5,
.reveal h6 {
text-transform: none; /* was uppercase */
margin: 0 0 15px 0;
font-family: 'Lato', sans-serif;
text-align: center;
}
.center {
text-align: center;
}
.reveal .fill, .fill {
min-width: 100%;
min-height: 100%;
max-width: 100%;
max-height: 100%;
}
.reveal img.center, img.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.flex {
display: flex;
}
ul.small, span.small {
font-size: .8em;
}
pre.small{
font-size: .4em;
}
</style>
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>LogCabin</h1>
<h3>usage, operation, and internals</h3>
<img src="logo.svg" style="float: right; height: 400px; width: auto; margin-right: 10%; border: 0; box-shadow: none" />
<p style="font-size: .6em; max-width: 40%; padding-top: 100px">
<em>Preface:</em>
Diego Ongaro hastily prepared and presented this talk at Scale
Computing's Engineering Week in July 2015. Though its organization is
poor, it contains some good content, some of which cannot be found
elsewhere.
<br />
There's sort of two axes to this talk: (1) usage, operations,
internals, and (2) aspect of LogCabin such as writes, reads, membership
changes, compaction.
Right now it's all mushed together. On the next revision,
it'd be better to do a conceptual overview, then organize by (2),
interspersing the (1)s.
</p>
<p style="font-size: .4em; clear: both;">
Copyright 2015 Diego Ongaro.
<br />
Source code available at <a href="https://github.com/logcabin/logcabin-talk">https://github.com/logcabin/logcabin-talk</a>.
<br />
This work is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
<br />
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img style="margin: 2px; border: 0; box-shadow: none" alt="Creative Commons License" style="border-width:0" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAPCAIAAAD8q9/YAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAISSURBVHjaYmAYYYARiP///z9SfMvIyAJhrdm0Glliz669M6fO7OjoKC8vx9Tm6up66tSptu5WcQlxIFdeVsHVyfXjh4+D3LeQeGXClHj54uXyxctx+RYIdu/ebWZmNrl/CoT74eOHwoLCoRLJWDy8fMkKYWFhXL6FAGBw3Lxxc8PajUD2x08fPHw8vH28h6qHL128lJ6eDmScPXtWWVkZmO6Bafj9+/dAEsgGigDFjY2NXVxcrl29BjWFiQnIRUs/EICcnDDZA+/hSxcvf/70GegfIDssLAzIALoPSHZ2dgL9+e7dO2DM37t3DygLFLxz+w48VQMTOWYJAQQQ78EZQBLIHkQe/vrlC5AUFBQERinQYxCfAxMwkK2kpAQUT0tLCw0NhRXxUKf//PmDkYURs5BA9h7EzwPrWywe5ubhAZJA3wL9BvQhMFYhxTKQC/QzULyiomLWrFloiZOdneP/n/94Ynjw5mE9fV1eXl6IP4ERu2fPHqCjgT4HsoGxLSQkBBSBZNczZ84oKitCdAnwCwArKvwxPLgaHsj1cF9X//Onz+/fv49HGzBETExMouOiA4L9gVxZabnmhuatW7YO8noYGPpYSunouKi3b98AoxSP5rKyMhVVZYhv+fkEdmzZMch9i69aArafUjNTKysr29vbsepxcna6fv16QUkBPD33T+gfbUsP0rb0SOssMQAEGAB0zfzj5yHE/QAAAABJRU5ErkJggg==" /></a>
</p>
</small>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Usage overview
- hierarchical key-value store (tree)
- <em>files</em> and <em>directories</em>, read/written in whole
- consistent: all operations are [linearizable](#/linearizability)
- [conditions](#/conditions)
- timeouts
- working directory
- testing callbacks
</script>
</section>
<section>
<h1>Command-line client</h1>
<pre>
<b>$ logcabin -h</b>
Run various operations on a LogCabin replicated state machine.
Usage: logcabin [options] <command> [<args>]
Commands:
mkdir <path> If no directory exists at <path>, create it.
list <path> List keys within directory at <path>.
dump [<path>] Recursively print keys and values within directory at <path>.
Defaults to printing all keys and values from root of tree.
rmdir <path> Recursively remove directory at <path>, if any.
write <path> Set/create value of file at <path> to stdin.
read <path> Print value of file at <path>.
remove <path> Remove file at <path>, if any.
Options:
-c <addresses>, --cluster=<addresses> Network addresses of the LogCabin
servers, comma-separated
[default: logcabin:5254]
-d <path>, --dir=<path> Set working directory [default: /]
-p <pred>, --condition=<pred> Set predicate on the operation of the
form <path>:<value>, indicating that the key
at <path> must have the given value.
-t <time>, --timeout=<time> Set timeout for the operation
(0 means wait forever) [default: 0s]
</pre>
</section>
<section id="conditions" data-markdown>
<script type="text/template">
# Conditions
- Check value of one key
- Write/remove/whatever a possibly different key
- Example: "If I own this lease, ..."
- Files currently don't have version numbers: comparison based on full value
</script>
</section>
</section>
<section>
<section id="linearizability">
<h1>Linearizability (schedule A)</h1>
<p>
An operation is <em>linearizable</em> if it appears to occur instantaneously and
exactly once at some point in time between its invocation and its response.
</p>
<img src="auto/linearizability-1.svg" class="center stretch" />
</section>
<section>
<h1>Linearizability (schedule B)</h1>
<p>
An operation is <em>linearizable</em> if it appears to occur instantaneously and
exactly once at some point in time between its invocation and its response.
</p>
<img src="auto/linearizability-2.svg" class="center stretch" />
<p>
<span class="small">
For more detail, see
<a href="https://scholar.google.com/scholar?cluster=7860241540823320465&hl=en&as_sdt=1,29">Linearizability: A correctness condition for concurrent objects</a>,
Maurice P. Herlihy and Jeannette M. Wing, 1990; and
<a href="http://www.bailis.org/blog/linearizability-versus-serializability/">Linearizability versus Serializability</a>,
a blog post by Peter Bailis, 2014.
</span>
</p>
</section>
<section data-markdown>
<script type="text/template">
# Linearizability challenges
All reads/writes go through the leader and the log has the linearized
order, so this is easy, right? Wrong.
Client retries and read-only operations.
*Warning:*
The next couple of slides won't make sense unless you're already familiar with
Raft and LogCabin. Consider revisiting these later.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Client retries
Problem:
- Client doesn't receive ack, re-submits command.
- Linearizability requires that each command is executed exactly once.
Solution: client sessions
- Client library opens a session (replicated) before issuing
any read-write requests
- <span class="small">Table of (sequence number, response) pairs.</span>
- If state machine sees command its already applied, replies with earlier
response.
- Client library heartbeats every minute. Servers expire sessions
after an hour. Client library aborts upon use of expired session.
More details in Client Interaction chapter of Raft dissertation.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Read-only queries
In principle, could write these into the log.
Instead, LogCabin treats them separately (for performance):
- Need a round of heartbeats to confirm leader is current.
- New leader in Raft doesn't know which of its entries
have already been committed by prior leaders
- Wait until the leader has committed a new entry to be certain it has the
latest commit index
More details in Client Interaction chapter of Raft dissertation.
</script>
</section>
</section>
<section>
<section>
<h1>Replicated state machines</h1>
<p>LogCabin is one of these.</p>
<img src="rsm.svg" class="center" />
<ul>
<li><em>Replicated log</em> ⇒ replicated state machine</ul>
<ul>
<li>All servers execute same commands in same order</li>
</ul>
<li>Consensus module ensures proper log replication</li>
<li>System makes progress as long as any majority of servers up</li>
<li>Failure model: fail-stop (not Byzantine), delayed/lost msgs</li>
</ul>
</section>
<section data-markdown>
<script type="text/template">
# Internals: Raft
- Leader election (<a href="https://raftconsensus.github.io/raftscope/">RaftScope</a>)
- Log replication
<img src="pipeline.svg" class="center stretch" />
More details in Raft dissertation. Performance chapter discusses write optimization.
</script>
</section>
<section data-markdown>
<script type="text/template">
# Internals: Client interaction
How do clients find the cluster?
- DNS or comma-separated list of hosts
- With [membership changes](#/jointconsensus), list should include any server that might be in the cluster
How do clients find the leader?
- No proxying in LogCabin
- Clients connect to a random server
- If that server isn't leader, it says so
- May provide address of current leader
- Clients then try again with another server
- Any time connection is lost, try random server
More details in Client Interaction chapter of Raft dissertation.
</script>
</section>
</section>
<section data-markdown>
<script type="text/template">
# Operation overview
- [Bootstrapping](#/bootstrapping)
- [Changing membership](#/changingmembership)
- [logcabinctl](#/logcabinctl)
</script>
</section>
<section>
<section id="bootstrapping">
<h1>Bootstrapping first server</h1>
<p>Very first server needs to be bootstrapped</p>
<p>Initializes the very first server's log with a configuration entry made up of just itself.</p>
<pre>
<b>Server1$ cat logcabin.conf</b>
serverId = 1
listenAddresses = 192.168.5.12
storagePath = storage
</pre>
<pre>
<b>Server1$ logcabind --config=logcabin.conf --bootstrap</b>
...
Server/RaftConsensus.cc:572 in setConfiguration(): Activating configuration 1:
prev_configuration {
servers {
server_id: 1
addresses: "192.168.5.12"
}
}
Server/Main.cc:346 in main(): Done bootstrapping configuration. Exiting.
...
</pre>
</section>
<section>
<h1>Bootstrapping effects</h1>
<p>The directory structure shows a single <a href="#/segmentedstorage">log
segment</a> with a single entry, and no <a href="#/snapshotting">snapshot</a>.</p>
<pre>
<b>Server1$ tree -sh --du -F storage</b>
storage
└── [ 16K] server1/
├── [ 0] lock
├── [8.1K] log/
│ └── [4.1K] Segmented-Binary/
│ ├── [ 51] 00000000000000000001-00000000000000000001
│ ├── [ 35] metadata1
│ └── [ 35] metadata2
└── [4.0K] snapshot/
</pre>
</section>
<section>
<h1>Bootstrapped log contents</h1>
<p><code>logcabin-storage</code> dumps out the log.</p>
<pre class="small">
<b>Server1$ logcabin-storage --config=logcabin.conf</b>
...
Storage/Tool.cc:255 in main(): Log contents start
Log:
metadata start:
current_term: 1
voted_for: 0
end of metadata
startIndex: 1
Entry 1 start:
term: 1
type: CONFIGURATION
configuration {
prev_configuration {
servers {
server_id: 1
addresses: "192.168.5.12"
}
}
}
index: 1
cluster_time: 0
end of entry 1
Storage/Tool.cc:257 in main(): Log contents end
...
Storage/Tool.cc:260 in main(): Reading snapshot at storage/server1
Storage/Tool.cc:153 in readSnapshot(): Snapshot file not found in storage/server1/snapshot
</pre>
</section>
</section>
<section>
<section id="changingmembership">
<h1>Adding servers: starting them</h1>
<p>First, let's start up the servers.</p>
<pre>
<b>Server2$ cat logcabin.conf</b>
serverId = 2
listenAddresses = 192.168.5.13
storagePath = storage
</pre>
<pre>
<b>Server3$ cat logcabin.conf</b>
serverId = 3
listenAddresses = 192.168.5.14
storagePath = storage
</pre>
<pre>
<b>Server1$ logcabind --config=logcabin.conf --daemon --log=server1.log</b>
<b>Server2$ logcabind --config=logcabin.conf --daemon --log=server2.log</b>
<b>Server3$ logcabind --config=logcabin.conf --daemon --log=server3.log</b>
</pre>
</section>
<section>
<h1>Adding servers: first becomes leader</h1>
<p>The first server (<a href="#/bootstrapping">bootstrapped</a>) gets to become leader of itself.</p>
<pre class="small">
<b>$ logcabinctl --server=$SERVER1IP stats get</b>
...
server_id: 1
addresses: "192.168.5.12"
...
raft {
current_term: 2
<b>state: LEADER</b>
commit_index: 6
last_log_index: 6
leader_id: 1
voted_for: 1
...
last_snapshot_index: 0
last_snapshot_bytes: 0
log_start_index: 1
log_bytes: 679
...
peer {
server_id: 1
addresses: "192.168.5.12"
old_member: true
new_member: false
staging_member: false
last_synced_index: 6
}
}
...
</pre>
</section>
<section>
<h1>Adding servers: others idle</h1>
<p>Other servers just sit idle, since they don't have a configuration.</p>
<pre class="small">
<b>$ logcabinctl --server=$SERVER2IP stats get</b>
...
server_id: 2
addresses: "192.168.5.13"
...
raft {
current_term: 0
<b>state: FOLLOWER</b>
commit_index: 0
last_log_index: 0
<b>leader_id: 0</b>
voted_for: 0
...
last_snapshot_index: 0
last_snapshot_bytes: 0
log_start_index: 1
log_bytes: 1
...
peer {
server_id: 2
addresses: ""
old_member: false
new_member: false
staging_member: false
}
}
...
</pre>
</section>
<section>
<h1>Adding servers: reconfigure</h1>
<p>We can ask the leader to add the other two.</p>
<pre>
<b>$ export CLUSTER=$SERVER1IP,$SERVER2IP,$SERVER3IP</b>
<b>$ logcabin-reconfigure --cluster=$CLUSTER set $SERVER1IP $SERVER2IP $SERVER3IP</b>
Current configuration:
Configuration 1:
- 1: 192.168.5.12
Attempting to change cluster membership to the following:
1: 192.168.5.12 (given as 192.168.5.12)
2: 192.168.5.13 (given as 192.168.5.13)
3: 192.168.5.14 (given as 192.168.5.14)
Membership change result: OK
Current configuration:
Configuration 11:
- 1: 192.168.5.12
- 2: 192.168.5.13
- 3: 192.168.5.14
</pre>
</section>
<section>
<h1>Adding servers: done</h1>
<p>Now servers 2 and 3 are part of the cluster, have the latest configuration, and are proper followers.</p>
<pre class="small">
<b>$ logcabinctl --server=$SERVER2IP stats get</b>
...
raft {
current_term: 17
state: FOLLOWER
commit_index: 1045
last_log_index: 1045
leader_id: 1
voted_for: 0
...
peer {
server_id: 1
addresses: "192.168.5.12"
old_member: true
new_member: false
staging_member: false
}
peer {
server_id: 2
addresses: "192.168.5.13"
old_member: true
new_member: false
staging_member: false
}
peer {
server_id: 3
addresses: "192.168.5.14"
old_member: true
new_member: false
staging_member: false
}
}
</pre>
</section>
</section>
<section>
<section id="jointconsensus">
<h1>Joint consensus: intro</h1>
<p>LogCabin uses the <em>joint consensus</em> approach to Raft membership changes.</p>
<ul>
<li>Older form of membership changes, prior to single-server approach.</li>
<ul>
<li>Just for historical reasons</li>
<li>Somewhat more complex</li>
<li>More flexible</li>
</ul>
<li>Allows transitioning from one cluster to another arbitrarily.</li>
<ul>
<li>Can add/remove multiple servers at once</li>
<li>No need for any overlap</li>
</ul>
<li>Cluster remains available throughout the change</li>
<ul>
<li>Except if leader is not in new cluster, leader election gap</li>
</ul>
</ul>
<p>More details in Membership Changes chapter of Raft dissertation.</p>
</section>
<section>
<h1>Joint consensus: procedure</h1>
<ol>
<li>Leader catches up new servers with the latest snapshot and (most) log entries.</li>
<li>Leader appends a transitional configuration entry to its log. Under this configuration, becoming leader and committing entries requires both:</li>
<ul>
<li>a majority of the old configuration, and</li>
<li>a majority of the new configuration.</li>
</ul>
</li>
<li>Leader commits transitional configuration entry.</li>
<li>Leader appends new configuration entry to its log.</li>
<li>Leader commits new configuration entry.</li>
</ol>
<p>More details in Membership Changes chapter of Raft dissertation.</p>
</section>
<section>
<h1>Joint consensus: debug log</h1>
<p>Log from adding servers after bootstrapping</p>
<pre class="small">
<b>Server1$ cat server1.log</b>
...
Server/RaftConsensus.cc:1595 in setConfiguration(): Attempting to change the configuration from 1
Server/RaftConsensus.cc:1603 in setConfiguration(): Adding server 1 at 192.168.5.12 to staging servers
Server/RaftConsensus.cc:1603 in setConfiguration(): Adding server 2 at 192.168.5.13 to staging servers
Server/RaftConsensus.cc:1603 in setConfiguration(): Adding server 3 at 192.168.5.14 to staging servers
...
Server/RaftConsensus.cc:1625 in setConfiguration(): Done catching up servers
Server/RaftConsensus.cc:1650 in setConfiguration(): Writing transitional configuration entry
...
Server/RaftConsensus.cc:572 in setConfiguration(): Activating configuration 10:
prev_configuration {
servers { server_id: 1, addresses: "192.168.5.12" }
}
next_configuration {
servers { server_id: 1, addresses: "192.168.5.12" },
servers { server_id: 2, addresses: "192.168.5.13" },
servers { server_id: 3, addresses: "192.168.5.14" }
}
Server/RaftConsensus.cc:572 in setConfiguration(): Activating configuration 11:
prev_configuration {
servers { server_id: 1, addresses: "192.168.5.12" },
servers { server_id: 2, addresses: "192.168.5.13" },
servers { server_id: 3, addresses: "192.168.5.14" }
}
...
</pre>
</section>
<section>
<h1>Joint consensus: arbitrary cluster changes</h1>
<pre class="small">
<b>$ logcabin-reconfigure --cluster=$CLUSTER set $SERVER1IP</b>
Current configuration:
Configuration 11:
- 1: 192.168.5.12
- 2: 192.168.5.13
- 3: 192.168.5.14
Attempting to change cluster membership to the following:
1: 192.168.5.12 (given as 192.168.5.12)
Membership change result: OK
Current configuration:
Configuration 2357:
- 1: 192.168.5.12
<b>$ logcabin-reconfigure --cluster=$CLUSTER set $SERVER2IP $SERVER3IP</b>
Current configuration:
Configuration 2357:
- 1: 192.168.5.12
Attempting to change cluster membership to the following:
2: 192.168.5.13 (given as 192.168.5.13)
3: 192.168.5.14 (given as 192.168.5.14)
<b>[...wait for leader election...]</b>
Membership change result: OK
Current configuration:
Configuration 2378:
- 2: 192.168.5.13
- 3: 192.168.5.14
</pre>
</section>
</section>
<section>
<h1>Intro snapshotting</h1>
<p>Snapshotting is discussed <a href="#/snapshotting">later</a>,
but you'll probably need some concept of it to understand half of
logcabinctl.</p>
<p>Goal: reclaim log space</p>
<img src="snapshot.svg" class="stretch center" />
</section>
<section>
<section id="logcabinctl">
<h1>logcabinctl</h1>
<pre>
<b>$ logcabinctl --help</b>
Inspect or modify the state of a single LogCabin server.
...
Commands:
info get Print server ID and addresses.
debug filename get Print the server's debug log filename.
debug filename set <path> Change the server's debug log filename.
debug policy get Print the server's debug log policy.
debug policy set <value> Change the server's debug log policy.
debug rotate Rotate the server's debug log file.
snapshot inhibit get Print the remaining time for which the server
was prevented from taking snapshots.
snapshot inhibit set [<time>] Abort the server's current snapshot if one is
in progress, and disallow the server from
starting automated snapshots for the given
duration [default: 1week].
snapshot inhibit clear Allow the server to take snapshots normally.
snapshot start Begin taking a snapshot if none is in progress.
snapshot stop Abort the current snapshot if one is in
progress.
snapshot restart Abort the current snapshot if one is in
progress, then begin taking a new snapshot.
stats get Print detailed server metrics.
stats dump Write detailed server metrics to server's debug
log.
</pre>
</section>
<section>
<h1>Forcing a <a href="#/snapshotting">snapshot</a></h1>
<pre>
<b>$ logcabinctl --server=$SERVER1IP stats get | grep bytes</b>
last_snapshot_bytes: 0
log_bytes: 744921
open_segment_bytes: 744867
</pre>
<pre>
<b>$ logcabinctl --server=$SERVER1IP snapshot start</b>
</pre>
...wait a second...
<pre>
<b>$ logcabinctl --server=$SERVER1IP stats get | grep bytes</b>
last_snapshot_bytes: 2785
log_bytes: 1863
open_segment_bytes: 1863
</pre>
</section>
<section>
<h1>Inhibiting <a href="#/snapshotting">snapshots</a></h1>
<p><code>scqad</code> (runs Scale's distributed tests) prevents automatic snapshots for one week after a test failure.</p>
<pre>
<b>$ logcabinctl --server=$SERVER1IP snapshot inhibit set 1week</b>
<b>$ logcabinctl --server=$SERVER1IP snapshot inhibit get</b>
604795.121117807 s
</pre>
<p>Allows you to see more Raft log history with <code>logcabin-storage</code>.</p>
<p>Undo:</p>
<pre>
<b>$ logcabinctl --server=$SERVER1IP snapshot inhibit clear</b>
<b>$ logcabinctl --server=$SERVER1IP snapshot inhibit get</b>
0 ns
</pre>
</section>
<section>
<h1>Changing debug log verbosity</h1>
<p>Change the server's verbosity at runtime</p>
<pre>
<b>$ logcabinctl --server=$SERVER1IP debug policy get</b>
NOTICE
<b>$ logcabinctl --server=$SERVER1IP debug policy set \</b>
<b> Server/RaftConsensus.cc@VERBOSE,Storage@WARNING,NOTICE</b>
</pre>
<pre>
<b>Server1$ tail server1.log</b>
Server/RaftConsensus.cc:1393 in handleAppendEntries() VERBOSE: New commitIndex: 4997
Server/RaftConsensus.cc:2804 in setElectionTimer() VERBOSE: Will become candidate in 581 ms
...
</pre>
<p>Clients have similar control with:</p>
<pre><code class="cpp" data-trim>
LogCabin::Client::Debug::setLogPolicy(
LogCabin::Client::Debug::logPolicyFromString(
"Client@VERBOSE,NOTICE"));
</code></pre>
<p>Set server's default verbosity in config file</p>
</section>
</section>
<section data-markdown>
<script type="text/template">
# Development overview
- [Code walkthrough](#/codewalkthrough)
- [Testing strategy/tools](#/testing)
- [Monitor-style classes](#/monitors)
- [Upgrades and compatibility](#/upgrades)
</script>
</section>
<section>
<section id="codewalkthrough">
<h1>Code walkthrough</h1>
<img src="auto/directories.svg" class="center stretch" />
</section>
<section data-transition="none">
<h1>Core/</h1>
<div class="flex">
<div><img src="auto/directories-Core.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Random</li>
<li>Time (C++11) </li>
<li>Mutex, condition variable</li>
<li>STL and string utilities</li>
<li>Checksumming (Crypto++)</li>
<li>Debug logging</li>
<li>Config file</li>
<li>Buffer (ptr, len)</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Event/</h1>
<div class="flex">
<div><img src="auto/directories-Event.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Event loop (epoll)</li>
<li>Singals</li>
<li>Timers</li>
<li>File descriptors</li>
<li><code>Event::Loop::Lock</code>:
<ul>
<li>block event loop thread in user-space outside of any handler</li>
<li>used when removing monitored files</li>
</ul>
</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>RPC/</h1>
<div class="flex">
<div><img src="auto/directories-RPC.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Low-level framing protocol</li>
<li>Application-level connection initiation timeout and heartbeats</li>
<li>Higher-level RPC protocol</li>
<li><code>Address</code>: DNS resolution</li>
<li><em>Service</em>: RPC endpoint</li>
<li>Thread dispatch for most services</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Protocol/</h1>
<div class="flex">
<div><img src="auto/directories-Protocol.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Mostly Protocol Buffer definitions for individual RPC types</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Server/</h1>
<div class="flex">
<div><img src="auto/directories-Server.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Raft implementation</li>
<li>State machine</li>
<ul>
<li>Client sessions</li>
<li>Forking</li>
</ul>
<li>Daemon startup (<code>Globals</code>)</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Storage/</h1>
<div class="flex">
<div><img src="auto/directories-Storage.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>In-memory and on-disk log</li>
<li>Opens/closes snapshot files</li>
<li>Filesystem layout</li>
<li>Filesystem utilities</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Tree/</h1>
<div class="flex">
<div><img src="auto/directories-Tree.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Core data structure for clients</li>
<li>ProtoBuf-to-method call layer</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Client/</h1>
<div class="flex">
<div><img src="auto/directories-Client.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li>Implementation of client library API</li>
<li><code>LeaderRPC</code>: connect to leader</li>
<li><code>MockClientImpl</code>: in-memory Tree used for testing applications</li>
</ul>
</div>
</div>
</section>
<section data-transition="none">
<h1>Examples/</h1>
<div class="flex">
<div><img src="auto/directories-Examples.svg" /></div>
<div style="min-width: 50%; min-height: 100000px">
<!-- giant min-height forces title to top of screen -->
<ul>
<li><code>logcabin-reconfigure</code></li>
<li><code>logcabin</code> CLI tool</li>
<li>Hello world</li>
<li>Benchmark</li>
</ul>
</div>
</div>
</section>
</section>
<section>
<section id="testing" data-markdown>
<script type="text/template">
# Testing strategy: static
- Pre-commit hooks:
- Build with anal compiler settings
- `cpplint.py` style checks
- Doxygen warnings
- No coverage checks
- `hookmatrix.sh` to compile/test on many compilers
- g++ (v4.4 to v4.9, v5.1)
- clang (v3.4 to v3.7 with libstdc++ 4.9 or libc++)
- Have run Coverity, Clang Static Analyzer in the past
- Manual
</script>
</section>