Suspiciously fast auto-increment speed in the table
Hi there!
I noticed that after restarting an node.js application that uses pglite and auto-increment, the auto-increment value increases by more than one—sometimes by ten, for example. I'm not sure if this is a bug or a feature, so I decided to create a sandbox and explain how to reproduce it.
Also the same case reproducible in browser with usage of IndexedDB for persistence.
Here sandbox https://codesandbox.io/p/devbox/pglite-test-case-tyzvn7 in which you can reproduce the case.
Just go to terminal and restart application with ctrl + c and that by re-run app by command npm install && npm start. You will see that the auto-increment for new rows increases by more than one.
Hey @naliferov
I've also noticed this, as far as I can see it only happens on a restart, jumping ahead in the sequence.
I have a suspicion it is due to how Postgres has to handle these sequences in the multi-process environment, but I've not dug in. We should confirm what the behaviour of native Postgres is, both on clean and unclean shutdown+restart, and see if we can reproduce there. It will give us a steer on if this is expected behaviour or not.