Seqno in grastate.dat not incrementing.

36 views
Skip to first unread message

brentgc...@gmail.com

unread,
Aug 13, 2015, 7:48:41 AM8/13/15
to codership
Good day Guys

Very new to Galera (please be gentle :) ).

So I have three virtual machines.

On vm1 I run "service mysql start --wsrep-new-cluster", thereafter I run "service mysql restart" on the other two vms.
Everything is working fine (i.e. SHOW STATUS LIKE 'wsrep_%'; shows me wsrep_cluster_size = 3 and wsrep_cluster_status is Primary on all the VMS.)

I then restart mysql on vm1, and everything is all still fine.

I then use sysbench to input from random data etc, and everything is still fine and replicating.

What I don’t get is, if I view grastate.dat it still says the seqno is -1.

I have been going through mysql's error logs and I cant find any reason why galera is not increasing the seqno.

If anyone could help, it would be appreciated.

Kind Regards
Brent Clark

Jay Janssen

unread,
Aug 13, 2015, 7:54:02 AM8/13/15
to brentgc...@gmail.com, codership
​Simple :)  The seqno isn't updated on a running daemon.  It is only set on a clean daemon shutdown.  

The seqno is stored with the innodb logs so it can be recovered in the event of a crash.  The -1 in the grastate.dat (with a non-zero UUID) is a signal to the node to pull the seqno from Innodb on the next startup.

You can ​extract the seqno yourself with 'mysqld_safe --wsrep_recover'

--
You received this message because you are subscribed to the Google Groups "codership" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codership-tea...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jay Janssen
Managing Consultant, Percona

Philip Stoev

unread,
Aug 13, 2015, 7:55:24 AM8/13/15
to brentgc...@gmail.com, codersh...@googlegroups.com
Hello,

grastate.dat is not written to at every transaction, that is why you do not
see it changing as you run your workload. It is only written to in a limited
number of circumstances, most importantly when Galera shuts down cleanly.

You said you restarted mysqld on node #1. Is seqno still -1 in the
grastate.dat file on that node after the restart?

Thank you.

Philip Stoev

Brent Clark

unread,
Aug 13, 2015, 8:21:25 AM8/13/15
to codersh...@googlegroups.com
Thank you ever so much in replying (@ Jay Janssen you too ;) )

On 13/08/2015 13:55, Philip Stoev wrote:
>
> You said you restarted mysqld on node #1. Is seqno still -1 in the
> grastate.dat file on that node after the restart?
>

Yes.

I did do Jay Janssen suggest ( i.e. mysqld_safe --wsrep_recover ). and
that worked.

Regards
Brent

Brent Clark

unread,
Aug 13, 2015, 8:38:54 AM8/13/15
to Philip Stoev, codersh...@googlegroups.com
Hiya

I'm sorry if I am not getting it. After I stopped "mysqld_safe
--wsrep_recover" the seqno went back to -1. Why is that?

Please see my workings below.

root@Galera1:~# service mysql stop
Shutting down MySQL
[ ok .
root@Galera1:~# mysqld_safe --wsrep_recover
150813 11:57:11 mysqld_safe Can't log to error log and syslog at the
same time. Remove all --log-error configuration options for --syslog to
take effect.
150813 11:57:11 mysqld_safe Logging to '/var/log/mysql/error.log'.
150813 11:57:11 mysqld_safe Starting mysqld daemon with databases from /mnt
150813 11:57:11 mysqld_safe WSREP: Running position recovery with
--log_error='/mnt/wsrep_recovery.FFt623'
--pid-file='/mnt/Galera1-recover.pid'
150813 11:57:13 mysqld_safe WSREP: Recovered position
fcc685af-40db-11e5-8702-3ff327ce715d:2101
150813 11:57:15 mysqld_safe mysqld from pid file
/var/run/mysqld/mysqld.pid ended

root@Galera1:/mnt# cat grastate.dat
# GALERA saved state
version: 2.1
uuid: fcc685af-40db-11e5-8702-3ff327ce715d
seqno: 2101
cert_index:
root@Galera1:/mnt# service mysql restart
[FAIL] MySQL server PID file could not be found! ... failed!
Starting MySQL
[ ok.
root@Galera1:/mnt# cat grastate.dat
# GALERA saved state
version: 2.1
uuid: fcc685af-40db-11e5-8702-3ff327ce715d
seqno: -1
cert_index:
root@Galera1:/mnt


Thank again.
Regards
Brent


On 13/08/2015 13:55, Philip Stoev wrote:

Philip Stoev

unread,
Aug 13, 2015, 8:55:19 AM8/13/15
to brentgc...@gmail.com, codersh...@googlegroups.com
"-1" is not the first seqno value. It is a special value that is kept in the
grastate.dat while the server is running to allow Galera to distinguish
between a clean and an unclean shutdown. Upon a clean shutdown, the correct
seqno value is written to the file.

So, when the server is brought back up, if the value is still -1 , this
means that the server did not shut down cleanly. If the value is greater
than 0, this means that the shutdown was clean. -1 is then written again to
the file in order to allow the "cleanliness" of the next shutdown to be
detected in the same manner.

Brent Clark

unread,
Aug 13, 2015, 9:27:45 AM8/13/15
to codersh...@googlegroups.com
Thanks for this.

How do I obtain a clean shutdown?
These vms are just idling (i.e. no db activity, other than galera running).

I would think that I cant get any more cleaner than by running "service
mysql stop"

Thanks
Brent

Jay Janssen

unread,
Aug 13, 2015, 9:57:15 AM8/13/15
to brentgc...@gmail.com, codership
service mysql stop indeed should be a clean shutdown.

--
You received this message because you are subscribed to the Google Groups "codership" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codership-tea...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages