Concurrent Update of Array (Postgres)
There is nothing you need to do, because this kind of anomaly cannot occur in PostgreSQL.
When the second transaction gets the lock on the row, it will re-read it and see the value modified by the first transaction.
See the documentation for details.