From: | Marc-Olaf Jaschke <moj(at)dshare(dot)de> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | concurrent creation of sequences |
Date: | 2021-03-31 16:26:52 |
Message-ID: | F385393C-7ADD-45D6-855A-767DFD245006@dshare.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I have a use case where I need to create sequences concurrently. I use sequences instead of a table with counters to keep lock contention for incrementing the id low. The creation of new sequences rarely occurs during normal application operation.
I check via information_schema.sequences if a sequence already exists and catch errors that occur with concurrent access if the corresponding sequence already exists.
I wrote a stress test that simulates the behavior with heavy concurrency. I get the following three different error codes:
42P07
42710
23505
I would have expected only 42710 (duplicate_object).
Is this behavior intentional?
Are there possibly other error codes that the stress test did not uncover and that I should consider?
"create sequence if not exists ..." does not prevent errors with concurrency.
Tested with "PostgreSQL 12.6 on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 8.1.0 (clang-802.0.42), 64-bit"
Best regards,
Marc-Olaf Jaschke
From | Date | Subject | |
---|---|---|---|
Next Message | Mutuku Ndeti | 2021-03-31 17:14:03 | Postgres connection to hot standby |
Previous Message | Michael Lewis | 2021-03-31 16:03:21 | Re: Primary keys and composite unique keys(basic question) |