Remove use of timestamps in failover code

Using timestamps to detect whether MaxScale was active or passive can
cause problems if multiple events happen at the same time. This can be
avoided by separating events into actively observed and passively observed
events. This clarifies the logic by removing the ambiguity of timestamps.

As the monitoring threads are separate from the worker threads, it is
prudent to use atomic operations to modify and read the state of the
MaxScale. This will impose an happens-before relation between MaxScale
being set into passive mode and events being classified as being passively
observed.
This commit is contained in:
Markus Mäkelä
2017-10-27 10:26:10 +03:00
parent 37e64bad90
commit 2d1e5f46fa
6 changed files with 29 additions and 39 deletions

View File

@ -212,7 +212,7 @@ typedef struct
unsigned int auth_read_timeout; /**< Read timeout for the user authentication */
unsigned int auth_write_timeout; /**< Write timeout for the user authentication */
bool skip_permission_checks; /**< Skip service and monitor permission checks */
bool passive; /**< True if MaxScale is in passive mode */
int32_t passive; /**< True if MaxScale is in passive mode */
int64_t promoted_at; /**< Time when this Maxscale instance was
* promoted from a passive to an active */
char qc_name[PATH_MAX]; /**< The name of the query classifier to load */