Looking at the code, `sql_query_async(...)` should work, do you get exactly the same error message as with `sql_query()`?
As for the use of async module, can you use the `async_task_data()` or `async_task_group_data()` functions? The other ones are intended for processing of SIP requests because they attempt to suspend the transaction, but in this case is no real SIP request under processing.
Otherwise, repeating somehow, the TCP main process never had a database connection and it should not have. As I said, the old code was triggering connection close events in a few cases when a tcp worker predicted (or instructed) that connection is going (or has to) to be closed by TCP main, but never for the cases when the connection was closed by TCP main alone.