Skip to content

Does context cancellation cancel the underlying query? #731

Closed
@knadh

Description

@knadh
ctx, cancel := context.WithCancel(context.Background())

// Cancel 5 seconds in.
go func() {
	time.Sleep(time.Second * 5)
  	cancel()
}()

// This query should take 10 seconds to return.
rows, err := dbt.db.QueryContext(ctx, "SELECT v, SLEEP(10) FROM test LIMIT 1")
fmt.Println(rows, err)

After reading #496 and #608, I was under the impression that in the above example, the underlying query would get canceled mid-execution, but that doesn't seem to be the case. It still takes 10 seconds to return (and the query shows in MySQL process list), albeit with the error sql: Rows are closed. Does this mean that the driver isn't actually able to cancel the underlying query running on the server?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions