This file is indexed.

/usr/share/doc/slony1-2-doc/adminguide/failover.html is in slony1-2-doc 2.2.5-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Doing switchover and failover with Slony-I</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:slony1-general@lists.slony.info"><LINK
REL="HOME"
TITLE="Slony-I 2.2.5 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Administration Tasks"
HREF="administration.html"><LINK
REL="PREVIOUS"
TITLE="Database Schema Changes (DDL)"
HREF="ddlchanges.html"><LINK
REL="NEXT"
TITLE="Advanced Concepts"
HREF="advanced.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> 2.2.5 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="ddlchanges.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="administration.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. Administration Tasks</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="administration.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="advanced.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="FAILOVER"
>3.4. Doing switchover and failover with <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
></A
></H1
><A
NAME="AEN1223"
></A
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1226"
>3.4.1. Foreword</A
></H2
><P
><SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> is an asynchronous replication system.  Because of
that, it is almost certain that at the moment the current origin of a
set fails, the final transactions committed at the origin will have
not yet propagated to the subscribers.  Systems are particularly
likely to fail under heavy load; that is one of the corollaries of
Murphy's Law.  Therefore the principal goal is to
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>prevent</I
></SPAN
> the main server from failing.  The best
way to do that is frequent maintenance.</P
><P
> Opening the case of a running server is not exactly what we
should consider a <SPAN
CLASS="QUOTE"
>"professional"</SPAN
> way to do system
maintenance.  And interestingly, those users who found it valuable to
use replication for backup and failover purposes are the very ones
that have the lowest tolerance for terms like <SPAN
CLASS="QUOTE"
>"system
downtime."</SPAN
> To help support these requirements, <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> not
only offers failover capabilities, but also the notion of controlled
origin transfer.</P
><P
> It is assumed in this document that the reader is familiar with
the <A
HREF="slonik.html"
><SPAN
CLASS="APPLICATION"
>slonik</SPAN
></A
> utility and knows at least how to set up a
simple 2 node replication system with <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
>.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1238"
>3.4.2. Controlled Switchover</A
></H2
><A
NAME="AEN1240"
></A
><P
> We assume a current <SPAN
CLASS="QUOTE"
>"origin"</SPAN
> as node1 with one
<SPAN
CLASS="QUOTE"
>"subscriber"</SPAN
> as node2 (<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>e.g.</I
></SPAN
> -
slave).  A web application on a third server is accessing the database
on node1.  Both databases are up and running and replication is more
or less in sync.  We do controlled switchover using <A
HREF="stmtmoveset.html"
>SLONIK MOVE SET</A
>.</P
><P
></P
><UL
><LI
><P
> At the time of this writing switchover to another
server requires the application to reconnect to the new database.  So
in order to avoid any complications, we simply shut down the web
server.  Users who use <SPAN
CLASS="APPLICATION"
>pg_pool</SPAN
> for the
applications database connections merely have to shut down the
pool.</P
><P
> What needs to be done, here, is highly dependent on the way
that the application(s) that use the database are configured.  The
general point is thus: Applications that were connected to the old
database must drop those connections and establish new connections to
the database that has been promoted to the <SPAN
CLASS="QUOTE"
>"master"</SPAN
> role.  There
are a number of ways that this may be configured, and therefore, a
number of possible methods for accomplishing the change:</P
><P
></P
><UL
><LI
><P
> The application may store the name of the database in
a file.</P
><P
> In that case, the reconfiguration may require changing the
value in the file, and stopping and restarting the application to get
it to point to the new location.</P
></LI
><LI
><P
> A clever usage of DNS might involve creating a CNAME
<A
HREF="http://www.iana.org/assignments/dns-parameters"
TARGET="_top"
> DNS
record </A
> that establishes a name for the application to use to
reference the node that is in the <SPAN
CLASS="QUOTE"
>"master"</SPAN
> role.</P
><P
> In that case, reconfiguration would require changing the CNAME
to point to the new server, and possibly restarting the application to
refresh database connections.</P
></LI
><LI
><P
> If you are using <SPAN
CLASS="APPLICATION"
>pg_pool</SPAN
> or some
similar <SPAN
CLASS="QUOTE"
>"connection pool manager,"</SPAN
> then the reconfiguration
involves reconfiguring this management tool, but is otherwise similar
to the DNS/CNAME example above.  </P
></LI
></UL
><P
> Whether or not the application that accesses the database needs
to be restarted depends on how it is coded to cope with failed
database connections; if, after encountering an error it tries
re-opening them, then there may be no need to restart it. </P
></LI
><LI
><P
> A small <A
HREF="slonik.html"
><SPAN
CLASS="APPLICATION"
>slonik</SPAN
></A
> script executes the
following commands:

