Difference between revisions of "Test MariaDB MaxScale readwrite"

From DevOps Notebook
(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...")
 
 
Line 1: Line 1:
 
Check if you are getting always Slave servers id in maxscale '''SELECT''':
 
Check if you are getting always Slave servers id in maxscale '''SELECT''':
 
<syntaxhighlight lang="MySQL">
 
<syntaxhighlight lang="MySQL">
> SELECT @@server_id AS "Server ID";
+
SELECT @@server_id AS "Server ID";
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 19: Line 19:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
3. Check values from previous step and confirm that correct server id was used for '''INSERT''''s
+
3. Check values from previous step and confirm that correct server id was used for '''INSERT'''
 
<syntaxhighlight lang="MySQL">
 
<syntaxhighlight lang="MySQL">
 
SELECT readwrite.id AS "Primary Key",
 
SELECT readwrite.id AS "Primary Key",

Latest revision as of 10:09, 29 October 2021

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

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)