Skip to content

Commit

Permalink
Generalize "fix" for 5432 after new occurence
Browse files Browse the repository at this point in the history
As I wrote in
rotki#5432 (comment) the
issue popped up again in a different place.

This means that this driver bug is more generic and can hit us in many
different places.

So I am moving the "fix" to the cursor itself.

We really need to find a proper fix for this
  • Loading branch information
LefterisJP committed Jun 22, 2023
1 parent 56bd8fb commit ef7f094
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rotkehlchen/chain/ethereum/modules/nft/nfts.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_db_nft_balances(self, filter_query: 'NFTFilterQuery') -> dict[str, Any]:
query, bindings = filter_query.prepare()
total_usd_value = ZERO
with self.db.conn.read_ctx() as cursor:
cursor.execute(
cursor.execute( # this sometimes causes https://github.com/rotki/rotki/issues/5432
'SELECT identifier, name, last_price, last_price_asset, manual_price, is_lp, '
'image_url, collection_name FROM nfts ' + query,
bindings,
Expand Down
7 changes: 1 addition & 6 deletions rotkehlchen/db/dbhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,12 +1107,7 @@ def get_tokens_for_address(
last_queried_ts = None
querystr = 'SELECT key, value FROM evm_accounts_details WHERE account=? AND chain_id=? AND (key=? OR key=?)' # noqa: E501
bindings = (address, blockchain.to_chain_id().serialize_for_db(), EVM_ACCOUNTS_DETAILS_LAST_QUERIED_TS, EVM_ACCOUNTS_DETAILS_TOKENS) # noqa: E501
try:
cursor.execute(querystr, bindings)
except sqlcipher.InterfaceError: # pylint: disable=no-member
# Long story. Don't judge me. https://github.com/rotki/rotki/issues/5432
log.debug(f'{querystr} with {bindings} failed due to https://github.com/rotki/rotki/issues/5432. Retrying') # noqa: E501
cursor.execute(querystr, bindings)
cursor.execute(querystr, bindings) # original place https://github.com/rotki/rotki/issues/5432 was seen # noqa: E501

returned_list = []
for (key, value) in cursor:
Expand Down
8 changes: 7 additions & 1 deletion rotkehlchen/db/drivers/gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ def __exit__(
def execute(self, statement: str, *bindings: Sequence) -> 'DBCursor':
if __debug__:
logger.trace(f'EXECUTE {statement}')
self._cursor.execute(statement, *bindings)
try:
self._cursor.execute(statement, *bindings)
except (sqlcipher.InterfaceError, sqlite3.InterfaceError): # pylint: disable=no-member
# Long story. Don't judge me. https://github.com/rotki/rotki/issues/5432
logger.debug(f'{statement} with {bindings} failed due to https://github.com/rotki/rotki/issues/5432. Retrying') # noqa: E501
self._cursor.execute(statement, *bindings)

if __debug__:
logger.trace(f'FINISH EXECUTE {statement}')
return self
Expand Down

0 comments on commit ef7f094

Please sign in to comment.