Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0428d56

Browse files
committed
Merge branch 'master' into rum_arrays_v1.2
2 parents 9cc6606 + c5be71b commit 0428d56

13 files changed

+1116
-961
lines changed

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,16 @@ install: installincludes
5151

5252
installincludes:
5353
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(INCLUDES)) '$(DESTDIR)$(includedir_server)/'
54+
55+
ISOLATIONCHECKS= predicate-rum predicate-rum-2
56+
57+
submake-isolation:
58+
$(MAKE) -C $(top_builddir)/src/test/isolation all
59+
60+
submake-rum:
61+
$(MAKE) -C $(top_builddir)/contrib/rum
62+
63+
isolationcheck: | submake-isolation submake-rum temp-install
64+
$(pg_isolation_regress_check) \
65+
--temp-config $(top_srcdir)/contrib/rum/logical.conf \
66+
$(ISOLATIONCHECKS)

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,21 @@ SELECT t, a <=> to_tsquery('english', 'beautiful | place') AS rank
106106
FROM test_rum
107107
WHERE a @@ to_tsquery('english', 'beautiful | place')
108108
ORDER BY a <=> to_tsquery('english', 'beautiful | place');
109-
t | rank
110-
---------------------------------+-----------
111-
The situation is most beautiful | 0.0303964
112-
It is a beautiful | 0.0303964
113-
It looks like a beautiful place | 0.0607927
109+
t | rank
110+
---------------------------------+---------
111+
It looks like a beautiful place | 8.22467
112+
The situation is most beautiful | 16.4493
113+
It is a beautiful | 16.4493
114114
(3 rows)
115115

116116
SELECT t, a <=> to_tsquery('english', 'place | situation') AS rank
117117
FROM test_rum
118118
WHERE a @@ to_tsquery('english', 'place | situation')
119119
ORDER BY a <=> to_tsquery('english', 'place | situation');
120-
t | rank
121-
---------------------------------+-----------
122-
The situation is most beautiful | 0.0303964
123-
It looks like a beautiful place | 0.0303964
120+
t | rank
121+
---------------------------------+---------
122+
The situation is most beautiful | 16.4493
123+
It looks like a beautiful place | 16.4493
124124
(2 rows)
125125
```
126126

expected/predicate-rum-2.out

+441
Large diffs are not rendered by default.

expected/predicate-rum.out

+461
Large diffs are not rendered by default.

logical.conf

+2
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

+59
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+
CREATE EXTENSION rum;
10+
11+
CREATE TABLE rum_tbl (id serial, tsv tsvector);
12+
13+
CREATE TABLE text_table (id1 serial, t text[]);
14+
15+
SELECT SETSEED(0.5);
16+
17+
INSERT INTO text_table(t) SELECT array[chr(i) || chr(j)] FROM generate_series(65,90) i,
18+
generate_series(65,90) j ;
19+
20+
INSERT INTO rum_tbl(tsv) SELECT to_tsvector('simple', t[1] ) FROM text_table;
21+
22+
DO $$
23+
BEGIN
24+
FOR j in 1..10 LOOP
25+
UPDATE rum_tbl SET tsv = tsv || q.t1 FROM (SELECT id1,to_tsvector('simple', t[1] )
26+
as t1 FROM text_table) as q WHERE id = (random()*q.id1)::integer;
27+
END LOOP;
28+
END;
29+
$$;
30+
31+
CREATE INDEX rum_tbl_idx ON rum_tbl USING rum (tsv rum_tsvector_ops);
32+
}
33+
34+
teardown
35+
{
36+
DROP TABLE text_table;
37+
DROP TABLE rum_tbl;
38+
DROP EXTENSION rum;
39+
}
40+
41+
session "s1"
42+
setup {
43+
BEGIN ISOLATION LEVEL SERIALIZABLE;
44+
set enable_seqscan=off;
45+
}
46+
step "rxy1" { SELECT id, tsv FROM rum_tbl WHERE tsv @@ 'hx'; }
47+
step "wx1" { INSERT INTO rum_tbl(tsv) values('ab'); }
48+
step "c1" { COMMIT; }
49+
50+
session "s2"
51+
setup {
52+
BEGIN ISOLATION LEVEL SERIALIZABLE;
53+
set enable_seqscan=off;
54+
}
55+
56+
step "rxy2" { SELECT id, tsv FROM rum_tbl WHERE tsv @@ 'qh'; }
57+
step "wy2" { INSERT INTO rum_tbl(tsv) values('xz'); }
58+
step "c2" { COMMIT; }
59+

specs/predicate-rum.spec

+58
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+
CREATE EXTENSION rum;
10+
11+
CREATE TABLE rum_tbl (id serial, tsv tsvector);
12+
13+
CREATE TABLE text_table (id1 serial, t text[]);
14+
15+
SELECT SETSEED(0.5);
16+
17+
INSERT INTO text_table(t) SELECT array[chr(i) || chr(j)] FROM generate_series(65,90) i,
18+
generate_series(65,90) j ;
19+
20+
INSERT INTO rum_tbl(tsv) SELECT to_tsvector('simple', t[1] ) FROM text_table;
21+
22+
DO $$
23+
BEGIN
24+
FOR j in 1..10 LOOP
25+
UPDATE rum_tbl SET tsv = tsv || q.t1 FROM (SELECT id1,to_tsvector('simple', t[1] )
26+
as t1 FROM text_table) as q WHERE id = (random()*q.id1)::integer;
27+
END LOOP;
28+
END;
29+
$$;
30+
31+
CREATE INDEX rum_tbl_idx ON rum_tbl USING rum (tsv rum_tsvector_ops);
32+
}
33+
34+
teardown
35+
{
36+
DROP TABLE text_table;
37+
DROP TABLE rum_tbl;
38+
DROP EXTENSION rum;
39+
}
40+
41+
session "s1"
42+
setup {
43+
BEGIN ISOLATION LEVEL SERIALIZABLE;
44+
set enable_seqscan=off;
45+
}
46+
step "rxy1" { SELECT id, tsv FROM rum_tbl WHERE tsv @@ 'hx'; }
47+
step "wx1" { INSERT INTO rum_tbl(tsv) values('qh'); }
48+
step "c1" { COMMIT; }
49+
50+
session "s2"
51+
setup {
52+
BEGIN ISOLATION LEVEL SERIALIZABLE;
53+
set enable_seqscan=off;
54+
}
55+
56+
step "rxy2" { SELECT id, tsv FROM rum_tbl WHERE tsv @@ 'qh'; }
57+
step "wy2" { INSERT INTO rum_tbl(tsv) values('hx'); }
58+
step "c2" { COMMIT; }

src/rumbtree.c

+13
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)