These are exciting times for the Drizzle team. We just released our first RC and things are finally coming together into some awesome new features. I’m excited to bring you latest news from the replication front:
Where to begin? Well, many moons ago, Brian sent David Shrewsbury and myself out on the task of making the transaction_log plugin rock solid. This plugin provides a file-based log that captures the server’s state via protobuf messages. After much blood, sweat, and tears (and *many* bugs), we accomplished our task with *plenty* of help from everyone on the team. With this task accomplished, we could say that any replication solution using the log would have an accurate representation of the server’s state. However, this was a long way from actually replicating server-server.
During this time, we were also working on storing the transaction log in an innodb table rather than a file. Initial sysbench tests show a significant performance gain using this code versus the file based log. Thanks to the initial work on the file-based log, getting this code up and running wasn’t too painful and it also passes all of our tests with flying colors. Special mention should be given to Joe Daly, Stewart Smith, and Andrew Hutchings for hacking on this.
Having the transaction log in a database table provides other advantages beyond speed (such as easy, standardized access by other servers), but I’ll leave that to the hackers to discuss (I’d really recommend catching Dave’s UC talk if you are interested!). The gist is that it has allowed the amazing Mr. Shrewsbury to cook up the slave plugin!
This is a plugin that allows a server to replicate from another server that is using the innodb-trx log. It is amazingly simple:
master options: –innodb.replication-log=true
slave options: –plugin-add=slave –slave.config-file=XYZ
The config file may contain the following options in option=value format:
master-host – hostname/ip of the master host
master-port – port used by the master server
master-user – username
master-pass – password
max-reconnects – max # of reconnect attempts if the master disappears
seconds-between-reconnects – how long to wait between reconnect attempts
The code hasn’t yet been merged to trunk, but can be checked out from lp:~dshrews/drizzle/slave
Currently, the plugin is able to replicate *anything* we throw at the master, which is HUGE!
Additionally, our experimental test-runner, dbqp, is sporting randgen integration! I’ll write more about this in an upcoming post, but I mention it here as you can use the new randgen-mode + –start-and-exit to have yourself a handy-dandy replication setup for ad-hoc testing. Observe:
./dbqp –mode=randgen –start-and-exit –suite=slave_plugin
Setting –no-secure-file-priv=True for randgen mode…
<snip>
24 Feb 2011 12:25:11 INFO: Using testing mode: randgen
24 Feb 2011 12:25:11 INFO: Processing test suites…
24 Feb 2011 12:25:11 INFO: Found 1 test(s) for execution
24 Feb 2011 12:25:11 INFO: Creating 1 testbot(s)
24 Feb 2011 12:25:11 INFO: Taking clean db snapshot…
24 Feb 2011 12:25:12 INFO: Taking clean db snapshot…
24 Feb 2011 12:25:13 INFO: testbot0 server:
24 Feb 2011 12:25:13 INFO: NAME: server0
24 Feb 2011 12:25:13 INFO: MASTER_PORT: 9316
24 Feb 2011 12:25:13 INFO: DRIZZLE_TCP_PORT: 9317
24 Feb 2011 12:25:13 INFO: MC_PORT: 9318
24 Feb 2011 12:25:13 INFO: PBMS_PORT: 9319
24 Feb 2011 12:25:13 INFO: RABBITMQ_NODE_PORT: 9320
24 Feb 2011 12:25:13 INFO: VARDIR: drizzle/tests/workdir/testbot0/server0/var
24 Feb 2011 12:25:13 INFO: STATUS: 1
24 Feb 2011 12:25:13 INFO: testbot0 server:
24 Feb 2011 12:25:13 INFO: NAME: server1
24 Feb 2011 12:25:13 INFO: MASTER_PORT: 9321
24 Feb 2011 12:25:13 INFO: DRIZZLE_TCP_PORT: 9322
24 Feb 2011 12:25:13 INFO: MC_PORT: 9323
24 Feb 2011 12:25:13 INFO: PBMS_PORT: 9324
24 Feb 2011 12:25:13 INFO: RABBITMQ_NODE_PORT: 9325
24 Feb 2011 12:25:13 INFO: VARDIR: drizzle/tests/workdir/testbot0/server1/var
24 Feb 2011 12:25:13 INFO: STATUS: 1
24 Feb 2011 12:25:13 INFO: User specified –start-and-exit. dbqp.py exiting and leaving servers running…
We now have two servers running, a master on port 9316 and a slave on port 9321
user@mahmachine:~drizzle/tests$ ../client/drizzle -uroot -p9316 test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the Drizzle client.. Commands end with ; or \g.
Your Drizzle connection id is 4
Connection protocol: mysql
Server version: 2011.02.2197 Source distribution (drizzle)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
drizzle> create table t1 (a int auto_increment not null, primary key(a));
Query OK, 0 rows affected (0.001652 sec)
drizzle> insert into t1 values (),(),();
Query OK, 3 rows affected (0.001182 sec)
Records: 3 Duplicates: 0 Warnings: 0
drizzle> select * from t1;
+—+
| a |
+—+
| 1 |
| 2 |
| 3 |
+—+
3 rows in set (0.000538 sec)
drizzle> exit
Bye
user@mahmachine:~drizzle/tests$ ../client/drizzle -uroot -p9321 test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the Drizzle client.. Commands end with ; or \g.
Your Drizzle connection id is 82
Connection protocol: mysql
Server version: 2011.02.2197 Source distribution (drizzle)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
drizzle> show tables;
+—————-+
| Tables_in_test |
+—————-+
| t1 |
+—————-+
1 row in set (0.000983 sec)
drizzle> select * from t1;
+—+
| a |
+—+
| 1 |
| 2 |
| 3 |
+—+
3 rows in set (0.00058 sec)
You will likely need to merge with trunk to use this feature in the slave branch, but the actual plugin should be merged soon.
When you are done playing, you can take advantage of a new quality of life feature – cleanup mode.
A pet peeve of mine is needing to clean up / shutdown any servers I may have started during testing. With dbqp –mode=cleanup, the tool will now kill any server pids it detects in its workdir. Nothing fancy, but useful, quick, and easy:
./dbqp –mode=cleanup
Setting –start-dirty=True for cleanup mode…
24 Feb 2011 12:32:55 INFO: Using Drizzle source tree:
24 Feb 2011 12:32:55 INFO: basedir: drizzle
24 Feb 2011 12:32:55 INFO: clientbindir: drizzle/client
24 Feb 2011 12:32:55 INFO: testdir: drizzle/tests
24 Feb 2011 12:32:55 INFO: server_version: 2011.02.2197
24 Feb 2011 12:32:55 INFO: server_compile_os: unknown-linux-gnu
24 Feb 2011 12:32:55 INFO: server_platform: x86_64
24 Feb 2011 12:32:55 INFO: server_comment: (Source distribution (drizzle))
24 Feb 2011 12:32:55 INFO: Using –start-dirty, not attempting to touch directories
24 Feb 2011 12:32:55 INFO: Using default-storage-engine: innodb
24 Feb 2011 12:32:55 INFO: Using testing mode: cleanup
24 Feb 2011 12:32:55 INFO: Killing pid 24416 from drizzle/tests/workdir/testbot0/server1/var/run/server1.pid
24 Feb 2011 12:32:55 INFO: Killing pid 24385 from drizzle/tests/workdir/testbot0/server0/var/run/server0.pid
24 Feb 2011 12:32:55 INFO: Stopping all running servers…
Please give it a whirl and help us make the code better by filing any bugs you detect!