citusdata / citusdata/citus

Locking issues

Open
#2,888 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Postgres 12 has added some `Assert(CheckRelationLockedByMe(...))` assertions. This makes Citus fail at few places where we are not getting the correct locks.

The two points I've seen so far:
- `RecordRelationAccessBase()` in `relation_access_tracking.c` calls `PartitionTableNoLock()` and `PartitionedTableNoLock()`, but in some cases we are not holding the correct locks.
- `simple_heap_delete()` calls on tables with primary keys requires we also hold locks for the replica index.

We will fix the `simple_heap_delete()` in 8.4. The first issue needs more work, so my suggestion is in 8.4 use `PartitionTable()` and `PartitionedTable()` which will avoid the assertion failures, and in 9.0 allocate time to fix the root problem and revert them back to `PartitionTableNoLock()` and `PartitionedTableNoLock().

8.4 todo list:

- [ ] Avoid assertion failures in `RecordRelationAccessBase()` by using `PartitionTable()` and `PartitionedTable()`.
- [ ] Acquire locks on replica indexes before `simple_heap_delete()` on tables with primary keys.

9.0 todo list:
- [ ] Fix the root issues for failures in `RecordRelationAccessBase()`
- [ ] Change "UNIQUE" columns to "PRIMARY KEY" and fix the `simple_heap_delete()` for those tables too.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.