</P><PRE
CLASS="PROGRAMLISTING"
>lock set (id = 1, origin = 1);
wait for event (origin = 1, confirmed = 2, wait on=1);
move set (id = 1, old origin = 1, new origin = 2);
wait for event (origin = 1, confirmed = 2, wait on=1);</PRE
><P></P
><P
> After these commands, the origin (master role) of data set 1
has been transferred to node2.  And it is not simply transferred; it
is done in a fashion such that node1 becomes a fully synchronized
subscriber, actively replicating the set.  So the two nodes have
switched roles completely.</P
></LI
><LI
><P
> After reconfiguring the web application (or
<SPAN
CLASS="APPLICATION"
><A
HREF="help.html#PGPOOL"
> pgpool </A
></SPAN
>) to
connect to the database on node2, the web server is restarted and
resumes normal operation.</P
><P
> Done in one shell script, that does the application shutdown,
<SPAN
CLASS="APPLICATION"
>slonik</SPAN
>, move config files and startup all
together, this entire procedure is likely to take less than 10
seconds.</P
></LI
></UL
><P
> You may now simply shutdown the server hosting node1 and do
whatever is required to maintain the server.  When <A
HREF="slon.html"
><SPAN
CLASS="APPLICATION"
>slon</SPAN
></A
> node1 is restarted later, it will start replicating
again, and soon catch up.  At this point the procedure to switch
origins is executed again to restore the original
configuration.</P
><P
> This is the preferred way to handle things; it runs quickly,
under control of the administrators, and there is no need for there to
be any loss of data.</P
><P
> After performing the configuration change, you should, run the 
<A
HREF="deploymentconcerns.html#TESTSLONYSTATE"
>Section 5.1.1</A
> scripts in order to
validate that the cluster state remains in good order after this
change. </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1283"
>3.4.3. Failover</A
></H2
><A
NAME="AEN1285"
></A
><P
> If some more serious problem occurs on the
<SPAN
CLASS="QUOTE"
>"origin"</SPAN
> server, it may be necessary to <A
HREF="stmtfailover.html"
>SLONIK FAILOVER</A
> to a backup server.  This is a highly
undesirable circumstance, as transactions <SPAN
CLASS="QUOTE"
>"committed"</SPAN
> on
the origin, but not applied to the subscribers, will be lost.  You may
have reported these transactions as <SPAN
CLASS="QUOTE"
>"successful"</SPAN
> to
outside users.  As a result, failover should be considered a
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>last resort</I
></SPAN
>.  If the <SPAN
CLASS="QUOTE"
>"injured"</SPAN
>
origin server can be brought up to the point where it can limp along
long enough to do a controlled switchover, that is
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>greatly</I
></SPAN
> preferable.</P
><P
> <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> does not provide any automatic detection for failed
systems.  Abandoning committed transactions is a business decision
that cannot be made by a database system.  If someone wants to put the
commands below into a script executed automatically from the network
monitoring system, well ... it's <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>your</I
></SPAN
> data, and
it's <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>your</I
></SPAN
> failover policy. </P
><P
></P
><UL
><LI
><P
>The <A
HREF="slonik.html"
><SPAN
CLASS="APPLICATION"
>slonik</SPAN
></A
> command
</P><PRE
CLASS="PROGRAMLISTING"
>failover (id = 1, backup node = 2);</PRE
><P></P
><P
> causes node2 to assume the ownership (origin) of all sets that
have node1 as their current origin.  If there should happen to be
additional nodes in the <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> cluster, all direct subscribers of
node1 are instructed that this is happening.
<SPAN
CLASS="APPLICATION"
>Slonik</SPAN
> will also query all direct
subscribers in order to determine out which node has the highest
replication status (<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>e.g.</I
></SPAN
> - the latest committed
transaction) for each set, and the configuration will be changed in a
way that node2 first applies those final before actually allowing
write access to the tables.</P
><P
> In addition, all nodes that subscribed directly to node1 will
now use node2 as data provider for the set.  This means that after the
failover command succeeded, no node in the entire replication setup
will receive anything from node1 any more.</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
> Note that in order for node 2 to be considered as a
candidate for failover, it must have been set up with the <A
HREF="stmtsubscribeset.html"
>SLONIK SUBSCRIBE SET</A
> option <TT
CLASS="COMMAND"
>forwarding =
yes</TT
>, which has the effect that replication log data is
collected in <A
HREF="table.sl-log-1.html"
>sl_log_1</A
>/<A
HREF="table.sl-log-2.html"
>sl_log_2</A
> on node 2.  If replication log data is
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
> being collected, then failover to that node
is not possible. </P
><P
>Only nodes listed in the failover_candidates view
can be used as the failover target for an origin. This is discussed in further detail below.</P
></BLOCKQUOTE
></DIV
></LI
><LI
><P
> Reconfigure and restart the application (or
<SPAN
CLASS="APPLICATION"
>pgpool</SPAN
>) to cause it to reconnect to
node2.</P
></LI
><LI
><P
> Purge out the abandoned node </P
><P
> You will find, after the failover, that there are still a full
set of references to node 1 in <A
HREF="table.sl-node.html"
>sl_node</A
>, as well
as in referring tables such as <A
HREF="table.sl-confirm.html"
>sl_confirm</A
>;
since data in <A
HREF="table.sl-log-1.html"
>sl_log_1</A
>/<A
HREF="table.sl-log-2.html"
>sl_log_2</A
> is still present, <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> cannot
immediately purge out the node. </P
><P
> After the failover is complete and all nodes have been
reconfigured you can remove all remnants of node1's
configuration information with the <A
HREF="stmtdropnode.html"
>SLONIK DROP NODE</A
>
command:

