Skip to content

Commit 91e71d2

Browse files
committed
Optimize snapshot size
1 parent 1db67dc commit 91e71d2

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

contrib/multimaster/dtmd/src/main.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,19 @@ static void gen_snapshot(Snapshot *s) {
196196
int n = 0;
197197
s->times_sent = 0;
198198
for (t = (Transaction*)active_transactions.prev; t != (Transaction*)&active_transactions; t = (Transaction*)t->elem.prev) {
199-
/*
200-
if (t->xid < s->xmin) {
201-
s->xmin = t->xid;
202-
}
203-
if (t->xid >= s->xmax) {
204-
s->xmax = t->xid + 1;
205-
}
206-
*/
207199
s->active[n++] = t->xid;
208200
}
209-
s->nactive = n;
201+
while (n > 1 && s->active[n-2]+1 == s->active[n-1]) {
202+
n -= 1;
203+
}
210204
if (n > 0) {
211205
s->xmin = s->active[0];
212-
s->xmax = s->active[n-1];
206+
s->xmax = s->active[--n];
213207
assert(s->xmin <= s->xmax);
214-
// snapshot_sort(s);
215208
} else {
216209
s->xmin = s->xmax = 0;
217210
}
211+
s->nactive = n;
218212
}
219213

220214
static void onreserve(client_t client, int argc, xid_t *argv) {

contrib/multimaster/tests/postgresql.conf.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,9 @@
547547
# These settings are initialized by initdb, but they can be changed.
548548
lc_messages = 'en_US.UTF-8' # locale for system error message
549549
# strings
550-
lc_monetary = 'ru_RU.UTF-8' # locale for monetary formatting
551-
lc_numeric = 'ru_RU.UTF-8' # locale for number formatting
552-
lc_time = 'ru_RU.UTF-8' # locale for time formatting
550+
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
551+
lc_numeric = 'en_US.UTF-8' # locale for number formatting
552+
lc_time = 'en_US.UTF-8' # locale for time formatting
553553

554554
# default configuration for text search
555555
default_text_search_config = 'pg_catalog.english'
@@ -624,5 +624,5 @@
624624

625625
# Add settings for extensions here
626626

627-
multimaster.queue_size = 1073741824
628-
#multimaster.workers = 16
627+
multimaster.workers=8
628+
multimaster.queue_size=1073741824
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
n_nodes=3
2-
export PATH=/home/knizhnik/postgrespro/cluster_install/bin/:$PATH
2+
export PATH=/home/knizhnik/postgres_cluster/dist/bin/:$PATH
33
ulimit -c unlimited
44
pkill -9 postgres
55
pkill -9 dtmd
6-
sleep 2
7-
rm -fr node? *.log dtm/*
6+
rm -fr node? *.log dtm
7+
mkdir dtm
88
conn_str=""
99
sep=""
1010
for ((i=1;i<=n_nodes;i++))
1111
do
1212
port=$((5431+i))
13-
conn_str="$conn_str${sep}replication=database dbname=postgres host=127.0.0.1 user=knizhnik port=$port sslmode=disable"
13+
conn_str="$conn_str${sep}dbname=postgres host=127.0.0.1 user=knizhnik port=$port sslmode=disable"
1414
sep=","
1515
initdb node$i
1616
done
1717

1818
echo Start DTM
19-
~/postgrespro/contrib/multimaster/dtmd/bin/dtmd -d dtm 2> dtm.log &
19+
~/postgres_cluster/contrib/multimaster/dtmd/bin/dtmd -d dtm 2> dtm.log &
2020
sleep 2
2121

2222
echo Start nodes
@@ -32,10 +32,6 @@ done
3232

3333
sleep 5
3434
echo Initialize database schema
35-
for ((i=1;i<=n_nodes;i++))
36-
do
37-
port=$((5431+i))
38-
psql -p $port postgres -U knizhnik -f init.sql
39-
done
35+
psql postgres -U knizhnik -f init.sql
4036

4137
echo Done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy