Re: [sqlalchemy] Deadlocks when reflecting SQL Server metadata

2018-02-26 Thread Sean Harrington
Negative - no other process/thread is executing any DDL statements. I have a hunch that selecting from INFORMATION_SCHEMA reads all dB tables, so if any of them are read-locked, we’d get this error. Question is: in what world (or config) do table’s get read locked when no DDL is being performed?

Re: [sqlalchemy] Deadlocks when reflecting SQL Server metadata

2018-02-26 Thread Mike Bayer
so do you have another thread or process that is running database migrations, like create table or alter table, while that happens? On Mon, Feb 26, 2018 at 6:16 PM, Sean Harrington wrote: > We're getting the following deadlock error on SQL Server: > > > [FreeTDS][SQL

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Mike Bayer
On Mon, Feb 26, 2018 at 4:51 PM, Cecil Rock wrote: > Hi Mike, > > Another colleague of mine sent me this write up which we believe is the root > cause of our issue. > > In sqlalchemy/orm/loading.py: > > > > Function _instance() defined in _instance_processor() checks if

[sqlalchemy] Deadlocks when reflecting SQL Server metadata

2018-02-26 Thread Sean Harrington
We're getting the following deadlock error on SQL Server: [FreeTDS][SQL Server]Transaction (Process ID 65) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. (1205) (SQLExecDirectW)') [SQL: 'SELECT [

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Cecil Rock
Hi Mike, Another colleague of mine sent me this write up which we believe is the root cause of our issue. In sqlalchemy/orm/loading.py: Function _instance() defined in _instance_processor() checks if identitykey is in session_identity_map by calling session_identity_map.get(identitykey). This

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Cecil Rock
OH, man sorry I misunderstood that issue. I have been starring at this for too long :) Yes, that totally could be it. I'll apply that patch and should be able to confirm it or not. On Mon, Feb 26, 2018 at 1:02 PM, Mike Bayer wrote: > On Mon, Feb 26, 2018 at 3:58 PM,

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Mike Bayer
On Mon, Feb 26, 2018 at 3:33 PM, Cecil Rock wrote: > Fairly old, v1.0.14. Its running in one of our older microservices. Once I > understood what was going on, I went through the fix list and could not find > anything obviously related to it. We can't reproduce this at

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Cecil Rock
Fairly old, v1.0.14. Its running in one of our older microservices. Once I understood what was going on, I went through the fix list and could not find anything obviously related to it. We can't reproduce this at will and nothing obvious has changed, so we're worried that upgrading without

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Mike Bayer
um what version of SQLAlchemy is this? On Mon, Feb 26, 2018 at 3:22 PM, Cecil Rock wrote: > One of my thoughts was maybe the gc wiped out the identity_map and it gets > recreated empty. > > Here is a stack trace of when I detect the situation prior to the flush > occurring.

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Cecil Rock
One of my thoughts was maybe the gc wiped out the identity_map and it gets recreated empty. Here is a stack trace of when I detect the situation prior to the flush occurring. [4018/eval_0/INFO/state/554/_modified_event] fc3a3a adding state.InstanceState object at 0x7f6a5bb989e8> as modified

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Mike Bayer
below are some assertions you could add, if these rules don't work exactly right then you could trip into that error condition diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 5a27140ac..64da5072a 100644 --- a/lib/sqlalchemy/orm/session.py +++

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Mike Bayer
if you can at least share the stack trace that should tell a lot On Mon, Feb 26, 2018 at 3:05 PM, Mike Bayer wrote: > On Mon, Feb 26, 2018 at 2:54 PM, Cecil Rock wrote: >> Hi, >> >> I have a question about some ORM internal state tracking stuff.

Re: [sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Mike Bayer
On Mon, Feb 26, 2018 at 2:54 PM, Cecil Rock wrote: > 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

[sqlalchemy] InstanceState dirty but will not flush

2018-02-26 Thread Cecil Rock
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

Re: [sqlalchemy] Re: Relationships - crash when class instantiation

2018-02-26 Thread Sven
Thank you Mike, it works ! Le samedi 24 février 2018 16:35:57 UTC+1, Mike Bayer a écrit : > > On Sat, Feb 24, 2018 at 5:33 AM, Sven > wrote: > > Hello, > > > > I have now a small example which illustrates the problem. > > > > Program logic : each NPC inherites from