diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-09 15:24:37 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-09 15:24:37 -0400 |
commit | b8a39b8636c8abef350e17ecca61e2a215931c9b (patch) | |
tree | e3367f57feae7f1d990cf132cffa0f9bf1fdfa41 /lib/sqlalchemy/engine/base.py | |
parent | adaa003300357179514628cd1735a7adae76b839 (diff) | |
download | sqlalchemy-b8a39b8636c8abef350e17ecca61e2a215931c9b.tar.gz |
- fix a potential race condition where the per-mapper LRUCache used by
persistence.py could theoretically hit the limit of the cache
(100 items by default) and at some points fail to have a key that
we check for, due to the cleanup. This has never been observed
so its likely that so far, the total number of INSERT, UPDATE and
DELETE statement structures in real apps has not exceeded 100
on a per-mapper basis; this could happen for apps that run a
very wide variety of attribute modified combinations into the unit
of work, *and* which have very high concurrency going on.
This change will be a lot more significant when we open up
use of LRUCache + compiled cache with the baked query extension.
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 305fa4620..067d32538 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -991,9 +991,8 @@ class Connection(Connectable): dialect = self.dialect if 'compiled_cache' in self._execution_options: key = dialect, elem, tuple(sorted(keys)), len(distilled_params) > 1 - if key in self._execution_options['compiled_cache']: - compiled_sql = self._execution_options['compiled_cache'][key] - else: + compiled_sql = self._execution_options['compiled_cache'].get(key) + if compiled_sql is None: compiled_sql = elem.compile( dialect=dialect, column_keys=keys, inline=len(distilled_params) > 1) |