</P><PRE
CLASS="PROGRAMLISTING"
>drop node (id = 1, event node = 2);</PRE
><P></P
><P
> Supposing the failure resulted from some catastrophic failure
of the hardware supporting node 1, there might be no
<SPAN
CLASS="QUOTE"
>"remains"</SPAN
> left to look at.  If the failure was not
<SPAN
CLASS="QUOTE"
>"total"</SPAN
>, as might be the case if the node had to be
abandoned due to a network communications failure, you will find that
node 1 still <SPAN
CLASS="QUOTE"
>"imagines"</SPAN
> itself to be as it was before the
failure.  See <A
HREF="failover.html#REBUILDNODE1"
>Section 3.4.7</A
> for more details on the
implications.</P
></LI
><LI
><P
> After performing the configuration change, you
should, as  run the <A
HREF="deploymentconcerns.html#TESTSLONYSTATE"
>Section 5.1.1</A
>
scripts in order to validate that the cluster state remains in good
order after this change. </P
></LI
></UL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="FAILOVERTARGETS"
>3.4.4. Failover Targets</A
></H2
><P
>An origin node can only be failed over to other nodes in the cluster that
are valid failover targets.  The failover targets for a node must meet the 
following conditions</P
><P
></P
><UL
><LI
><P
>The failover target must be a direct subscriber of all sets that
the failed node is an origin for</P
></LI
><LI
><P
>The failover target must have paths to all nodes that the
failed node has paths to</P
></LI
></UL
><P
>The view sl_failover_targets displays the valid failover targets for 
each origin node.  Clusters that have more than two nodes and would like
to have the option of using failover need to be setup in such a way that
valid failover targets exist for the various failure scenarios that 
they wish to support.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="MULTIPLEFAILURES"
>3.4.5. Multiple Node Failures</A
></H2
><P
>If multiple nodes fail at the same time, maybe because an entire data-center has failed,
then all failed nodes should be passed to the failover command. If we consider a cluster where  node 1 the origin of a set and provides a subscription to
node 2 and node 3 then node 2 provides a subscription to node 4, what should happen if  both nodes 1 and 2 fail?
Slony can be told about the failed nodes with the following command
</P><PRE
CLASS="PROGRAMLISTING"
>FAILOVER (node=(id=1, backup node=3), node=(id=2, backup node=3));</PRE
><P>

