Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OperationalError('interrupted') can 500 on row page #1088

Closed
simonw opened this issue Nov 12, 2020 · 3 comments
Closed

OperationalError('interrupted') can 500 on row page #1088

simonw opened this issue Nov 12, 2020 · 3 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Nov 12, 2020

I got this on my (private) https://dogsheep.simonwillison.net/twitter/tweets/1188612004572880896 page:

Error_500

@simonw simonw added the bug label Nov 12, 2020
@simonw
Copy link
Owner Author

simonw commented Nov 12, 2020

I'm suspicious of this code:

sql = "select " + ", ".join(
[
"(select count(*) from {table} where {column}=:id)".format(
table=escape_sqlite(fk["other_table"]),
column=escape_sqlite(fk["other_column"]),
)
for fk in foreign_keys
]
)
try:
rows = list(await db.execute(sql, {"id": pk_values[0]}))
except sqlite3.OperationalError:
# Almost certainly hit the timeout
return []

This code uses a different exception:

if count_sql and filtered_table_rows_count is None:
try:
count_rows = list(await db.execute(count_sql, from_sql_params))
filtered_table_rows_count = count_rows[0][0]
except QueryInterrupted:
pass

@simonw
Copy link
Owner Author

simonw commented Nov 12, 2020

Yup, swapping QueryInterrupted fixed this against my giant database.

@simonw
Copy link
Owner Author

simonw commented Nov 12, 2020

I'm going to fix this without a test, because writing a test for this is a bit fiddly and it's a very minor bug. If it comes back again I'll do the work to test for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant