processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

SELECT ... FOR UPDATE and likely other locking reads not working with dbReader

Open teppokoivula opened this issue 1 year ago • 2 comments

In a codebase that makes use of SELECT ... FOR UPDATE (and likely other locking reads, though I haven't tested others) the core WireDatabasePDO class uses reader instance, which results in an exception since the database is in read-only mode.

Seems like something that WireDatabasePDO::pdoType() should and could handle?

More about different locking reads: https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html

teppokoivula avatar Mar 01 '24 09:03 teppokoivula

@teppokoivula Thanks, I've pushed a fix for this issue. Though I've not used these locking reads as most of the queries I write have to be compatible across myisam and innodb, so I'm just going by the examples mentioned on the linked page. If you find other queries where the solution doesn't work, please let me know.

ryancramerdesign avatar Mar 01 '24 14:03 ryancramerdesign

Awesome, thanks! We'll get to testing likely next week, so I'll leave the issue open until then.

teppokoivula avatar Mar 01 '24 15:03 teppokoivula

@teppokoivula, any news on this?

matjazpotocnik avatar Jul 19 '24 06:07 matjazpotocnik

Haven't heard back from the team yet, but I'll assume that the fix works, so closing the issue :)

teppokoivula avatar Jul 19 '24 07:07 teppokoivula