I am currently trying to write a scheduler in Java which will read from an AWS Postgres read replica in batches and do some processing. This scheduler will be run on a cluster of Java instances. The current issue I am having is that I am unable to tell whether a row has been processed yet or not.
I am thinking about using a “SELECT * from table Limit 1 FOR UPDATE SKIP LOCKED” but I am wondering if:
- Is it possible to SELECT FOR UPDATE on a read replica
- How would I release this lock?
- If I cannot use this, is there any other way I can coordinate the batch processing on a read replica with multiple Java instances. (I.e would spring batch be able to this?)