-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: remove the conflict between DB updates and running queries
Each database handle has a shared lock that queries hold while they run, and that updating the state of the handle with a new database, label, and named queries acquire exclusively. This meant that handing off a new database would block for a long-running query. I dealt with this by setting a timeout on user queries. That works, but can be annoying when users have a complex query to run that may take a while. To address this, change the way updates are done: - If an update arrives and the handle is not locked, it is applied immediately (as before). - But if the handle is locked (busy), record the intended update in an atomic field. - Each time a query exits, it checks whether there is a pending update and tries to apply it. - Each time the UI browses the handles, it checks whether there are pending updates and tries to apply them. If an update cannot be applied immediately, then one or more running queries hold the lock that prevents it. Either the last such query, or a subsequent UI visit, will notice the pending query and apply it.
- Loading branch information
1 parent
fe491d5
commit 8400c81
Showing
3 changed files
with
84 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters