learningequality/morango

Modifying the database connection's transaction isolation persists beyond the transaction

Closed this issue · 0 comments

Background

We recently made fixes to Morango that correct the database transaction handling, which was meant to perform certain operations within a transaction with higher transaction isolation when using postgres. Due to connection mismanagement, the operations weren't actually executing in a transaction.

Observed behavior

A bad assumption was made by @bjester thinking that setting the transaction isolation level after opening a transaction would execute SQL that modifies the current transaction's isolation level. Instead, the BEGIN of the transaction is actually delayed until SQL is executed through the connection, which means the isolation is enabled through the BEGIN statement and persists for all transactions opened through that connection until it is closed.

Expected behavior

Morango should apply the higher transaction isolation level for the duration of the transaction, by rolling it back to its previous level after the transaction has been closed, either by ROLLBACK or COMMIT.