Skip to content

Fix freeze/deadlock after aborted pragma #3742

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

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

chrschllr
Copy link
Contributor

This is a proposed fix for #3741.
(I stumbled upon this when using pragma legacy_alter_table=1 as a workaround for #1686, after I had added a few rows to a table.)

When saving, the GUI thread blocks on DBBrowserDB::waitForDbRelease line 847, where it waits for db_used to become false. This must be done by ~db_pointer_type (DatabaseReleaser).

In RunSql::executeNextStatement this deleter is normally invoked by RunSql::releaseDbAccess, but in the case of a pragma statement on a dirty DB, the function exits early (line 140) without calling releaseDbAccess. This creates a deadlock, as db_used is never set to false - thus hindering the GUI thread from accepting any user input.

Calling the aforementioned method before returning resolved the issue for me. I'm neither familiar with the sqlitebrowser codebase nor with C++ in general, so this probably isn't the best solution.

@lucydodo
Copy link
Member

lucydodo commented Oct 7, 2024

Thanks for the contribution. This seems like a decent approach to me, But before I merge it, I'd like to ask our lead maintainer for his opinion: @mgrojo I was wondering if you had any thoughts on this PR? :)

@mgrojo
Copy link
Member

mgrojo commented Oct 12, 2024

Thanks, @chrschllr. This seems correct. It also fixes the uglier part of #3723, although the VACUUM is still not executed.

I will merge it to master branch now, and it should also go in our next bug-fix release.

@mgrojo mgrojo merged commit 15a9620 into sqlitebrowser:master Oct 12, 2024
11 checks passed
@justinclift justinclift added this to the 3.13.1 milestone Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants