Skip to content

Commit 62f55b4

Browse files
committed
WL#11338: Backport changes to uniquely identify different node incarnations
In GCS/XCOM, a node can receive messages such as ping(s) and paxos proposals and act upon them immediately after rebooting. However, a node that has recently rebooted suffers from amnesia and does not know anything about its prior states unless it has written them into a stable storage. Unfortunately, GCS/XCOM does not use any stable storage in order to improve performance but pings and paxos are still indiscriminately processed after reboot. This scenario can lead to a variety of strange problems, and in the extreme case, it can generate data inconsistency. We have identified the problem and started augmenting GCS/XCOM with the notion of incarnation. Basically, every node has a unique identifier assigned to it every time it joins the cluster and this information can be used to distinguish among different node incarnations. This fix contains the following set of patches backported from 8.0: . BUG#25311008 . BUG#22204121
1 parent fe24af0 commit 62f55b4

26 files changed

+987
-203
lines changed

rapid/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_member_identifier.h

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -17,6 +17,73 @@
1717
#define GCS_MEMBER_IDENTIFIER_INCLUDED
1818

1919
#include <string>
20+
#include "gcs_types.h"
21+
22+
23+
/*
24+
Internal GCS unique identifier.
25+
*/
26+
class Gcs_uuid
27+
{
28+
public:
29+
/*
30+
Create a GCS unique identifier.
31+
*/
32+
33+
static Gcs_uuid create_uuid();
34+
35+
36+
/*
37+
Default constructor
38+
*/
39+
Gcs_uuid();
40+
41+
42+
/*
43+
Copies the internal buffer which is used to store a uuid to an
44+
external buffer. If the parameters buffer or size point to NULL,
45+
nothing is returned.
46+
47+
@param [out] buffer storage buffer
48+
@param [out] size data size
49+
@return Whether the data was returned or not.
50+
*/
51+
52+
bool encode(uchar **buffer, unsigned int *size) const;
53+
54+
55+
/*
56+
Copies the external buffer to an internal buffer. If the
57+
parameter buffer points to NULL, nothing is returned.
58+
59+
@param [in] buffer storage buffer
60+
@param [in] size data size
61+
@return Whether the data was copied or not.
62+
*/
63+
64+
bool decode(const uchar *buffer, const unsigned int size);
65+
66+
/*
67+
Return the size of the UUID in use.
68+
*/
69+
size_t size() const;
70+
71+
/*
72+
Unique identifier which currently only accommodates 64 bits but
73+
can easily be extended to 128 bits and become a truly UUID in
74+
the future.
75+
*/
76+
77+
std::string actual_value;
78+
79+
private:
80+
/*
81+
Create a GCS unique identifier.
82+
*/
83+
84+
static const std::string do_create_uuid();
85+
};
86+
2087

2188
/**
2289
@class Gcs_member_identifier
@@ -41,6 +108,17 @@ class Gcs_member_identifier
41108
explicit Gcs_member_identifier(const std::string &member_id);
42109

43110

111+
/**
112+
Gcs_member_identifier constructor.
113+
114+
@param[in] member_id the member identifier
115+
@param[in] uuid the member uuid
116+
*/
117+
118+
explicit Gcs_member_identifier(const std::string &member_id,
119+
const Gcs_uuid &uuid);
120+
121+
44122
virtual ~Gcs_member_identifier() {}
45123

46124

@@ -50,6 +128,18 @@ class Gcs_member_identifier
50128

51129
const std::string& get_member_id() const;
52130

131+
/**
132+
@return the member uuid
133+
*/
134+
135+
const Gcs_uuid& get_member_uuid() const;
136+
137+
138+
/**
139+
Regenerate the member uuid
140+
*/
141+
142+
void regenerate_member_uuid();
53143

54144
/**
55145
Redefinition of the operator less, to allow usage as key in maps.
@@ -76,7 +166,8 @@ class Gcs_member_identifier
76166

77167

78168
private:
79-
std::string member_id;
169+
std::string m_member_id;
170+
Gcs_uuid m_uuid;
80171
};
81172

82173
#endif // GCS_MEMBER_IDENTIFIER_INCLUDED

rapid/plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_view.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
2121
#include "gcs_member_identifier.h"
2222

2323
#include <vector>
24+
#include <string>
2425

2526
/**
2627
@class Gcs_view
@@ -146,6 +147,23 @@ class Gcs_view
146147
Gcs_view::Gcs_view_error_code get_error_code() const;
147148

148149

150+
/*
151+
@param[in] address Member's identifier which is usually its address
152+
@return the member whose identifier matches the one provided as
153+
parameter
154+
*/
155+
156+
const Gcs_member_identifier *get_member(const std::string &member_id) const;
157+
158+
159+
/*
160+
@param[in] member_id Member's identifier which is usually its address
161+
@return whether there is a member whose identifier matches the one
162+
provided as parameter
163+
*/
164+
165+
bool has_member(const std::string &member_id) const;
166+
149167
private:
150168
std::vector<Gcs_member_identifier> *m_members;
151169
Gcs_view_identifier *m_view_id;

0 commit comments

Comments
 (0)