Fix context query cancellation
Previous commits had a race condition due to not waiting for the PostgreSQL server to close the cancel query connection. This made it possible for the cancel request to impact a subsequent query on the same connection. This commit sets a flag that a cancel request was made and blocks until the PostgreSQL server closes the cancel connection.
This commit is contained in:
@@ -419,6 +419,11 @@ func (c *Conn) QueryRow(sql string, args ...interface{}) *Row {
|
||||
}
|
||||
|
||||
func (c *Conn) QueryContext(ctx context.Context, sql string, args ...interface{}) (rows *Rows, err error) {
|
||||
err = c.waitForPreviousCancelQuery(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.lastActivityTime = time.Now()
|
||||
|
||||
rows = c.getRows(sql, args)
|
||||
|
||||
Reference in New Issue
Block a user