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

Commit15456e4

Browse files
knizhnikkelvich
authored andcommitted
Call SetPreparedTransactionState inside transaction
1 parent1b880e4 commit15456e4

File tree

6 files changed

+52
-21
lines changed

6 files changed

+52
-21
lines changed

‎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;

‎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();

‎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

‎tests2/test_recovery.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
fromlib.bank_clientimportMtmClient
1313
fromlib.failure_injectorimport*
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
classTestHelper(object):
1921

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

4143
defperformFailure(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
defsetUpClass(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
defsetUp(self):
8393
warnings.simplefilter("ignore",ResourceWarning)
94+
time.sleep(20)
95+
print('Start new test at ',datetime.datetime.utcnow())
96+
97+
deftearDown(self):
98+
print('Finish test at ',datetime.datetime.utcnow())
8499

85100
deftest_normal_operations(self):
86101
print('### test_normal_operations ###')
@@ -122,8 +137,6 @@ def test_edge_partition(self):
122137
deftest_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])

‎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
classRecoveryTest(unittest.TestCase,TestHelper):
6666

67-
defsetUp(self):
68-
time.sleep(20)
69-
print('Start new test at ',datetime.datetime.utcnow())
70-
warnings.simplefilter("ignore",ResourceWarning)
67+
@classmethod
68+
defsetUpClass(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-
deftearDown(self):
79-
print('Finish test at ',datetime.datetime.utcnow())
76+
@classmethod
77+
deftearDownClass(self):
78+
print('tearDown')
8079
self.client.stop()
8180

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

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

‎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
defsetUpClass(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
deftearDownClass(self):
16-
subprocess.check_call(['docker-compose','down'])
17+
print('tearDown')
18+
# subprocess.check_call(['docker-compose','down'])
1719

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp