sqlalchemy: Regression in lambda behavior between 1.4 and 2.0
Describe the bug
After upgrading to 2.x the race/thread-safety with the lambdas appears to have returned https://github.com/home-assistant/core/issues/89170
Previous issue https://github.com/sqlalchemy/sqlalchemy/issues/8098
git diff -w rel_1_4_46..rel_2_0_5_post1 -- lib/sqlalchemy/sql/lambdas.py
It looks like the lock was removed here
if rec is None:
- if cache_key is not traversals.NO_CACHE:
-
- with AnalyzedCode._generation_mutex:
- key = tracker_key + cache_key
- if key not in lambda_cache:
+ if cache_key is not _cache_key.NO_CACHE:
rec = AnalyzedFunction(
tracker, self, apply_propagate_attrs, fn
)
rec.closure_bindparams = bindparams
- lambda_cache[key] = rec
- else:
- rec = lambda_cache[key]
+ lambda_cache[tracker_key + cache_key] = rec
else:
rec = NonAnalyzedFunction(self._invoke_user_fn(fn))
Optional link from https://docs.sqlalchemy.org which documents the behavior that is expected
No response
SQLAlchemy Version in Use
2.0.5.post1
DBAPI (i.e. the database driver)
all
Database Vendor and Major Version
all
Python Version
3.10/3.11
Operating system
Linux
To Reproduce
The ones from the previous issue should still be valid
Error
Data is mixed up as before
Additional context
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (17 by maintainers)
I am hoping for today. We had a problem with our last release so with this release I needed @CaselIT to be around in case there are problems with wheel builds, hence I didnt release over the weekend
thanks for reporting, will try to look when i next have time
That wheel issue should be fixed, still a bit of work to be done on the wheel pipeline, but we should be good to release also without waiting for it