Hi,
I'd like to submit a patch to fix an issue in dml_adaptive load balancing when ROLLBACK TO SAVEPOINT is used.
Currently, dml_adaptive() uses is_commit_or_rollback_query() to determine whether a transaction has ended. However, this function also returns true for ROLLBACK TO SAVEPOINT, even though the transaction itself is still active.
As a result, ROLLBACK TO SAVEPOINT clears is_in_transaction and the accumulated transaction write list. A subsequent SELECT on a table modified earlier in the same transaction may then be load balanced to a standby, potentially returning stale data.
This patch changes the transaction-end check so that only COMMIT and normal ROLLBACK clear the transaction state. ROLLBACK TO SAVEPOINT now preserves the accumulated write list.
I also added a regression test to confirm that a SELECT after ROLLBACK TO SAVEPOINT is still sent to the primary when the table was modified earlier in the transaction.
The patch is attached.
Discussion:
https://github.com/pgpool/pgpool2/issues/173
Best Regards,
Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/