How do you plan to use WAIT FOR LSN from an application point of view? While it sounds awesome as a building block, it is unclear for me, what is the good way to expose such primitive for applications.
You’d probably write a helper function that automatically runs SELECT pg_current_wal_insert_lsn() after a write and returns it.
That said, I don’t see the point. If you need to read DB-generated data (like a PK, or timestamp) from a write, use RETURNING so you get it with one call, and pass that to another function if it needs it. If it’s data you wrote, you already have it. So many web apps are slow because they have a million services, and all of them are calling the DB for the same information instead of passing it to each other.
If you can do this and that matches the use case, sure, that's certainly the best way.
But your writes and reads might have other calls in between.
Another case is that the read in question is a (relatively) heavy query, which one might want to intentionally offload to a read replica.
I remember reading a blog from gitlab engineering some years back.
Immediately after a form submission the read api could not be directed to replica as it might be stale, so they were reading the WAL position and directing the query to writer or reader. This change formalizes that pattern.
That said, I don’t see the point. If you need to read DB-generated data (like a PK, or timestamp) from a write, use RETURNING so you get it with one call, and pass that to another function if it needs it. If it’s data you wrote, you already have it. So many web apps are slow because they have a million services, and all of them are calling the DB for the same information instead of passing it to each other.