cloudfoundry/vcap — pull request #188 by krobertson (2012-02-22 01:01:17+00:00)
Title: Fix for mysql2 trying to resume a dead fiber

This is a patch for an issue I'd experienced with running the cloud controller on MySQL. The issue was that if an exception was thrown down at the model level or from the database (between when the fiber yielded and was resumed), it would essentially kill the fiber but mysql2 would continue to try to resume it.

Bug: https://github.com/brianmario/mysql2/issues/188

This would end up crashing thin and causing the cloud controller to exit.

Fiber support was moved from mysql2 to em-sychrony. But em-sychrony requires eventmachine 1.0 and CF is locked on a patched version of eventmachine.

Attached to the bug was a patch (https://gist.github.com/1058768). It basically just changed it to call `fiber.alive?` before calling resume.

Unfortunately, like my earlier cloud controller pull #172, it is random when it crops up.