devenv icon indicating copy to clipboard operation
devenv copied to clipboard

db startup script consistently hangs at "service mysqld start" line

Open miketull opened this issue 10 years ago • 10 comments

When I run "vagrant up" or "vagrant up db", the startup script consistently hangs at the "service mysqld start" line. As far as I know I have the current dev environment. Zach Allgood is having the same problem, and he did a fresh installation of the dev environment this week. I have done this procedure https://github.com/davidalger/devenv#mysqld-fails-to-start multiple times, and rebooted my MacBook before recreating the db VM this last time.

Usually I just Ctrl-C twice and everything works OK. But it is annoying to have to manually interact with the startup process every time.

Output from "vagrant up db": Bringing machine 'db' up with 'virtualbox' provider... ==> db: Checking if box 'bento/centos-6.7' is up to date... ==> db: Clearing any previously set forwarded ports... ==> db: Clearing any previously set network interfaces... ==> db: Preparing network interfaces based on configuration... db: Adapter 1: nat db: Adapter 2: hostonly ==> db: Forwarding ports... db: 22 (guest) => 2222 (host) (adapter 1) ==> db: Running 'pre-boot' VM customizations... ==> db: Booting VM... ==> db: Waiting for machine to boot. This may take a few minutes... db: SSH address: 127.0.0.1:2222 db: SSH username: vagrant db: SSH auth method: private key db: Warning: Remote connection disconnect. Retrying... db: Warning: Remote connection disconnect. Retrying... db: Warning: Remote connection disconnect. Retrying... ==> db: Machine booted and ready! ==> db: Checking for guest additions in VM... ==> db: Setting hostname... ==> db: Configuring and enabling network interfaces... ==> db: Mounting NFS shared folders... ==> db: Mounting shared folders... db: /server/vagrant => /server/vagrant db: /server/.shared => /server/.shared ==> db: Machine already provisioned. Run vagrant provision or use the --provision ==> db: flag to force provisioning. Provisioners marked to run always will still run. ==> db: Running provisioner: shell... db: Running: script: bind_sh ==> db: /server/.shared/yum => /var/cache/yum ==> db: /server/.shared/npm => /var/cache/npm ==> db: Running provisioner: shell... db: Running: script: service mysqld start

/var/log/mysqld.log entries 161013 11:18:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql/data 2016-10-13 11:18:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-10-13 11:18:01 0 [Note] /usr/sbin/mysqld (mysqld 5.6.34) starting as process 5473 ... 2016-10-13 11:18:01 5473 [Note] Plugin 'FEDERATED' is disabled. 2016-10-13 11:18:01 5473 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-10-13 11:18:01 5473 [Note] InnoDB: The InnoDB memory heap is disabled 2016-10-13 11:18:01 5473 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-10-13 11:18:01 5473 [Note] InnoDB: Memory barrier is not used 2016-10-13 11:18:01 5473 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-10-13 11:18:01 5473 [Note] InnoDB: Using Linux native AIO 2016-10-13 11:18:01 5473 [Note] InnoDB: Using CPU crc32 instructions 2016-10-13 11:18:01 5473 [Note] InnoDB: Initializing buffer pool, size = 2.0G 2016-10-13 11:18:01 5473 [Note] InnoDB: Completed initialization of buffer pool 2016-10-13 11:18:01 5473 [Note] InnoDB: Highest supported file format is Barracuda. 2016-10-13 11:18:05 5473 [Note] InnoDB: 128 rollback segment(s) are active. 2016-10-13 11:18:05 5473 [Note] InnoDB: Waiting for purge to start 2016-10-13 11:18:05 5473 [Note] InnoDB: 5.6.34 started; log sequence number 1118065247 2016-10-13 11:18:05 5473 [Note] Server hostname (bind-address): '*'; port: 3306 2016-10-13 11:18:05 5473 [Note] IPv6 is available. 2016-10-13 11:18:05 5473 [Note] - '::' resolves to '::'; 2016-10-13 11:18:05 5473 [Note] Server socket created on IP: '::'. 2016-10-13 11:18:05 5473 [Note] Event Scheduler: Loaded 0 events 2016-10-13 11:18:05 5473 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.6.34' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)

miketull avatar Oct 13 '16 16:10 miketull

@davidalger I've experienced the same thing. It doesn't' happen when running vagrant up from a destroyed box, but any time I run vagrant up when the db node is halted, it happens.

