elixir-sqlite / exqlite

An SQLite3 driver for Elixir
https://hexdocs.pm/exqlite
MIT License
198 stars 46 forks source link

Add Exqlite.Sqlite3.interrupt/1. #282

Closed ColaCheng closed 3 months ago

ColaCheng commented 3 months ago

We encounter the db connection can not be closed when a long-running query gets a timeout(Ecto environment) but the query is still running in the background and takes the CPU resource. For this function, we can manually trigger and force-stop the query. Then we can close and release the resource successfully.

Ref: https://www.sqlite.org/c3ref/interrupt.html

warmwaffles commented 3 months ago

@ColaCheng yes I've been wanting to add this. Although it will not solve the issue of that long running query in the background because of the connection pool. If your connection pool is 2 then there is no guarantee that the interrupt will be routed to the problematic "connection".

That being said, thank you for implementing this and I'll get this merged. 😄

warmwaffles commented 3 months ago

Released under v0.21.0