cockroachdb / cockroachdb/cockroach

sql: support DDL in read committed transactions

Open
#114,778 7 comments 1 reaction 0 assignees View on GitHub
A-read-committed A-schema-changes A-schema-transactional C-enhancement docs-done docs-known-limitation T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We currently do not allow DDL statements like CREATE TABLE, CREATE SCHEMA, CREATE INDEX, etc. within explicit read committed transactions when `autocommit_before_ddl` is off. Postgres allows these statements within read committed transactions.

A demonstration is something like:

```sql
SET autocommit_before_ddl = off;
SET CLUSTER SETTING sql.txn.read_committed_isolation.enabled = true;
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT 1;
CREATE TABLE a (a INT PRIMARY KEY);
ROLLBACK;
```

In CRDB this fails with `explicit transaction involving a schema change needs to be SERIALIZABLE`.

Jira issue: CRDB-33677

Epic CRDB-60942

Contributor guide

Open the contributing guide

Research direction

Start by running the SQL reproduction from the issue with autocommit_before_ddl disabled and READ COMMITTED enabled. Trace where CockroachDB rejects schema changes in this transaction mode, then verify that CREATE TABLE and the other listed DDL statements are accepted and that the demonstrated transaction can roll back as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.