Executing a Broken Statement Causes a Hang
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Run the provided main.go reproduction and trace the sqlitepool.NewPool, BeginTx, and transaction.Exec entry points. Determine why an invalid statement in a transaction does not return and verify the fix by confirming the example reports an error instead of hanging.
Written by the indexing model from the issue text.
Description
Hi,
whenever you try to execute an invalid statement in a transaction an error isn't returned (nor a panic thrown) the program just hangs.
I'd initially noticed this when inserting twice into a table that expected a column to be unique assuming I'd see an error but instead the program just hung.
this does not seem to be directly related to the unique constraint, it seems to happened with any invalid statement; even if they aren't valid SQL.
here's a example:
package main
import (
"context"
"log"
"github.com/tailscale/sqlite/sqliteh"
"github.com/tailscale/sqlite/sqlitepool"
)
var db *sqlitepool.Pool
func init() {
var err error
db, err = sqlitepool.NewPool("file:./db.sqlite", 10, func(init sqliteh.DB) error { return nil }, nil)
if err != nil {
panic(err)
}
}
func main() {
defer db.Close()
transaction, err := db.BeginTx(context.Background(), "")
if err != nil {
panic(err)
}
log.Println("executing invalid statement")
err = transaction.Exec("this should throw an error")
if err != nil {
panic(err)
}
log.Println("done")
err = transaction.Commit()
if err != nil {
panic(err)
}
}
running this program yields the following then hangs forever:
% go run main.go
2023/03/01 22:43:26 executing invalid statement
- Dominant language
- C
- Stars
- 225
- Forks
- 11
- Avg merge
- 20m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tailscale/sqlite
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in tailscale/sqlite
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·