假设 PostgreSQL 10.3 和已提交读:在分区表被另一个进程修改的情况下,对分区表的查询是否会引入竞争条件?
例如,给定这个模式:
CREATE TABLE foo (
id VARCHAR,
state VARCHAR
) PARTITION BY LIST(state);
CREATE TABLE foo_pending PARTITION OF foo FOR VALUES IN ('pending');
CREATE TABLE foo_ready PARTITION OF foo FOR VALUES IN ('ready');
假设我有一个查询的进程:
SELECT * FROM foo WHERE id = 'something';
另一个过程:
BEGIN TRANSACTION;
DELETE FROM foo_ready WHERE id = 'something';
INSERT INTO foo_pending VALUES ('something', 'pending');
COMMIT;
第一个进程是否有可能在分区中找不到匹配的行foo_pending
(因为它在另一个进程提交之前获取)并且也没有匹配的行foo_ready
(因为它在另一个进程提交之后获取)?
Do I need SERIALIZABLE
(or REPEATABLE READ
) to overcome this issue?