This command requires that a paths exist between node 3 and 4. It will then redirect node 4 to receive the subscription from node 3.
&#13;</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1352"
>3.4.6. Automating <TT
CLASS="COMMAND"
> FAIL OVER </TT
></A
></H2
><A
NAME="AEN1355"
></A
><P
> If you do choose to automate <TT
CLASS="COMMAND"
>FAIL OVER </TT
>, it
is important to do so <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>carefully.</I
></SPAN
> You need to have
good assurance that the failed node is well and truly failed, and you
need to be able to assure that the failed node will not accidentally
return into service, thereby allowing there to be two nodes out there
able to respond in a <SPAN
CLASS="QUOTE"
>"master"</SPAN
> role. </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
> The problem here requiring that you <SPAN
CLASS="QUOTE"
>"shoot the
failed node in the head"</SPAN
> is not fundamentally about replication
or <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
>; <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> handles this all reasonably gracefully, as once
the node is marked as failed, the other nodes will <SPAN
CLASS="QUOTE"
>"shun"</SPAN
>
it, effectively ignoring it.  The problem is instead with
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>your application.</I
></SPAN
> Supposing the failed node can
come back up sufficiently that it can respond to application requests,
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>that</I
></SPAN
> is likely to be a problem, and one that
hasn't anything to do with <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
>.  The trouble is if there are two
databases that can respond as if they are <SPAN
CLASS="QUOTE"
>"master"</SPAN
>
systems. </P
></BLOCKQUOTE
></DIV
><P
> When failover occurs, there therefore needs to be a mechanism
to forcibly knock the failed node off the network in order to prevent
applications from getting confused.  This could take place via having
an SNMP interface that does some combination of the following:</P
><P
></P
><UL
><LI
><P
> Turns off power on the failed server. </P
><P
> If care is not taken, the server may reappear when system
administrators power it up. </P
></LI
><LI
><P
> Modify firewall rules or other network configuration
to drop the failed server's IP address from the network. </P
><P
> If the server has multiple network interfaces, and therefore
multiple IP addresses, this approach allows the
<SPAN
CLASS="QUOTE"
>"application"</SPAN
> addresses to be dropped/deactivated, but
leave <SPAN
CLASS="QUOTE"
>"administrative"</SPAN
> addresses open so that the server
would remain accessible to system administrators.  </P
></LI
></UL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="REBUILDNODE1"
>3.4.7. After Failover, Reconfiguring
Former Origin</A
></H2
><A
NAME="AEN1383"
></A
><P
> What happens to the failed node will depend somewhat on the
nature of the catastrophe that lead to needing to fail over to another
node.  If the node had to be abandoned because of physical destruction
of its disk storage, there will likely not be anything of interest
left.  On the other hand, a node might be abandoned due to the failure
of a network connection, in which case the former
<SPAN
CLASS="QUOTE"
>"provider"</SPAN
> can appear be functioning perfectly well.
Nonetheless, once communications are restored, the fact of the
<TT
CLASS="COMMAND"
>FAIL OVER</TT
> makes it mandatory that the failed node
be abandoned. </P
><P
> After the above failover, the data stored on node 1 will
rapidly become increasingly out of sync with the rest of the nodes,
and must be treated as corrupt.  Therefore, the only way to get node 1
back and transfer the origin role back to it is to rebuild it from
scratch as a subscriber, let it catch up, and then follow the
switchover procedure.</P
><P
> A good reason <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
> to do this automatically
is the fact that important updates (from a
<SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>business</I
></SPAN
> perspective) may have been
<TT
CLASS="COMMAND"
>commit</TT
>ted on the failing system.  You probably want
to analyze the last few transactions that made it into the failed node
to see if some of them need to be reapplied on the <SPAN
CLASS="QUOTE"
>"live"</SPAN
>
cluster.  For instance, if someone was entering bank deposits
affecting customer accounts at the time of failure, you wouldn't want
to lose that information.</P
><DIV
CLASS="WARNING"
><P
></P
><TABLE
CLASS="WARNING"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>Warning</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
> It has been observed that there can be some very
confusing results if a node is <SPAN
CLASS="QUOTE"
>"failed"</SPAN
> due to a
persistent network outage as opposed to failure of data storage.  In
such a scenario, the <SPAN
CLASS="QUOTE"
>"failed"</SPAN
> node has a database in
perfectly fine form; it is just that since it was cut off, it
<SPAN
CLASS="QUOTE"
>"screams in silence."</SPAN
> </P
><P
> If the network connection is repaired, that node could
reappear, and as far as <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>its</I
></SPAN
> configuration is
concerned, all is well, and it should communicate with the rest of its
<SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> cluster. </P
><P
> In <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>fact</I
></SPAN
>, the only confusion taking place
is on that node.  The other nodes in the cluster are not confused at
all; they know that this node is <SPAN
CLASS="QUOTE"
>"dead,"</SPAN
> and that they
should ignore it.  But there is not a way to know this by looking at
the <SPAN
CLASS="QUOTE"
>"failed"</SPAN
> node.</P
><P
> This points back to the design point that <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> is not a
network monitoring tool.  You need to have clear methods of
communicating to applications and users what database hosts are to be
used.  If those methods are lacking, adding replication to the mix
will worsen the potential for confusion, and failover will be a point
at which there is enormous potential for confusion. </P
></TD
></TR
></TABLE
></DIV
><P
> If the database is very large, it may take many hours to
recover node1 as a functioning <SPAN
CLASS="PRODUCTNAME"
>Slony-I</SPAN
> node; that is another reason
to consider failover as an undesirable <SPAN
CLASS="QUOTE"
>"final
resort."</SPAN
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1411"
>3.4.8. Planning for Failover</A
></H2
><P
> <A
HREF="failover.html"
> Failover </A
> policies
should be planned for ahead of time.  </P
><P
> Most pointedly, any node that is expected to be a failover
target must have its subscription(s) set up with the option
<TT
CLASS="COMMAND"
>FORWARD = YES</TT
>.  Otherwise, that node is not a
candidate for being promoted to origin node. </P
><P
> This may simply involve thinking about what the priority lists
should be of what should fail to what, as opposed to trying to
automate it.  But knowing what to do ahead of time cuts down on the
number of mistakes made.</P
><P
> At Afilias, a variety of internal [<SPAN
CLASS="CITATION"
>The 3AM Unhappy
DBA's Guide to...</SPAN
>] guides have been created to provide
checklists of what to do when certain <SPAN
CLASS="QUOTE"
>"unhappy"</SPAN
> events
take place.  This sort of material is highly specific to the
environment and the set of applications running there, so you would
need to generate your own such documents.  This is one of the vital
components of any disaster recovery preparations.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="ddlchanges.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="advanced.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Database Schema Changes (DDL)</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="administration.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Advanced Concepts</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>