Skip to content

Commit 6e98228

Browse files
committed
Call SetPreparedTransactionState inside transaction
1 parent af34ad7 commit 6e98228

File tree

6 files changed

+52
-21
lines changed

6 files changed

+52
-21
lines changed

contrib/mmts/arbiter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,10 @@ static void MtmReceiver(Datum arg)
10651065
Assert(replorigin_session_origin == InvalidRepOriginId);
10661066
MTM_LOG2("SetPreparedTransactionState for %s", ts->gid);
10671067
MtmUnlock();
1068+
MtmResetTransaction();
1069+
StartTransactionCommand();
10681070
SetPreparedTransactionState(ts->gid, MULTIMASTER_PRECOMMITTED);
1071+
CommitTransactionCommand();
10691072
MtmLock(LW_EXCLUSIVE);
10701073
} else {
10711074
ts->status = TRANSACTION_STATUS_UNKNOWN;

contrib/mmts/multimaster.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,14 @@ void MtmPrecommitTransaction(char const* gid)
956956
}
957957
MtmUnlock();
958958
Assert(replorigin_session_origin != InvalidRepOriginId);
959-
SetPreparedTransactionState(ts->gid, MULTIMASTER_PRECOMMITTED);
959+
if (!IsTransactionState()) {
960+
MtmResetTransaction();
961+
StartTransactionCommand();
962+
SetPreparedTransactionState(ts->gid, MULTIMASTER_PRECOMMITTED);
963+
CommitTransactionCommand();
964+
} else {
965+
SetPreparedTransactionState(ts->gid, MULTIMASTER_PRECOMMITTED);
966+
}
960967
} else {
961968
elog(WARNING, "MtmPrecommitTransaction: transaction '%s' is already in %s state", gid, MtmTxnStatusMnem[ts->status]);
962969
MtmUnlock();

contrib/mmts/tests2/support/docker-regress.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ SQL
1717

1818
STATUS=$?
1919

20-
if [ -f "regression.diffs" ]
21-
then
22-
cat regression.diffs
23-
fi
20+
#if [ -f "regression.diffs" ]
21+
#then
22+
# cat regression.diffs
23+
#fi
2424

2525
exit $STATUS

contrib/mmts/tests2/test_recovery.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
from lib.bank_client import MtmClient
1313
from lib.failure_injector import *
1414

15+
TEST_WARMING_TIME = 5
1516
TEST_DURATION = 10
16-
TEST_RECOVERY_TIME = 20
17+
TEST_RECOVERY_TIME = 30
18+
TEST_SETUP_TIME = 20
1719

1820
class TestHelper(object):
1921

@@ -39,6 +41,11 @@ def assertNoCommits(self, aggs):
3941
raise AssertionError('There are commits during aggregation interval')
4042

4143
def performFailure(self, failure):
44+
45+
time.sleep(TEST_WARMING_TIME)
46+
47+
print('Simulate failure at ',datetime.datetime.utcnow())
48+
4249
failure.start()
4350

4451
self.client.clean_aggregates()
@@ -47,6 +54,8 @@ def performFailure(self, failure):
4754

4855
failure.stop()
4956

57+
print('Eliminate failure at ',datetime.datetime.utcnow())
58+
5059
self.client.clean_aggregates()
5160
time.sleep(TEST_RECOVERY_TIME)
5261
aggs = self.client.get_aggregates()
@@ -60,11 +69,12 @@ class RecoveryTest(unittest.TestCase, TestHelper):
6069
def setUpClass(self):
6170
subprocess.check_call(['docker-compose','up',
6271
'--force-recreate',
72+
'--build',
6373
'-d'])
6474

6575
# XXX: add normal wait here
66-
time.sleep(20)
67-
print('started')
76+
time.sleep(TEST_SETUP_TIME)
77+
6878
self.client = MtmClient([
6979
"dbname=regression user=postgres host=127.0.0.1 port=15432",
7080
"dbname=regression user=postgres host=127.0.0.1 port=15433",
@@ -81,6 +91,11 @@ def tearDownClass(self):
8191

8292
def setUp(self):
8393
warnings.simplefilter("ignore", ResourceWarning)
94+
time.sleep(20)
95+
print('Start new test at ',datetime.datetime.utcnow())
96+
97+
def tearDown(self):
98+
print('Finish test at ',datetime.datetime.utcnow())
8499

85100
def test_normal_operations(self):
86101
print('### test_normal_operations ###')
@@ -122,8 +137,6 @@ def test_edge_partition(self):
122137
def test_node_restart(self):
123138
print('### test_node_restart ###')
124139

125-
time.sleep(3)
126-
127140
aggs_failure, aggs = self.performFailure(RestartNode('node3'))
128141

129142
self.assertCommits(aggs_failure[:2])

contrib/mmts/tests2/test_recovery_up.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,27 @@ def performFailure(self, failure):
6464

6565
class RecoveryTest(unittest.TestCase, TestHelper):
6666

67-
def setUp(self):
68-
time.sleep(20)
69-
print('Start new test at ',datetime.datetime.utcnow())
70-
warnings.simplefilter("ignore", ResourceWarning)
67+
@classmethod
68+
def setUpClass(self):
7169
self.client = MtmClient([
7270
"dbname=regression user=postgres host=127.0.0.1 port=15432",
7371
"dbname=regression user=postgres host=127.0.0.1 port=15433",
7472
"dbname=regression user=postgres host=127.0.0.1 port=15434"
7573
], n_accounts=1000)
7674
self.client.bgrun()
7775

78-
def tearDown(self):
79-
print('Finish test at ',datetime.datetime.utcnow())
76+
@classmethod
77+
def tearDownClass(self):
78+
print('tearDown')
8079
self.client.stop()
8180

81+
def setUp(self):
82+
warnings.simplefilter("ignore", ResourceWarning)
83+
time.sleep(20)
84+
print('Start new test at ',datetime.datetime.utcnow())
85+
86+
def tearDown(self):
87+
print('Finish test at ',datetime.datetime.utcnow())
8288

8389
def test_normal_operations(self):
8490
print('### test_normal_operations ###')

contrib/mmts/tests2/test_regression.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ class RecoveryTest(unittest.TestCase):
66

77
@classmethod
88
def setUpClass(self):
9-
subprocess.check_call(['docker-compose','up',
10-
'--force-recreate',
11-
'--build',
12-
'-d'])
9+
print('setUp')
10+
# subprocess.check_call(['docker-compose','up',
11+
# '--force-recreate',
12+
# '--build',
13+
# '-d'])
1314

1415
@classmethod
1516
def tearDownClass(self):
16-
subprocess.check_call(['docker-compose','down'])
17+
print('tearDown')
18+
# subprocess.check_call(['docker-compose','down'])
1719

1820
def test_regression(self):
1921
# XXX: make smth clever here

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