|
@@ -0,0 +1,118 @@
|
|
1
|
+--- a/dbinc/repmgr.h
|
|
2
|
++++ b/dbinc/repmgr.h
|
|
3
|
+@@ -374,6 +374,7 @@ typedef struct {
|
|
4
|
+ #define SITE_FROM_EID(eid) (&db_rep->sites[eid])
|
|
5
|
+ #define EID_FROM_SITE(s) ((int)((s) - (&db_rep->sites[0])))
|
|
6
|
+ #define IS_VALID_EID(e) ((e) >= 0)
|
|
7
|
++#define IS_KNOWN_REMOTE_SITE(e) ((e) >= 0 && ((u_int)(e)) < db_rep->site_cnt)
|
|
8
|
+ #define SELF_EID INT_MAX
|
|
9
|
+
|
|
10
|
+ #define IS_PEER_POLICY(p) ((p) == DB_REPMGR_ACKS_ALL_PEERS || \
|
|
11
|
+--- a/rep/rep_elect.c
|
|
12
|
++++ b/rep/rep_elect.c
|
|
13
|
+@@ -33,7 +33,7 @@ static int __rep_elect_init
|
|
14
|
+ static int __rep_fire_elected __P((ENV *, REP *, u_int32_t));
|
|
15
|
+ static void __rep_elect_master __P((ENV *, REP *));
|
|
16
|
+ static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t));
|
|
17
|
+-static int __rep_wait __P((ENV *, db_timeout_t *, int *, int, u_int32_t));
|
|
18
|
++static int __rep_wait __P((ENV *, db_timeout_t *, int, u_int32_t));
|
|
19
|
+
|
|
20
|
+ /*
|
|
21
|
+ * __rep_elect --
|
|
22
|
+@@ -55,7 +55,7 @@ __rep_elect(dbenv, given_nsites, nvotes,
|
|
23
|
+ ENV *env;
|
|
24
|
+ LOG *lp;
|
|
25
|
+ REP *rep;
|
|
26
|
+- int done, eid, elected, full_elect, locked, in_progress, need_req;
|
|
27
|
++ int done, elected, full_elect, locked, in_progress, need_req;
|
|
28
|
+ int ret, send_vote, t_ret;
|
|
29
|
+ u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri;
|
|
30
|
+ u_int32_t tiebreaker;
|
|
31
|
+@@ -181,8 +181,7 @@ __rep_elect(dbenv, given_nsites, nvotes,
|
|
32
|
+ REP_SYSTEM_UNLOCK(env);
|
|
33
|
+ (void)__rep_send_message(env, DB_EID_BROADCAST,
|
|
34
|
+ REP_MASTER_REQ, NULL, NULL, 0, 0);
|
|
35
|
+- ret = __rep_wait(env, &to, &eid,
|
|
36
|
+- 0, REP_F_EPHASE0);
|
|
37
|
++ ret = __rep_wait(env, &to, 0, REP_F_EPHASE0);
|
|
38
|
+ REP_SYSTEM_LOCK(env);
|
|
39
|
+ F_CLR(rep, REP_F_EPHASE0);
|
|
40
|
+ switch (ret) {
|
|
41
|
+@@ -286,11 +285,11 @@ restart:
|
|
42
|
+ REP_SYSTEM_LOCK(env);
|
|
43
|
+ goto vote;
|
|
44
|
+ }
|
|
45
|
+- ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE1);
|
|
46
|
++ ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE1);
|
|
47
|
+ switch (ret) {
|
|
48
|
+ case 0:
|
|
49
|
+ /* Check if election complete or phase complete. */
|
|
50
|
+- if (eid != DB_EID_INVALID && !IN_ELECTION(rep)) {
|
|
51
|
++ if (!IN_ELECTION(rep)) {
|
|
52
|
+ RPRINT(env, DB_VERB_REP_ELECT,
|
|
53
|
+ (env, "Ended election phase 1"));
|
|
54
|
+ goto edone;
|
|
55
|
+@@ -398,15 +397,12 @@ phase2:
|
|
56
|
+ REP_SYSTEM_LOCK(env);
|
|
57
|
+ goto i_won;
|
|
58
|
+ }
|
|
59
|
+- ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE2);
|
|
60
|
++ ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE2);
|
|
61
|
+ RPRINT(env, DB_VERB_REP_ELECT,
|
|
62
|
+ (env, "Ended election phase 2 %d", ret));
|
|
63
|
+ switch (ret) {
|
|
64
|
+ case 0:
|
|
65
|
+- if (eid != DB_EID_INVALID)
|
|
66
|
+- goto edone;
|
|
67
|
+- ret = DB_REP_UNAVAIL;
|
|
68
|
+- break;
|
|
69
|
++ goto edone;
|
|
70
|
+ case DB_REP_EGENCHG:
|
|
71
|
+ if (to > timeout)
|
|
72
|
+ to = timeout;
|
|
73
|
+@@ -1050,13 +1046,6 @@ __rep_elect_master(env, rep)
|
|
74
|
+ ENV *env;
|
|
75
|
+ REP *rep;
|
|
76
|
+ {
|
|
77
|
+- /*
|
|
78
|
+- * We often come through here twice, sometimes even more. We mustn't
|
|
79
|
+- * let the redundant calls affect stats counting. But rep_elect relies
|
|
80
|
+- * on this first part for setting eidp.
|
|
81
|
+- */
|
|
82
|
+- rep->master_id = rep->eid;
|
|
83
|
+-
|
|
84
|
+ if (F_ISSET(rep, REP_F_MASTERELECT | REP_F_MASTER)) {
|
|
85
|
+ /* We've been through here already; avoid double counting. */
|
|
86
|
+ return;
|
|
87
|
+@@ -1093,10 +1082,10 @@ __rep_fire_elected(env, rep, egen)
|
|
88
|
+ (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
|
|
89
|
+
|
|
90
|
+ static int
|
|
91
|
+-__rep_wait(env, timeoutp, eidp, full_elect, flags)
|
|
92
|
++__rep_wait(env, timeoutp, full_elect, flags)
|
|
93
|
+ ENV *env;
|
|
94
|
+ db_timeout_t *timeoutp;
|
|
95
|
+- int *eidp, full_elect;
|
|
96
|
++ int full_elect;
|
|
97
|
+ u_int32_t flags;
|
|
98
|
+ {
|
|
99
|
+ DB_REP *db_rep;
|
|
100
|
+@@ -1174,7 +1163,6 @@ __rep_wait(env, timeoutp, eidp, full_ele
|
|
101
|
+ F_CLR(rep, REP_F_EGENUPDATE);
|
|
102
|
+ ret = DB_REP_EGENCHG;
|
|
103
|
+ } else if (phase_over) {
|
|
104
|
+- *eidp = rep->master_id;
|
|
105
|
+ done = 1;
|
|
106
|
+ ret = 0;
|
|
107
|
+ }
|
|
108
|
+--- a/repmgr/repmgr_net.c
|
|
109
|
++++ b/repmgr/repmgr_net.c
|
|
110
|
+@@ -100,6 +100,8 @@ __repmgr_send(dbenv, control, rec, lsnp,
|
|
111
|
+ control, rec, &nsites_sent, &npeers_sent)) != 0)
|
|
112
|
+ goto out;
|
|
113
|
+ } else {
|
|
114
|
++ DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid));
|
|
115
|
++
|
|
116
|
+ /*
|
|
117
|
+ * If this is a request that can be sent anywhere, then see if
|
|
118
|
+ * we can send it to our peer (to save load on the master), but
|