ericthehacker avatar Oct 13 '16 16:10 ericthehacker

@davidalger Ditto what Eric said. I didn't make that distinction in the original issue text.

miketull avatar Oct 13 '16 16:10 miketull

I also have issues with mysqld not starting and have to manually SSH into the box and start the service. I never reported the issue as I thought it might be isolated to my environment and didn't want to raise a fuss for no reason.

I have a similar issue when starting the web box, except it's with httpd not starting.

erikhansen avatar Oct 13 '16 16:10 erikhansen

@miketull Thanks for the incredibly precise detail on the issue you're encountering. I looked at this last night and was able to reproduce the issue…but unfortunately it's something which doesn't appear I can fix, as it's a bug in vagrant.

The shell provisioner that's being run is pretty simple, just the following line:

service mysqld start 2>&1 | grep -v "/var/lib/mysql/data': Operation not permitted"

It's returning just fine, and as your mysqld.log shows above, the mysql server started just fine and works…vagrant just required the double-control-C to escape from it's infinite loop.

A verbose debug log from vagrant reports the following:

DEBUG ssh: Uploading: /var/folders/yw/x5mg2fz964907j9bsbcfjxtc0000gn/T/vagrant-shell20161017-32395-1v6qt9w.ps1 to /tmp/vagrant-shell
DEBUG ssh: Re-using SSH connection.
 INFO interface: detail: Running: script: service mysqld start
 INFO interface: detail:     db: Running: script: service mysqld start
    db: Running: script: service mysqld start
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: chmod +x '/tmp/vagrant-shell' && /tmp/vagrant-shell (sudo=true)
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
DEBUG ssh: Exit status: 0
 INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-zaQPoA1492/agent.1492
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
...

That last (repeated) line keeps repeating ad-infinitum and never stops, even though the line above it reports the provisioner as having successfully returned. So I'm not sure what's going awry here, as it's in the SSH connection which vagrant opens to the VM and is failing to close properly and then (itself) exit.

My best guess without digging further is that this is a bug in the vagrant tool itself which we'll have to wait to fix. All of us who are running into the issue are running vagrant v1.8.x. One question though: can you let me know what specific version you're running? You can get this by running vagrant -v

cc/@mttjohnson

davidalger avatar Oct 18 '16 14:10 davidalger

@davidalger - I'm running version 1.8.4. Eric W updated my local to 1.8.5 at one point, but we rolled back to 1.8.4 because 1.8.5 introduced some other bug. (I don't remember the specifics at this time.)

miketull avatar Oct 18 '16 15:10 miketull

I'm on 1.8.6.

ericthehacker avatar Oct 18 '16 15:10 ericthehacker

I'm also running 1.8.6 and can reproduce the issue, but @mttjohnson cannot and he's running 1.8.4.

@miketull What version of macOS are you running? I'm on 10.12, so is @ericthehacker, but @mttjohnson is on 10.11 still.

davidalger avatar Oct 18 '16 17:10 davidalger

@davidalger My OS X is 10.11.6

miketull avatar Oct 18 '16 17:10 miketull

Alright…looks like vagrant threw me off, but I dug deeper because there are too many similarities. Turns out the issue is not vagrant, which is good, but also bad because of where the issue ultimately is could actually be considered worse! However…I found a workaround, so hang-tight! :)

The issue is a bug in bash that's being triggered by a change in the mysql-server startup script, the change triggers a bug causing a leaked file-descriptor.

The folks on an issue over in the salt community tipped me off to this in https://github.com/saltstack/salt/issues/33442#issuecomment-255171897 where I then posted my minimal reproducible case hoping it'll help them in return… the test case is basically this:

Running as root…

  1. Stop mysqld service mysqld stop
  2. Attempt to start via the following service mysqld start 2>&1 | cat

This will hang, but mysqld is started successfully. Changing the start command to use an ad-hoc descriptor works around the issue:

service mysqld start 2> >(cat)

A fix will be forthcoming soon.

davidalger avatar Oct 20 '16 17:10 davidalger

This should be solved in release 1.0.0-beta27. Please update your local environments to that tagged release to resolve. Thanks!

time bash -c "cd /server && vagrant halt && vagrant destroy -f && git fetch && git checkout 1.0.0-beta27 && vagrant up"

davidalger avatar Oct 20 '16 18:10 davidalger