The log_counter table tracks this. It's true that a naive solution using sequences does not work for exactly the reason you say.
The log_counter table tracks this. It's true that a naive solution using sequences does not work for exactly the reason you say.