Test MariaDB MaxScale readwrite

From DevOps Notebook
Revision as of 10:09, 29 October 2021 by MilosZ (talk | contribs) (Created page with "Check if you are getting always Slave servers id in maxscale '''SELECT''': <syntaxhighlight lang="MySQL"> > SELECT @@server_id AS "Server ID"; </syntaxhighlight> 1. Create te...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Check if you are getting always Slave servers id in maxscale SELECT:

> SELECT @@server_id AS "Server ID";

1. Create test database

CREATE TABLE test.readwrite_test (
   id INT PRIMARY KEY AUTO_INCREMENT,
   write_id INT
);

2. Insert few values with server id's trough maxscale connection

INSERT INTO test.readwrite_test (write_id) VALUES (@@server_id);
INSERT INTO test.readwrite_test (write_id) VALUES (@@server_id);
INSERT INTO test.readwrite_test (write_id) VALUES (@@server_id);

3. Check values from previous step and confirm that correct server id was used for INSERT's

SELECT readwrite.id AS "Primary Key",
   current.id AS "Current Server ID",
   readwrite.write_id AS "Stored Server ID"
FROM (
   SELECT @@server_id AS id
) AS current
INNER JOIN (
   SELECT id, write_id
   FROM test.readwrite_test
) AS readwrite;
+-------------+-------------------+------------------+
| Primary Key | Current Server ID | Stored Server ID |
+-------------+-------------------+------------------+
|           1 |         168103696 |       1078250471 |
|           2 |         168103696 |       1078250471 |
|           3 |         168103696 |       1078250471 |
+-------------+-------------------+------------------+
3 rows in set (0.01 sec)