MySQL on OpenVMS loses data if MySQL is not properly shutdown or system crashes

I’ve been busy converting from our old set on OpenVMS of OSU webserver, PHP 3 and MySQL V4. The upgrade consisted of Apache, CWCS from HP, PHP 5 and MySQL V5.

 

While working on MySQL V5, there was no mysql_shutdown.com file to properly say “shutdown mysql properly”. I was stopping MySQL using “stop/id=xxxx”. This is akin to stopping a car by running it straight into a brick wall. Yes, it works, but your going to have to fix the car.

 

When I did stop MySQL this way, I found some things did not stay in the database. This means, they were in memory, but had not been written to disk yet. Well, that’s not good. To fix this, I did find the right way to shutdown the server, this should go into your sys$manager:syshutdown.com:

 

$ mysqladmin -u root –password=”yourpasswordhere” shutdown

$ mysqladmin -u root –password=”yourpasswordhere” shutdown

 

Yes, twice… I know, it takes two of them… don’t know why, but I know it works. But still, what if the system crashes. I know, OpenVMS NEVER crashes, it’s just reliable and thats that… BUT, I can’t control Florida Power and Light, and I promise you, they will fail, and you will get your crash…

 

I found adding the –flush to the mysql startup file fixes this. While it slows down mysql’s speed, it does give up the reliability that MySQL has a better chance to not corrupt a table due to a delayed write. So, here’s what the mysql_startup.com file should look like:

 

$ set process/parse=extend
$ mysqld :== $ mysql051_root:[vms.bin]mysqld
$ define sys$scratch mysql051_root:[mysql_server.tmp]
$ define /noLOG TMPDIR “/mysql051_root/mysql_server/tmp”
$ define /noLOG DECC$EFS_CASE_PRESERVE enable
$ define /noLOG DECC$EFS_CHARSET enable
$ define /noLOG DECC$READDIR_DROPDOTNOTYPE enable
$ define /noLOG DECC$FILENAME_UNIX_REPORT enable
$ define /noLOG DECC$FILE_SHARING enable
$ define /noLOG DECC$EFS_CASE_SPECIAL disable
$ define /noLOG DECC$FILENAME_UNIX_ONLY enable
$ define /noLOG DECC$ALLOW_REMOVE_OPEN_FILES enable
$ define /noLOG TCPIP$SELECT_ABORT_ON_SIGNAL enable
$ define /noLOG DECC$FD_LOCKING enable
$ define /noLOG DECC$POSIX_SEEK_STREAM_FILE enable
$ set rms/ext=20000
$ if f$trnlnm(“LIBZ_SHR32”) .eqs. “” then $ define LIBZ_SHR32 –
mysql051_root:[vms.lib]libz_shr32.exe
$ if f$trnlnm(“LIBZ_SHR64”) .eqs. “” then $ define LIBZ_SHR64 –
mysql051_root:[vms.lib]libz_shr64.exe
$!
$! All options except ansi defined using configuration file my.cnf
$!
$ mysqld  –ansi –flush
$ if f$search (“mysql051_root:[mysql_server.tmp]*.*;*”) .nes. “”
$ then
$      delete mysql051_root:[mysql_server.tmp]*.*;*
$ endif

 

The –flush is all you have to add.