Skip to content

[YSQL] ALTER TABLE add primary key fails with error "Transaction aborted due to deadlock - kDeadlock". #29934

@dhruva4869

Description

@dhruva4869

Jira Link: DB-19787

Description

Version - 2.29.0.0-b328
Steps-

  1. Create database, tables, partitions, indexes, constraints, materialized views and load data
  2. Create before row triggers on partition tables.
  3. Load some data using INSERTS and bulk copy from/to
  4. Create snapshot schedule and take time t1
  5. Detach existing partitions, attach new partitions
  6. Drop a few triggers, create new ones
  7. Restore to time t1 (PITR)
  8. Insert more data, create new triggers
  9. Do bunch of alters on the tables, including drop constraint, add column, rename columns, set default. The add constraint primary key fails intermittently around 20-30% of the times with error -
DatabaseError('deadlock detected\nDETAIL:  Transaction 2d16d955-dfc8-4102-ad54-25a4a86dfdf6 aborted due to a deadlock: <1767962626864104>2d16d955-dfc8-4102-ad54-25a4a86dfdf6-><1767961902779172>a572b896-d6ea-4dee-b9b7-40a52af0b2c9->: kDeadlock\n')

ALTER query that fails - ALTER TABLE employees_hash ADD CONSTRAINT employees_hash_pkey PRIMARY KEY(id,age)
Issue reprod 2 times in about 10 runs and both times the same above query failed.

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions