summaryrefslogtreecommitdiff
path: root/test/orm/test_options.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-05-12 23:42:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2023-05-13 10:59:16 -0400
commit4b37ded2897c3ae9384ecdd6209699a0fdc513a3 (patch)
treefced3c194d055bc97c86f6ab039f1e63f1372937 /test/orm/test_options.py
parenteb286c15f096771dbb128acbe8fe03e94aa72f6a (diff)
downloadsqlalchemy-4b37ded2897c3ae9384ecdd6209699a0fdc513a3.tar.gz
remove "aliased class pool" caching approach
Modified the ``JoinedLoader`` implementation to use a simpler approach in one particular area where it previously used a cached structure that would be shared among threads. The rationale is to avoid a potential race condition which is suspected of being the cause of a particular crash that's been reported multiple times. The cached structure in question is still ultimately "cached" via the compiled SQL cache, so a performance degradation is not anticipated. The change also modifies the tests for None in context.secondary to ensure no None values are in this list, as this is suspected as being the immediate cause of the issue in #9777. The cached AliasedClass thing is suspected as being the origination of the cause, as under high concurrency many threads might all access that AliasedClass immediately, which seems a reasonable place that the "adapter returning None" symptom might be originating. As of yet we don't have a self-contained reproducer for the issue, some initial attempts with threads are not showing any issue. Fixes: #9777 Change-Id: I967588f280796c413e629b55b8d97d40c1164248
Diffstat (limited to 'test/orm/test_options.py')
-rw-r--r--test/orm/test_options.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/orm/test_options.py b/test/orm/test_options.py
index 47ffedb07..3b088b998 100644
--- a/test/orm/test_options.py
+++ b/test/orm/test_options.py
@@ -28,6 +28,7 @@ from sqlalchemy.orm import undefer
from sqlalchemy.orm import util as orm_util
from sqlalchemy.orm import with_polymorphic
from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import is_not
from sqlalchemy.testing.assertions import assert_raises_message
from sqlalchemy.testing.assertions import AssertsCompiledSQL
from sqlalchemy.testing.assertions import emits_warning
@@ -1288,20 +1289,18 @@ class PickleTest(fixtures.MappedTest):
def test_pickle_relationship_loader(self, user_address_fixture):
User, Address = user_address_fixture
- for i in range(3):
- opt = joinedload(User.addresses)
-
- q1 = fixture_session().query(User).options(opt)
- c1 = q1._compile_context()
+ opt = joinedload(User.addresses)
- pickled = pickle.dumps(opt)
+ pickled = pickle.dumps(opt)
- opt2 = pickle.loads(pickled)
+ opt2 = pickle.loads(pickled)
- q2 = fixture_session().query(User).options(opt2)
- c2 = q2._compile_context()
+ is_not(opt, opt2)
+ assert isinstance(opt, Load)
+ assert isinstance(opt2, Load)
- eq_(c1.attributes, c2.attributes)
+ for k in opt.__slots__:
+ eq_(getattr(opt, k), getattr(opt2, k))
class LocalOptsTest(PathTest, QueryTest):