]> Cypherpunks repositories - gostls13.git/commit
database/sql: prevent Tx statement from committing after rollback
authorDaniel Theophanes <kardianos@gmail.com>
Fri, 24 Jan 2020 14:40:49 +0000 (06:40 -0800)
committerDaniel Theophanes <kardianos@gmail.com>
Mon, 20 Apr 2020 17:45:50 +0000 (17:45 +0000)
commitd8f0a229b5036e42b7bc5371c32c302cead9b635
treee01113d48c74f9000588df3dd910d7e49d0391f8
parentb2cff7e091ca1f59ceb77c4dd3acaf0c150b5440
database/sql: prevent Tx statement from committing after rollback

It was possible for a Tx that was aborted for rollback
asynchronously to execute a query after the rollback had completed
on the database, which often would auto commit the query outside
of the transaction.

By W-locking the tx.closemu prior to issuing the rollback
connection it ensures any Tx query either fails or finishes
on the Tx, and never after the Tx has rolled back.

Fixes #34775
Fixes #32942

Change-Id: I017b7932082f2f4ead70bae08b61ed9068ac1d01
Reviewed-on: https://go-review.googlesource.com/c/go/+/216240
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
src/database/sql/fakedb_test.go
src/database/sql/sql.go
src/database/sql/sql_test.go