0

I have a Flask app running using Elastic Beanstalk, using flask-security and plain sqlalchemy. The app's data is stored on a RDS instance, living outside of EB. I am following the flask-security Quick Start with a session, which doesn't use flask-sqlalchemy. Everything is free tier.

Everything is up and running well, but I've encountered that

  • After a db insert of a certain type, a view which reads all objects of that type gives alternating good/bad results. Literally, on odd refreshes I get a read that includes the newly inserted object and on even refreshes the newly inserted object is missing. This persists for as long as I've tried refreshing (dozens of times... several minutes).
  • After going away for an afternoon and coming back, the app's db connection is broken. I feel like my free tier resources are going to sleep, and the example code is not recovering well.

I'm looking for pointers on how to debug, for a more robust starting code example, or for suggestions on what else to try.

I may try to switch to flask-sqlalchemy (perhaps getting better session handling), or drop flask-security for flask-login (a downgrade in functionality... sniff).

HoosierDaddy
  • 720
  • 6
  • 19
  • Do you end your transactions timely, usually at the end of a request, if not before. Certain isolation levels, such as REPEATABLE READ will keep on displaying data from the original snapshot, as the name implies. – Ilja Everilä Mar 05 '18 at 12:59
  • Yes, the commit happens during the request. It was odd that alternate queries were returning different results than even ones. I switched to flask-sqlalchemy, which hasn't shown the problem. I'm assuming it's something to do with session handling that flask-sqlalchemy gets right and I got wrong. – HoosierDaddy Mar 08 '18 at 21:47
  • Though you committed in the request that inserted, did you also always end transactions in other requests? If not, then perhaps every other request was serviced by the thread that had inserted, committed and started a new transaction, while every other by a thread hanging on to an open transaction. Flask-SQLAlchemy does indeed handle closing the session at the end of a request, which implicitly rollbacks. – Ilja Everilä Mar 09 '18 at 05:21

0 Answers0