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

Commite8efbf4

Browse files
committed
Move assertion about valid CSN from sender to receiver. It is okay when such tx will be filtered anyway
1 parentaddf523 commite8efbf4

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

‎multimaster.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,8 +1849,7 @@ csn_t MtmGetTransactionCSN(TransactionId xid)
18491849
csn_tcsn;
18501850
MtmLock(LW_SHARED);
18511851
ts= (MtmTransState*)hash_search(MtmXid2State,&xid,HASH_FIND,NULL);
1852-
Assert(ts!=NULL);
1853-
csn=ts->csn;
1852+
csn=ts ?ts->csn :INVALID_CSN;
18541853
MtmUnlock();
18551854
returncsn;
18561855
}

‎pglogical_apply.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,14 @@ process_remote_commit(StringInfo in)
735735
casePGLOGICAL_COMMIT_PREPARED:
736736
{
737737
Assert(!TransactionIdIsValid(MtmGetCurrentTransactionId()));
738-
csn=pq_getmsgint64(in);
738+
csn=pq_getmsgint64(in);
739+
/*
740+
* Since our recovery method allows undershoot of csn, we can receive
741+
* some already committed transactions. And in case of donor node reboot
742+
* xid<->csn mapping for them will be lost. However we must filter such
743+
* transactions in walreceiver before this code. --sk
744+
*/
745+
Assert(csn);
739746
strncpy(gid,pq_getmsgstring(in),sizeofgid);
740747
MTM_LOG2("PGLOGICAL_COMMIT_PREPARED commit: csn=%lld, gid=%s, lsn=%llx",csn,gid,end_lsn);
741748
MtmResetTransaction();

‎t/004_recovery.pl

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,54 @@
22
use warnings;
33
use Cluster;
44
use TestLib;
5-
use Test::Moretests=>2;
5+
use Test::Moretests=>3;
66

77
my$cluster = new Cluster(3);
88
$cluster->init();
99
$cluster->configure();
1010
$cluster->start();
1111
sleep(10);
1212

13-
$cluster->psql(0,'postgres',"create extension multimaster");
13+
$cluster->psql(0,'postgres',"create extension multimaster;
14+
create table if not exists t(k int primary key, v int);");
15+
16+
$cluster->psql(0,'postgres',"insert into t values(1, 10);");
17+
$cluster->psql(1,'postgres',"insert into t values(2, 20);");
18+
$cluster->psql(2,'postgres',"insert into t values(3, 30);");
19+
sleep(2);
20+
21+
22+
my$sum0;
23+
my$sum1;
24+
my$sum2;
25+
26+
########################################################
27+
# Check start after all nodes were disconnected
28+
########################################################
29+
30+
$cluster->{nodes}->[1]->stop('fast');
31+
$cluster->{nodes}->[2]->stop('fast');
32+
33+
sleep(5);
34+
$cluster->{nodes}->[1]->start;
35+
# try to start node3 right here?
36+
sleep(5);
37+
$cluster->{nodes}->[2]->start;
38+
sleep(5);
39+
40+
$cluster->psql(0,'postgres',"select sum(v) from t;",stdout=> \$sum0);
41+
$cluster->psql(1,'postgres',"select sum(v) from t;",stdout=> \$sum1);
42+
$cluster->psql(1,'postgres',"select sum(v) from t;",stdout=> \$sum2);
43+
is( (($sum0 == 60)and ($sum1 ==$sum0)and ($sum2 ==$sum0)) , 1,"Check that nodes are working and sync");
44+
45+
########################################################
46+
# Check recovery during some load
47+
########################################################
48+
1449
$cluster->pgbench(0, ('-i',-s=>'10') );
50+
$cluster->pgbench(0, ('-N',-T=>'1') );
51+
$cluster->pgbench(1, ('-N',-T=>'1') );
52+
$cluster->pgbench(2, ('-N',-T=>'1') );
1553

1654
# kill node while neighbour is under load
1755
my$pgb_handle =$cluster->pgbench_async(1, ('-N',-T=>'10') );
@@ -29,9 +67,6 @@
2967
sleep(10);
3068

3169
# check data identity
32-
my$sum0;
33-
my$sum1;
34-
my$sum2;
3570
$cluster->psql(0,'postgres',"select sum(abalance) from pgbench_accounts;",stdout=> \$sum0);
3671
$cluster->psql(1,'postgres',"select sum(abalance) from pgbench_accounts;",stdout=> \$sum1);
3772
$cluster->psql(2,'postgres',"select sum(abalance) from pgbench_accounts;",stdout=> \$sum2);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp