Search Posts

Tornado handler DB connection not fetching recent inserts

I’ve been grappling with a strange error in creating an RPC model using Tornado. Originally, I was passing some data to a Tornado handler and having the data processed in the IO loop while the results were added to a Amazon RDS database. The handler would then redirect to another one for display with a URL parameter, and everything worked fine.

I then tried passing the same data to a worker process through RabbitMQ, and when the callback was received the handler tasked with displaying the results failed to read the new insert from the database.

I added a wait period between the insert and callback to see if RabbitMQ was racing the database connection, but this didn’t appear to help. The records inserted normally.

I then tried reloading the display handler, but nothing showed up until I terminated the Tornado server and restarted it, at which point everything displayed normally.

I’m not sure why I have to reset the Tornado server to find a record that is in the database, and I’m at wit’s end.

Any advice?

I’m using MySQLdb to connect to the database instance, and generally proxying requests through nginx (but running it locally didn’t fix the problem, either).

Source: Stackoverflow

Leave a Reply

Your email address will not be published. Required fields are marked *