]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Send deterministic ordering into unit of work topological
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Nov 2020 17:50:51 +0000 (12:50 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 12 Dec 2020 00:19:17 +0000 (19:19 -0500)
commitaf0b13b6d919c8c9ddf3a803eef21cd1a00a36ce
treebd1ce7e4998570feaed688f2c7caad5d0a54e2b8
parent5b05041a80f7276298f612d3b1a434c2ae577000
Send deterministic ordering into unit of work topological

Improved the unit of work topological sorting system such that the
toplogical sort is now deterministic based on the sorting of the input set,
which itself is now sorted at the level of mappers, so that the same inputs
of affected mappers should produce the same output every time, among
mappers / tables that don't have any dependency on each other. This further
reduces the chance of deadlocks as can be observed in a flush that UPDATEs
among multiple, unrelated tables such that row locks are generated.

topological.sort() has been made "deterministic" in all cases by
using a separate list + set.

Fixes: #5735
Change-Id: I073103df414dba549e46605b394f8ccae6e80d0e
doc/build/changelog/unreleased_14/5735.rst [new file with mode: 0644]
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/unitofwork.py
lib/sqlalchemy/sql/ddl.py
lib/sqlalchemy/util/topological.py
test/base/test_dependency.py
test/orm/test_unitofwork.py
test/orm/test_unitofworkv2.py