[1.6.x] Fixed #19918 -- Modified select_for_update to run on the write database.

Backport of 1c64a0f29e from master