Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78e9fc5

Browse files
author
shubhambaraiss
committed
Predicate locking in rum index
1 parent10e2ea6 commit78e9fc5

11 files changed

+1108
-25
lines changed

‎Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ endif
3535
wal-check: temp-install
3636
$(prove_check)
3737

38+
check: isolationcheck
39+
40+
submake-isolation:
41+
$(MAKE) -C$(top_builddir)/src/test/isolation all
42+
submake-rum:
43+
$(MAKE) -C$(top_builddir)/contrib/rum
44+
45+
3846
all: rum--1.1.sql
3947

4048
#9.6 requires 1.1 file but 10.0 could live with 1.0 + 1.0-1.1 files
@@ -48,3 +56,9 @@ install: installincludes
4856

4957
installincludes:
5058
$(INSTALL_DATA)$(addprefix$(srcdir)/,$(INCLUDES))'$(DESTDIR)$(includedir_server)/'
59+
60+
ISOLATIONCHECKS= predicate-rum predicate-rum-2
61+
isolationcheck: | submake-isolation submake-rum temp-install
62+
$(pg_isolation_regress_check)\
63+
--temp-config$(top_srcdir)/contrib/rum/logical.conf\
64+
$(ISOLATIONCHECKS)

‎expected/predicate-rum-2.out

Lines changed: 441 additions & 0 deletions
Large diffs are not rendered by default.

‎expected/predicate-rum.out

Lines changed: 461 additions & 0 deletions
Large diffs are not rendered by default.

‎logical.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
wal_level = logical
2+
max_replication_slots = 4

‎specs/predicate-rum-2.spec

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Test for page level predicate locking in rum
2+
#
3+
# Test to check reduced false positives
4+
#
5+
# Queries are written in such a way that an index scan(from one transaction) and an index insert(from another transaction) will try to access different parts(sub-tree) of the index.
6+
7+
setup
8+
{
9+
CREATEEXTENSIONrum;
10+
11+
CREATETABLErum_tbl (idserial,tsvtsvector);
12+
13+
CREATETABLEtext_table (id1serial,ttext[]);
14+
15+
SELECTSETSEED(0.5);
16+
17+
INSERTINTOtext_table(t)SELECTarray[chr(i)||chr(j)]FROMgenerate_series(65,90)i,
18+
generate_series(65,90)j ;
19+
20+
INSERTINTOrum_tbl(tsv)SELECTto_tsvector('simple',t[1] )FROMtext_table;
21+
22+
DO $$
23+
BEGIN
24+
FORjin1..10LOOP
25+
UPDATErum_tblSETtsv=tsv||q.t1FROM (SELECTid1,to_tsvector('simple',t[1] )
26+
ast1FROMtext_table)asqWHEREid= (random()*q.id1)::integer;
27+
ENDLOOP;
28+
END;
29+
$$;
30+
31+
CREATEINDEXrum_tbl_idxONrum_tblUSINGrum (tsvrum_tsvector_ops);
32+
}
33+
34+
teardown
35+
{
36+
DROPTABLEtext_table;
37+
DROPTABLErum_tbl;
38+
DROPEXTENSIONrum;
39+
}
40+
41+
session"s1"
42+
setup{
43+
BEGINISOLATIONLEVELSERIALIZABLE;
44+
setenable_seqscan=off;
45+
}
46+
step"rxy1"{SELECTid,tsvFROMrum_tblWHEREtsv @@'hx'; }
47+
step"wx1"{INSERTINTOrum_tbl(tsv)values('ab'); }
48+
step"c1"{COMMIT; }
49+
50+
session"s2"
51+
setup{
52+
BEGINISOLATIONLEVELSERIALIZABLE;
53+
setenable_seqscan=off;
54+
}
55+
56+
step"rxy2"{SELECTid,tsvFROMrum_tblWHEREtsv @@'qh'; }
57+
step"wy2"{INSERTINTOrum_tbl(tsv)values('xz'); }
58+
step"c2"{COMMIT; }
59+

