Skip to content

Commit

Permalink
sqlite cached_statements workaround (#19114)
Browse files Browse the repository at this point in the history
### Purpose:

Newer versions of python return incorrect sqlite results if
cached_statements is nonzero. See:

python/cpython#118172

### Current Behavior:

cached_statements is set to default

### New Behavior:

cached_statements is set to 0. Chia rarely repeats the same sqlite
queries so hopefully this does not affect performance.

### Testing Notes:

None
  • Loading branch information
wjblanke authored Jan 9, 2025
2 parents c5dd8f2 + 31f48b9 commit 2509071
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion chia/util/db_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ async def _create_connection(
log_file: Optional[TextIO] = None,
name: Optional[str] = None,
) -> aiosqlite.Connection:
connection = await aiosqlite.connect(database=database, uri=uri)
# To avoid https://github.com/python/cpython/issues/118172
connection = await aiosqlite.connect(database=database, uri=uri, cached_statements=0)

if log_file is not None:
await connection.set_trace_callback(functools.partial(sql_trace_callback, file=log_file, name=name))
Expand Down

0 comments on commit 2509071

Please sign in to comment.