Skip to content

Commit 1e1e6d5

Browse files
committed
[#29124] YSQL: Enable Read Committed isolation by default in release builds
Summary: Enable support for Read Committed isolation by default in release builds and turn it off in debug builds (so that our unit tests are run against the previous mode too). Before this diff, the gflag was set the other way around. Support for RC is controlled by the `yb_enable_read_committed_isolation` Tserver gflag. When the support is disabled, any syntactic usage of RC (e.g., using `BEGIN;` or `BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;`) in Postgresql will map to Snapshot Isolation. Jira: DB-18889 Test Plan: Jenkins Reviewers: smishra, patnaik.balivada Reviewed By: patnaik.balivada Subscribers: jason, svc_phabricator, yql Differential Revision: https://phorge.dev.yugabyte.com/D47487
1 parent 32851f6 commit 1e1e6d5

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

src/postgres/src/backend/utils/misc/pg_yb_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,9 @@ YBIsReadCommittedSupported()
647647
{
648648

649649
#ifdef NDEBUG
650-
cached_value = YBCIsEnvVarTrueWithDefault("FLAGS_yb_enable_read_committed_isolation", false);
651-
#else
652650
cached_value = YBCIsEnvVarTrueWithDefault("FLAGS_yb_enable_read_committed_isolation", true);
651+
#else
652+
cached_value = YBCIsEnvVarTrueWithDefault("FLAGS_yb_enable_read_committed_isolation", false);
653653
#endif
654654
}
655655
return cached_value;

src/postgres/src/test/regress/expected/yb.orig.lock_status.out

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ SELECT true::bool FROM yb_lock_status('yb_lock_tests'::regclass, '10000000-2000-
144144
-- READ COMMITTED
145145
-- Basic insert
146146
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
147-
WARNING: read committed isolation is disabled
148-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
149147
INSERT INTO yb_lock_tests VALUES (1, 1, 1, 'one', 1, 1);
150148
INSERT INTO yb_lock_tests VALUES (2, 2, 2, 'two', 2, 2);
151149
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
@@ -177,8 +175,6 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
177175
COMMIT;
178176
-- Basic Column Update
179177
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
180-
WARNING: read committed isolation is disabled
181-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
182178
UPDATE yb_lock_tests SET v1 = 2 WHERE k1 = 1 AND k2 = 1;
183179
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
184180
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -199,8 +195,6 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
199195
ABORT;
200196
-- Basic primary key update
201197
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
202-
WARNING: read committed isolation is disabled
203-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
204198
UPDATE yb_lock_tests SET r1 = 2 WHERE k1 = 1 AND k2 = 1;
205199
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
206200
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -226,8 +220,6 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
226220

227221
ABORT;
228222
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
229-
WARNING: read committed isolation is disabled
230-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
231223
UPDATE yb_lock_tests SET k2 = 2 WHERE k1 = 1 AND k2 = 1;
232224
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
233225
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -255,8 +247,6 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
255247
ABORT;
256248
-- SELECT FOR SHARE
257249
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
258-
WARNING: read committed isolation is disabled
259-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
260250
SELECT * FROM yb_lock_tests FOR SHARE;
261251
k1 | k2 | r1 | r2 | v1 | v2
262252
----+----+----+-----+----+----
@@ -285,8 +275,6 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
285275
COMMIT;
286276
-- SELECT FOR KEY SHARE
287277
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
288-
WARNING: read committed isolation is disabled
289-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
290278
SELECT * FROM yb_lock_tests FOR KEY SHARE;
291279
k1 | k2 | r1 | r2 | v1 | v2
292280
----+----+----+-----+----+----
@@ -315,8 +303,6 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
315303
COMMIT;
316304
-- SELECT FOR UPDATE
317305
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
318-
WARNING: read committed isolation is disabled
319-
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
320306
SELECT * FROM yb_lock_tests FOR UPDATE;
321307
k1 | k2 | r1 | r2 | v1 | v2
322308
----+----+----+-----+----+----

src/postgres/src/test/regress/expected/yb.orig.lock_status_1.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ SELECT true::bool FROM yb_lock_status('yb_lock_tests'::regclass, '10000000-2000-
144144
-- READ COMMITTED
145145
-- Basic insert
146146
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
147+
WARNING: read committed isolation is disabled
148+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
147149
INSERT INTO yb_lock_tests VALUES (1, 1, 1, 'one', 1, 1);
148150
INSERT INTO yb_lock_tests VALUES (2, 2, 2, 'two', 2, 2);
149151
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
@@ -185,6 +187,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
185187
COMMIT;
186188
-- Basic Column Update
187189
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
190+
WARNING: read committed isolation is disabled
191+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
188192
UPDATE yb_lock_tests SET v1 = 2 WHERE k1 = 1 AND k2 = 1;
189193
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
190194
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -205,6 +209,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
205209
ABORT;
206210
-- Basic primary key update
207211
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
212+
WARNING: read committed isolation is disabled
213+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
208214
UPDATE yb_lock_tests SET r1 = 2 WHERE k1 = 1 AND k2 = 1;
209215
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
210216
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -233,6 +239,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
233239

234240
ABORT;
235241
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
242+
WARNING: read committed isolation is disabled
243+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
236244
UPDATE yb_lock_tests SET k2 = 2 WHERE k1 = 1 AND k2 = 1;
237245
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
238246
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -265,6 +273,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
265273
ABORT;
266274
-- SELECT FOR SHARE
267275
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
276+
WARNING: read committed isolation is disabled
277+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
268278
SELECT * FROM yb_lock_tests FOR SHARE;
269279
k1 | k2 | r1 | r2 | v1 | v2
270280
----+----+----+-----+----+----
@@ -293,6 +303,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
293303
COMMIT;
294304
-- SELECT FOR KEY SHARE
295305
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
306+
WARNING: read committed isolation is disabled
307+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
296308
SELECT * FROM yb_lock_tests FOR KEY SHARE;
297309
k1 | k2 | r1 | r2 | v1 | v2
298310
----+----+----+-----+----+----
@@ -321,6 +333,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
321333
COMMIT;
322334
-- SELECT FOR UPDATE
323335
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
336+
WARNING: read committed isolation is disabled
337+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
324338
SELECT * FROM yb_lock_tests FOR UPDATE;
325339
k1 | k2 | r1 | r2 | v1 | v2
326340
----+----+----+-----+----+----

src/postgres/src/test/regress/expected/yb.orig.lock_status_2.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ SELECT true::bool FROM yb_lock_status('yb_lock_tests'::regclass, '10000000-2000-
144144
-- READ COMMITTED
145145
-- Basic insert
146146
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
147+
WARNING: read committed isolation is disabled
148+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
147149
INSERT INTO yb_lock_tests VALUES (1, 1, 1, 'one', 1, 1);
148150
INSERT INTO yb_lock_tests VALUES (2, 2, 2, 'two', 2, 2);
149151
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
@@ -185,6 +187,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
185187
COMMIT;
186188
-- Basic Column Update
187189
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
190+
WARNING: read committed isolation is disabled
191+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
188192
UPDATE yb_lock_tests SET v1 = 2 WHERE k1 = 1 AND k2 = 1;
189193
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
190194
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -205,6 +209,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
205209
ABORT;
206210
-- Basic primary key update
207211
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
212+
WARNING: read committed isolation is disabled
213+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
208214
UPDATE yb_lock_tests SET r1 = 2 WHERE k1 = 1 AND k2 = 1;
209215
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
210216
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -233,6 +239,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
233239

234240
ABORT;
235241
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
242+
WARNING: read committed isolation is disabled
243+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
236244
UPDATE yb_lock_tests SET k2 = 2 WHERE k1 = 1 AND k2 = 1;
237245
SELECT * FROM validate_and_return_lock_status('yb_lock_tests'::regclass, null);
238246
locktype | relation | mode | granted | fastpath | valid_waitstart | valid_waitend | has_node | has_tablet_id | has_transaction_id | valid_subtransaction_id | has_status_tablet_id | is_explicit | hash_cols | range_cols | attnum | column_id | multiple_rows_locked | num_blocking
@@ -265,6 +273,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
265273
ABORT;
266274
-- SELECT FOR SHARE
267275
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
276+
WARNING: read committed isolation is disabled
277+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
268278
SELECT * FROM yb_lock_tests FOR SHARE;
269279
k1 | k2 | r1 | r2 | v1 | v2
270280
----+----+----+-----+----+----
@@ -293,6 +303,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
293303
COMMIT;
294304
-- SELECT FOR KEY SHARE
295305
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
306+
WARNING: read committed isolation is disabled
307+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
296308
SELECT * FROM yb_lock_tests FOR KEY SHARE;
297309
k1 | k2 | r1 | r2 | v1 | v2
298310
----+----+----+-----+----+----
@@ -321,6 +333,8 @@ SELECT * FROM validate_and_return_lock_status('yb_lock_tests_k1_k2'::regclass, n
321333
COMMIT;
322334
-- SELECT FOR UPDATE
323335
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
336+
WARNING: read committed isolation is disabled
337+
DETAIL: Set yb_enable_read_committed_isolation to enable. When disabled, read committed falls back to using repeatable read isolation.
324338
SELECT * FROM yb_lock_tests FOR UPDATE;
325339
k1 | k2 | r1 | r2 | v1 | v2
326340
----+----+----+-----+----+----

src/yb/yql/pggate/pggate_flags.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ DEFINE_NON_RUNTIME_uint32(
157157
"for regex functions. ");
158158

159159
#ifdef NDEBUG
160-
constexpr bool kEnableReadCommitted = false;
161-
#else
162160
constexpr bool kEnableReadCommitted = true;
161+
#else
162+
constexpr bool kEnableReadCommitted = false;
163163
#endif
164164
DEFINE_NON_RUNTIME_bool(
165165
yb_enable_read_committed_isolation, kEnableReadCommitted,

0 commit comments

Comments
 (0)