‎specs/predicate-rum.spec

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Test for page level predicate locking in rum
2+
#
3+
# Test to verify serialization failures
4+
#
5+
# Queries are written in such a way that an index scan(from one transaction) and an index insert(from another transaction) will try to access the same part(sub-tree) of the index.
6+
7+
setup
8+
{
9+
CREATEEXTENSIONrum;
10+
11+
CREATETABLErum_tbl (idserial,tsvtsvector);
12+
13+
CREATETABLEtext_table (id1serial,ttext[]);
14+
15+
SELECTSETSEED(0.5);
16+
17+
INSERTINTOtext_table(t)SELECTarray[chr(i)||chr(j)]FROMgenerate_series(65,90)i,
18+
generate_series(65,90)j ;
19+
20+
INSERTINTOrum_tbl(tsv)SELECTto_tsvector('simple',t[1] )FROMtext_table;
21+
22+
DO $$
23+
BEGIN
24+
FORjin1..10LOOP
25+
UPDATErum_tblSETtsv=tsv||q.t1FROM (SELECTid1,to_tsvector('simple',t[1] )
26+
ast1FROMtext_table)asqWHEREid= (random()*q.id1)::integer;
27+
ENDLOOP;
28+
END;
29+
$$;
30+
31+
CREATEINDEXrum_tbl_idxONrum_tblUSINGrum (tsvrum_tsvector_ops);
32+
}
33+
34+
teardown
35+
{
36+
DROPTABLEtext_table;
37+
DROPTABLErum_tbl;
38+
DROPEXTENSIONrum;
39+
}
40+
41+
session"s1"
42+
setup{
43+
BEGINISOLATIONLEVELSERIALIZABLE;
44+
setenable_seqscan=off;
45+
}
46+
step"rxy1"{SELECTid,tsvFROMrum_tblWHEREtsv @@'hx'; }
47+
step"wx1"{INSERTINTOrum_tbl(tsv)values('qh'); }
48+
step"c1"{COMMIT; }
49+
50+
session"s2"
51+
setup{
52+
BEGINISOLATIONLEVELSERIALIZABLE;
53+
setenable_seqscan=off;
54+
}
55+
56+
step"rxy2"{SELECTid,tsvFROMrum_tblWHEREtsv @@'qh'; }
57+
step"wy2"{INSERTINTOrum_tbl(tsv)values('hx'); }
58+
step"c2"{COMMIT; }

‎src/rumbtree.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include"access/generic_xlog.h"
1717
#include"miscadmin.h"
18+
#include"storage/predicate.h"
1819

1920
#include"rum.h"
2021

@@ -485,6 +486,14 @@ rumInsertValue(Relation index, RumBtree btree, RumBtreeStack * stack,
485486
btree->fillRoot(btree,stack->buffer,lbuffer,rbuffer,
486487
page,lpage,rpage);
487488

489+
PredicateLockPageSplit(btree->index,
490+
BufferGetBlockNumber(stack->buffer),
491+
BufferGetBlockNumber(lbuffer));
492+
493+
PredicateLockPageSplit(btree->index,
494+
BufferGetBlockNumber(stack->buffer),
495+
BufferGetBlockNumber(rbuffer));
496+
488497
if (btree->rumstate->isBuild)
489498
{
490499
START_CRIT_SECTION();
@@ -548,6 +557,10 @@ rumInsertValue(Relation index, RumBtree btree, RumBtreeStack * stack,
548557
RumPageGetOpaque(rpage)->leftlink=BufferGetBlockNumber(stack->buffer);
549558
RumPageGetOpaque(newlpage)->rightlink=BufferGetBlockNumber(rbuffer);
550559

560+
PredicateLockPageSplit(btree->index,
561+
BufferGetBlockNumber(stack->buffer),
562+
BufferGetBlockNumber(rbuffer));
563+
551564
/*
552565
* it's safe because we don't have right-to-left walking
553566
* with locking bth pages except vacuum. But vacuum will

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp