go-sql-driver / go-sql-driver/mysql

ExecContext should return error if it is canceled during execution

Open
#1,287 21 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
15.3k
Forks
2.3k
Avg merge
2h 23m
Merged PRs (30d)
10

Description

### Issue description
[`mysqlConn.ExecContext`](https://github.com/go-sql-driver/mysql/blob/v1.6.0/connection.go#L514) uses [`mysqlConn.watchCancel`](https://github.com/go-sql-driver/mysql/blob/v1.6.0/connection.go#L520) to decide if the `ctx` passed as an argument is canceled, so if the `ctx` is canceled before the decision, it returns an error. However, `mysqlConn.ExecContext` does not return an error even if the `ctx` is cancelled [during or after `mysqlConn.Exec` execution](https://github.com/go-sql-driver/mysql/blob/v1.6.0/connection.go#L525), or [during `mysqlConn.finish` execution in `defer`](https://github.com/go-sql-driver/mysql/blob/v1.6.0/connection.go#L523). Is this the intended behavior?

### Configuration
*Driver version (or git SHA):*

*Go version:* 1.17.2

*Server version:* E.g. MySQL 5.7

*Server OS:* amazonlinux:latest(Docker Image)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.