Hi,
I have a question about some ORM internal state tracking stuff. If this
isn't the right venue for this type of question my apologies.
I've run into what looks like a race condition using the ORM during some
our production workloads. I am trying to figure out if our code has a bug
or if we are hitting a bug inside the ORM. We are occasionally getting a
FlushError with this message "Over 100 subsequent flushes have occurred
within session.commit() - is an after_flush() hook creating new objects?"(
we are not using any event hooks.)
I've managed to track this down to what looks like the session.identity_map
has an InstanceState in its modified list (i.e. the session is dirty) but
the InstanceState is not in the sessions.identity_map._dict (i.e not in the
session?). The InstanceState is showing that it is attached to the session.
e.g. the WeakInstanceDict looks like this for the session...
_dict = {} # is empty
_modified = ( TheModifiedInstanceState )
This is a difficult bug to reproduce, but seems more likely to occur if we
hold the session open longer like so...
my_model = MyModel.query.filter('...').first()
my_model.attr = 'something'
sleep(1)
session.commit() <-- flush error "occasionally"
I was hoping someone could confirm for me that this is "never a valid
state" for the identity map to be in. (Or if I'm super lucky someone will
recognize this as a known bug or something).
Thanks for the help,
Cecil
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.