Skip to content

Commit 5c29127

Browse files
Fix rebootstrapping issues in the 'master-master' tutorial (#4149)
1 parent d0aba24 commit 5c29127

File tree

1 file changed

+95
-67
lines changed

1 file changed

+95
-67
lines changed

doc/how-to/replication/repl_bootstrap_master_master.rst

Lines changed: 95 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,13 @@ Checking a replica set status
160160
• Connecting to the instance...
161161
• Connected to master_master:instance001
162162
163+
master_master:instance001>
164+
163165
2. Check that both instances are writable using ``box.info.ro``:
164166

165167
- ``instance001``:
166168

167-
.. code-block:: console
169+
.. code-block:: tarantoolsession
168170
169171
master_master:instance001> box.info.ro
170172
---
@@ -173,7 +175,7 @@ Checking a replica set status
173175
174176
- ``instance002``:
175177

176-
.. code-block:: console
178+
.. code-block:: tarantoolsession
177179
178180
master_master:instance002> box.info.ro
179181
---
@@ -183,30 +185,30 @@ Checking a replica set status
183185
3. Execute ``box.info.replication`` to check a replica set status.
184186
For ``instance002``, ``upstream.status`` and ``downstream.status`` should be ``follow``.
185187

186-
.. code-block:: console
188+
.. code-block:: tarantoolsession
187189
188190
master_master:instance001> box.info.replication
189191
---
190192
- 1:
191193
id: 1
192-
uuid: 4cfa6e3c-625e-b027-00a7-29b2f2182f23
194+
uuid: c3bfd89f-5a1c-4556-aa9f-461377713a2a
193195
lsn: 7
196+
name: instance001
197+
2:
198+
id: 2
199+
uuid: dccf7485-8bff-47f6-bfc4-b311701e36ef
200+
lsn: 0
194201
upstream:
195202
status: follow
196-
idle: 0.21281599999929
203+
idle: 0.93246499999987
197204
peer: replicator@127.0.0.1:3302
198-
lag: 0.00031614303588867
205+
lag: 0.00016188621520996
199206
name: instance002
200207
downstream:
201208
status: follow
202-
idle: 0.21800899999653
209+
idle: 0.8988360000003
203210
vclock: {1: 7}
204211
lag: 0
205-
2:
206-
id: 2
207-
uuid: 9bb111c2-3ff5-36a7-00f4-2b9a573ea660
208-
lsn: 0
209-
name: instance001
210212
...
211213
212214
To see the diagrams that illustrate how the ``upstream`` and ``downstream`` connections look,
@@ -244,7 +246,7 @@ To check that both instances get updates from each other, follow the steps below
244246

245247
2. On ``instance002``, use the ``select`` operation to make sure data is replicated:
246248

247-
.. code-block:: console
249+
.. code-block:: tarantoolsession
248250
249251
master_master:instance002> box.space.bands:select()
250252
---
@@ -260,26 +262,36 @@ To check that both instances get updates from each other, follow the steps below
260262
:language: lua
261263
:dedent:
262264

263-
4. Get back to ``instance001`` and use ``select`` to make sure new records are replicated.
265+
4. Get back to ``instance001`` and use ``select`` to make sure new records are replicated:
266+
267+
.. code-block:: tarantoolsession
268+
269+
master_master:instance001> box.space.bands:select()
270+
---
271+
- - [1, 'Roxette', 1986]
272+
- [2, 'Scorpions', 1965]
273+
- [3, 'Ace of Base', 1987]
274+
- [4, 'The Beatles', 1960]
275+
...
264276
265277
5. Check that :ref:`box.info.vclock <box_introspection-box_info>` values are the same on both instances:
266278

267279
- ``instance001``:
268280

269-
.. code-block:: console
281+
.. code-block:: tarantoolsession
270282
271283
master_master:instance001> box.info.vclock
272284
---
273-
- {2: 5, 1: 9}
285+
- {2: 2, 1: 12}
274286
...
275287
276288
- ``instance002``:
277289

278-
.. code-block:: console
290+
.. code-block:: tarantoolsession
279291
280292
master_master:instance002> box.info.vclock
281293
---
282-
- {2: 5, 1: 9}
294+
- {2: 2, 1: 12}
283295
...
284296
285297
@@ -341,32 +353,33 @@ To insert conflicting records to ``instance001`` and ``instance002``, follow the
341353
Then, check ``box.info.replication`` on ``instance001``.
342354
``upstream.status`` should be ``stopped`` because of the ``Duplicate key exists`` error:
343355

344-
.. code-block:: console
356+
.. code-block:: tarantoolsession
345357
346358
master_master:instance001> box.info.replication
347359
---
348360
- 1:
349361
id: 1
350-
uuid: 4cfa6e3c-625e-b027-00a7-29b2f2182f23
351-
lsn: 9
362+
uuid: c3bfd89f-5a1c-4556-aa9f-461377713a2a
363+
lsn: 13
364+
name: instance001
365+
2:
366+
id: 2
367+
uuid: dccf7485-8bff-47f6-bfc4-b311701e36ef
368+
lsn: 2
352369
upstream:
353370
peer: replicator@127.0.0.1:3302
354-
lag: 143.52251672745
371+
lag: 115.99977827072
355372
status: stopped
356-
idle: 3.9462469999999
373+
idle: 2.0342070000006
357374
message: Duplicate key exists in unique index "primary" in space "bands" with
358-
old tuple - [5, "Pink Floyd", 1965] and new tuple - [5, "incorrect data", 0]
375+
old tuple - [5, "Pink Floyd", 1965] and new tuple - [5, "incorrect data",
376+
0]
359377
name: instance002
360378
downstream:
361379
status: stopped
362-
message: 'unexpected EOF when reading from socket, called on fd 12, aka 127.0.0.1:3301,
363-
peer of 127.0.0.1:59258: Broken pipe'
380+
message: 'unexpected EOF when reading from socket, called on fd 24, aka 127.0.0.1:3301,
381+
peer of 127.0.0.1:58478: Broken pipe'
364382
system_message: Broken pipe
365-
2:
366-
id: 2
367-
uuid: 9bb111c2-3ff5-36a7-00f4-2b9a573ea660
368-
lsn: 6
369-
name: instance001
370383
...
371384
372385
The diagram below illustrates how the ``upstream`` and ``downstream`` connections look like:
@@ -385,48 +398,62 @@ Reseeding a replica
385398
To resolve a replication conflict, ``instance002`` should get the correct data from ``instance001`` first.
386399
To achieve this, ``instance002`` should be rebootstrapped:
387400

388-
1. In the ``config.yaml`` file, change ``database.mode`` of ``instance002`` to ``ro``:
401+
1. Select all the tuples in the :ref:`box.space._cluster <box_space-cluster>` system space to get a UUID of ``instance002``:
402+
403+
.. code-block:: tarantoolsession
404+
405+
master_master:instance001> box.space._cluster:select()
406+
---
407+
- - [1, 'c3bfd89f-5a1c-4556-aa9f-461377713a2a', 'instance001']
408+
- [2, 'dccf7485-8bff-47f6-bfc4-b311701e36ef', 'instance002']
409+
...
410+
411+
2. In the ``config.yaml`` file, change the following ``instance002`` settings:
412+
413+
* Set ``database.mode`` to ``ro``.
414+
* Set ``database.instance_uuid`` to a UUID value obtained in the previous step.
389415

390416
.. code-block:: yaml
391417
392418
instance002:
393419
database:
394420
mode: ro
421+
instance_uuid: 'dccf7485-8bff-47f6-bfc4-b311701e36ef'
395422
396-
2. Reload configurations on both instances using the ``reload()`` function provided by the :ref:`config <config-module>` module:
423+
3. Reload configurations on both instances using the :ref:`config:reload() <config_api_reference_reload>` function:
397424

398425
- ``instance001``:
399426

400-
.. code-block:: console
427+
.. code-block:: tarantoolsession
401428
402429
master_master:instance001> require('config'):reload()
403430
---
404431
...
405432
406433
- ``instance002``:
407434

408-
.. code-block:: console
435+
.. code-block:: tarantoolsession
409436
410437
master_master:instance002> require('config'):reload()
411438
---
412439
...
413440
414-
3. Delete write-ahead logs and snapshots stored in the ``var/lib/instance002`` directory.
441+
4. Delete write-ahead logs and snapshots stored in the ``var/lib/instance002`` directory.
415442

416443
.. NOTE::
417444

418445
``var/lib`` is the default directory used by tt to store write-ahead logs and snapshots.
419446
Learn more from :ref:`Configuration <tt-config>`.
420447

421-
4. Restart ``instance002`` using the :ref:`tt restart <tt-restart>` command:
448+
5. Restart ``instance002`` using the :ref:`tt restart <tt-restart>` command:
422449

423450
.. code-block:: console
424451
425452
$ tt restart master_master:instance002
426453
427-
5. Connect to ``instance002`` and make sure it received the correct data from ``instance001``:
454+
6. Connect to ``instance002`` and make sure it received the correct data from ``instance001``:
428455

429-
.. code-block:: console
456+
.. code-block:: tarantoolsession
430457
431458
master_master:instance002> box.space.bands:select()
432459
---
@@ -448,33 +475,33 @@ After :ref:`reseeding a replica <replication-master-master-reseed-replica>`, you
448475
1. Execute ``box.info.replication`` on ``instance001``.
449476
``upstream.status`` is still stopped:
450477

451-
.. code-block:: console
478+
.. code-block:: tarantoolsession
452479
453480
master_master:instance001> box.info.replication
454481
---
455482
- 1:
456483
id: 1
457-
uuid: 4cfa6e3c-625e-b027-00a7-29b2f2182f23
458-
lsn: 9
484+
uuid: c3bfd89f-5a1c-4556-aa9f-461377713a2a
485+
lsn: 13
486+
name: instance001
487+
2:
488+
id: 2
489+
uuid: dccf7485-8bff-47f6-bfc4-b311701e36ef
490+
lsn: 2
459491
upstream:
460492
peer: replicator@127.0.0.1:3302
461-
lag: 143.52251672745
493+
lag: 115.99977827072
462494
status: stopped
463-
idle: 1309.943383
495+
idle: 1013.688243
464496
message: Duplicate key exists in unique index "primary" in space "bands" with
465497
old tuple - [5, "Pink Floyd", 1965] and new tuple - [5, "incorrect data",
466498
0]
467499
name: instance002
468500
downstream:
469501
status: follow
470-
idle: 0.47881799999959
471-
vclock: {2: 6, 1: 9}
502+
idle: 0.69694700000036
503+
vclock: {2: 2, 1: 13}
472504
lag: 0
473-
2:
474-
id: 2
475-
uuid: 9bb111c2-3ff5-36a7-00f4-2b9a573ea660
476-
lsn: 6
477-
name: instance001
478505
...
479506
480507
The diagram below illustrates how the ``upstream`` and ``downstream`` connections look like:
@@ -497,13 +524,14 @@ After :ref:`reseeding a replica <replication-master-master-reseed-replica>`, you
497524
498525
3. Reload configuration on ``instance001`` only:
499526

500-
.. code-block:: console
527+
.. code-block:: tarantoolsession
501528
502529
master_master:instance001> require('config'):reload()
503530
---
504531
...
505532
506-
4. Change ``database.mode`` values back to ``rw`` for both instances and restore ``iproto.listen`` for ``instance001``:
533+
4. Change ``database.mode`` values back to ``rw`` for both instances and restore ``iproto.listen`` for ``instance001``.
534+
The ``database.instance_uuid`` option can be removed for ``instance002``:
507535

508536
.. literalinclude:: /code_snippets/snippets/replication/instances.enabled/master_master/config.yaml
509537
:language: yaml
@@ -515,15 +543,15 @@ After :ref:`reseeding a replica <replication-master-master-reseed-replica>`, you
515543

516544
- ``instance001``:
517545

518-
.. code-block:: console
546+
.. code-block:: tarantoolsession
519547
520548
master_master:instance001> require('config'):reload()
521549
---
522550
...
523551
524552
- ``instance002``:
525553

526-
.. code-block:: console
554+
.. code-block:: tarantoolsession
527555
528556
master_master:instance002> require('config'):reload()
529557
---
@@ -532,30 +560,30 @@ After :ref:`reseeding a replica <replication-master-master-reseed-replica>`, you
532560
6. Check ``box.info.replication``.
533561
``upstream.status`` should be ``follow`` now.
534562

535-
.. code-block:: console
563+
.. code-block:: tarantoolsession
536564
537565
master_master:instance001> box.info.replication
538566
---
539567
- 1:
540568
id: 1
541-
uuid: 4cfa6e3c-625e-b027-00a7-29b2f2182f23
542-
lsn: 9
569+
uuid: c3bfd89f-5a1c-4556-aa9f-461377713a2a
570+
lsn: 13
571+
name: instance001
572+
2:
573+
id: 2
574+
uuid: dccf7485-8bff-47f6-bfc4-b311701e36ef
575+
lsn: 2
543576
upstream:
544577
status: follow
545-
idle: 0.21281300000192
578+
idle: 0.86873800000012
546579
peer: replicator@127.0.0.1:3302
547-
lag: 0.00031113624572754
580+
lag: 0.0001060962677002
548581
name: instance002
549582
downstream:
550583
status: follow
551-
idle: 0.035179000002245
552-
vclock: {2: 6, 1: 9}
584+
idle: 0.058662999999797
585+
vclock: {2: 2, 1: 13}
553586
lag: 0
554-
2:
555-
id: 2
556-
uuid: 9bb111c2-3ff5-36a7-00f4-2b9a573ea660
557-
lsn: 6
558-
name: instance001
559587
...
560588
561589

0 commit comments

Comments
 (0)