matehat/cqerl — pull request #40 by nwt (2014-10-30 16:32:15+00:00)
Title: Fix a couple of message-handling in cqerl_client's sleep state

We'd been bumping into a problem wherein `cqerl:run_query/2` would intermittently throw `{timeout, {gen_fsm, sync_send_event, _}}`. The ratio of these exceptions to successful calls would then increase over time until we got nothing but exceptions.

Upon examining nodes in this state, we found that our `cqerl_client` processes all had large numbers of bytes stuck in `#client_state.delayed`. The initial bytes were not a valid frame header, and we traced that to incorrect fragment handling in the sleep-state `cqerl_client:handle_info/3`.

This PR contains a fix for that problem. It also fixes a nearby problem that kept updates to `#client_state{}` from happening.