[YSQL] DROP SEQUENCE is not atomic #16309
Labels
area/ysql
Yugabyte SQL (YSQL)
kind/bug
This issue is a bug
priority/medium
Medium priority issue
status/awaiting-triage
Issue awaiting triage
Projects
Jira Link: DB-5734
Description
Some objects are represented in both PG and YB (also colloquially referred to as "DocDB"). For example, tables: CREATE TABLE will first create the DocDB table then commit the pg metadata, and DROP TABLE will first remove the pg metadata then remove the DocDB table.
Sequences similarly have a PG representation and DocDB representation. However, it appears they have been neglected on the atomicity improvements that have been done on other objects like tables. So it may be possible for the sequence to exist in PG but not in DocDB or vice versa.
Here's an easy repro showing how DROP SEQUENCE may drop the sequence in DocDB but not in PG in case of a crash between the two internal steps:
Apply patch on master commit c92ad22:
bin/yb-ctl create --tserver_flags "ysql_sequence_cache_minval=0" bin/ysqlsh
cc: @deeps1991, @mislam-yb
Note that we can have issues with ALTER SEQUENCE RESET due to lack of atomicity. CREATE SEQUENCE can also possibly leave behind garbage rows in DocDB. However these issues are separately tracked in #19011 where we will convert the sequences table backed by DocDB into a transactional table that can be updated atomically with the PG catalog. This ticket merely tracks the fix for the failures incurred above due to DROP SEQUENCE not being atomic.
The text was updated successfully, but these errors were encountered: