CUBRID에서 디폴트 설정된 격리 수준(3)으로서 동시성이 높다. 행에 대해서는 더티 읽기, 반복 불가능한 읽기, 유령 읽기가 발생할 수 있지만, 테이블에 대해서는 반복 가능한 읽기를 보장한다. 즉, 트랜잭션 T1이 하나의 객체를 갱신하는 동안 다른 트랜잭션 T2에서 객체를 읽을 수 있다는 의미이다.
다음과 같은 규칙이 적용된다.
이 격리 수준은 배타 및 갱신 잠금에 대해서는 2단계 잠금을 따른다. 하지만 행에 대한 공유 잠금은 행이 조회된 직후 바로 해제된다. 단 테이블에 대한 의도 잠금은 반복 가능한 읽기를 보장하기 위하여 트랜잭션이 종료될 때 해제된다.
다음은 동시에 수행되는 트랜잭션의 격리 수준이 REPEATABLE READ CLASS with READ UNCOMMITTED INSTANCES인 경우 한 트랜잭션에서 커밋하지 않은 더티 데이터를 다른 트랜잭션에서 읽을 수 있는 한편, 테이블 스키마 갱신에 대해서는 반복 가능한 읽기를 보장함을 보여주는 예제이다.
session 1 |
session 2 |
---|---|
;autocommit off AUTOCOMMIT IS OFF
SET TRANSACTION ISOLATION LEVEL 3;
Isolation level set to: REPEATABLE READ SCHEMA, READ UNCOMMITTED INSTANCES. |
;autocommit off AUTOCOMMIT IS OFF
SET TRANSACTION ISOLATION LEVEL 3;
Isolation level set to: REPEATABLE READ SCHEMA, READ UNCOMMITTED INSTANCES. |
--creating a table
CREATE TABLE isol3_tbl(host_year integer, nation_code char(3)); CREATE UNIQUE INDEX on isol3_tbl(nation_code, host_year); INSERT INTO isol3_tbl VALUES (2008, 'AUS');
COMMIT; |
|
|
--selecting records from the table SELECT * FROM isol3_tbl; host_year nation_code =================================== 2008 'AUS' |
INSERT INTO isol3_tbl VALUES (2004, 'AUS');
INSERT INTO isol3_tbl VALUES (2000, 'NED');
/* able to insert new rows even if tran 2 uncommitted */ |
|
|
SELECT * FROM isol3_tbl; host_year nation_code =================================== 2008 'AUS' 2004 'AUS' 2000 'NED'
/* dirty read may occur so that tran_2 can select new rows uncommitted by tran_1 */ |
ROLLBACK; |
|
|
SELECT * FROM isol3_tbl; host_year nation_code =================================== 2008 'AUS'
/* unrepeatable read may occur so that selected results are different */ |
INSERT INTO isol3_tbl VALUES (1994, 'FRA');
DELETE FROM isol3_tbl WHERE nation_code = 'AUS' and host_year=2008;
/* able to delete rows even if tran 2 uncommitted */ |
|
|
SELECT * FROM isol3_tbl; host_year nation_code =================================== 1994 'FRA' |
ALTER TABLE isol3_tbl ADD COLUMN gold INT;
/* unable to alter the table schema until tran 2 committed */ |
|
|
/* repeatable read is ensured while tran_1 is altering table schema */
SELECT * FROM isol3_tbl; host_year nation_code =================================== 1994 'FRA' |
|
COMMIT; |
|
SELECT * FROM isol3_tbl; |
COMMIT; |
host_year nation_code gold =================================== 1994 'FRA' NULL |
참고 CUBRID는 다양한 상황에서 워크 스페이스에 있는 더티 데이터를 데이터베이스로 내려쓰기(flush)한다. 이에 관한 설명은 CUBRID에서 더티 인스턴스(dirty instance)를 다루는 방법을 참고한다.