Skip to content

Commit

Permalink
Drop dead code (#6818)
Browse files Browse the repository at this point in the history
Queries after DDL in a transaction have been running without cache for
some time, dropping the dead code for now; maybe we will add it back in
the future properly.
  • Loading branch information
fantix authored and aljazerzen committed Mar 13, 2024
1 parent 4c4ee28 commit 1486f44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
4 changes: 0 additions & 4 deletions edb/server/dbview/dbview.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ cdef class DatabaseConnectionView:
tuple _session_state_db_cache
tuple _session_state_cache


object _eql_to_compiled

object _txid
object _in_tx_db_config
object _in_tx_savepoints
Expand All @@ -163,7 +160,6 @@ cdef class DatabaseConnectionView:

object __weakref__

cdef _invalidate_local_cache(self)
cdef _reset_tx_state(self)

cdef clear_tx_error(self)
Expand Down
36 changes: 6 additions & 30 deletions edb/server/dbview/dbview.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ cdef class Database:

cdef class DatabaseConnectionView:

_eql_to_compiled: typing.Mapping[bytes, dbstate.QueryUnitGroup]

def __init__(self, db: Database, *, query_cache, protocol_version):
self._db = db

Expand Down Expand Up @@ -325,16 +323,8 @@ cdef class DatabaseConnectionView:
self._last_comp_state = None
self._last_comp_state_id = 0

# Whenever we are in a transaction that had executed a
# DDL command, we use this cache for compiled queries.
self._eql_to_compiled = lru.LRUMapping(
maxsize=defines._MAX_QUERIES_CACHE)

self._reset_tx_state()

cdef _invalidate_local_cache(self):
self._eql_to_compiled.clear()

cdef _reset_tx_state(self):
self._txid = None
self._in_tx = False
Expand All @@ -354,7 +344,6 @@ cdef class DatabaseConnectionView:
self._in_tx_state_serializer = None
self._tx_error = False
self._in_tx_dbver = 0
self._invalidate_local_cache()

cdef clear_tx_error(self):
self._tx_error = False
Expand All @@ -379,7 +368,6 @@ cdef class DatabaseConnectionView:
self.set_session_config(config)
self.set_globals(globals)
self.set_state_serializer(state_serializer)
self._invalidate_local_cache()

cdef declare_savepoint(self, name, spid):
state = (
Expand Down Expand Up @@ -729,11 +717,8 @@ cdef class DatabaseConnectionView:
cdef cache_compiled_query(self, object key, object query_unit_group):
assert query_unit_group.cacheable

key = (key, self.get_modaliases(), self.get_session_config())

if self._in_tx_with_ddl:
self._eql_to_compiled[key] = query_unit_group
else:
if not self._in_tx_with_ddl:
key = (key, self.get_modaliases(), self.get_session_config())
self._db._cache_compiled_query(key, query_unit_group)

cdef lookup_compiled_query(self, object key):
Expand All @@ -743,14 +728,10 @@ cdef class DatabaseConnectionView:
return None

key = (key, self.get_modaliases(), self.get_session_config())

if self._in_tx_with_ddl:
query_unit_group = self._eql_to_compiled.get(key)
else:
query_unit_group, qu_dbver = self._db._eql_to_compiled.get(
key, DICTDEFAULT)
if query_unit_group is not None and qu_dbver != self._db.dbver:
query_unit_group = None
query_unit_group, qu_dbver = self._db._eql_to_compiled.get(
key, DICTDEFAULT)
if query_unit_group is not None and qu_dbver != self._db.dbver:
query_unit_group = None

return query_unit_group

Expand Down Expand Up @@ -817,11 +798,6 @@ cdef class DatabaseConnectionView:
cdef on_success(self, query_unit, new_types):
side_effects = 0

if query_unit.tx_savepoint_rollback:
# Need to invalidate the cache in case there were
# SET ALIAS or CONFIGURE or DDL commands.
self._invalidate_local_cache()

if not self._in_tx:
if new_types:
self._db._update_backend_ids(new_types)
Expand Down

0 comments on commit 1486f44

Please sign in to comment.