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

Commit59dbe42

Browse files
committed
When creating new physical replication slot check that it doesn't already exist
1 parente2e5a8d commit59dbe42

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎testgres/node.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
ExecUtilException, \
5050
QueryException, \
5151
StartNodeException, \
52-
TimeoutException
52+
TimeoutException, \
53+
TestgresException
5354

5455
from .loggerimportTestgresLogger
5556

@@ -263,6 +264,13 @@ def _create_replication_slot(self, slot_name, dbname=None, username=None):
263264
dbname: database name
264265
username: database user name
265266
"""
267+
rs=self.execute("select exists (select * from pg_replication_slots "
268+
"where slot_name = '{}')".format(slot_name),
269+
dbname=dbname,username=username)
270+
271+
ifrs[0][0]:
272+
raiseTestgresException("Slot '{}' already exists".format(slot_name))
273+
266274
query= (
267275
"select pg_create_physical_replication_slot('{}')"
268276
).format(slot_name)

‎tests/test_simple.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
BackupException, \
2222
QueryException, \
2323
CatchUpException, \
24-
TimeoutException
24+
TimeoutException, \
25+
TestgresException
2526

2627
fromtestgresimport \
2728
TestgresConfig, \
@@ -393,6 +394,10 @@ def test_replication_slots(self):
393394
res=replica.execute('select * from test')
394395
self.assertListEqual(res, [(1, ), (2, )])
395396

397+
# cannot create new slot with the same name
398+
withself.assertRaises(TestgresException):
399+
node._create_replication_slot('slot1')
400+
396401
deftest_incorrect_catchup(self):
397402
withget_new_node()asnode:
398403
node.init(allow_streaming=True).start()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp