seems postgresql have some issue in transaction when update with subquery
there are one record in table with column lock_id is null;
TESTCASE1
1、excute update table set lock_id = 1 where id in (select id from table where lock_id is null order by creation_date limit 100) but no commit;
2、excute update table set lock_id = 2 where id in (select id from table where lock_id is null order by creation_date limit 100) but no commit;
3、commit step 1;
4、commit step 2;
5 query the column lock_id ,result is 2
TESTCASE2
1、excute update table set lock_id = 1 where lock_id is null but no commit;
2、excute update table set lock_id = 2 where lock_id is null but no commit;
3、commit step 1;
4、commit step 2;
5 query the column lock_id ,result is 1
seems when there are subquery in update's condition,the second update will cover up the first one
For me,I have some concurrent scenarios, two machine will try to excute update like testcase1 to lock 100 records and then query the records for subsequent processings by lock_id,but sometimes two machine both handle a same record;
How to avoid this behaviour?