Failure in multi-row INSERTs sets citus.multi_shard_modify_mode to sequential
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
Citus manually marks `multi_shard_modify_mode` to sequential while executing multi-row INSERTs (https://github.com/citusdata/citus/blob/959629d3f308f5d158ad4f7a4497d45aec61f55c/src/backend/distributed/executor/adaptive_executor.c#L2184-L2188).
And, on failures, it is not cleared until the user re-connects. Steps to reproduce
```SQL
cusred034c9409-vl2:citus onderkalaci$ psql postgres
psql (13beta3)
Type "help" for help.
postgres=# show citus.multi_shard_modify_mode ;
citus.multi_shard_modify_mode
-------------------------------
parallel
(1 row)
postgres=# BEGIN;
BEGIN
insert into users_table(user_id) VALUES (1),(2),(3) RETURNING user_id / 0;
ERROR: division by zero
CONTEXT: while executing command on localhost:9701
postgres=!# ROLLBACK;
ROLLBACK
show citus.multi_shard_modify_mode ;
citus.multi_shard_modify_mode
-------------------------------
sequential
(1 row)
postgres=#
```
Contributor guide
Research direction
Start with the multi-row INSERT handling in src/backend/distributed/executor/adaptive_executor.c at the linked lines, then reproduce the failure with the SQL transaction shown in the issue. Trace how citus.multi_shard_modify_mode is changed and cleaned up after the error; done means it returns to parallel after rollback without reconnecting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, postgresql, sql
- Domain
- databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100