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

Commit9bcefb2

Browse files
committed
[PBCKP-327] test_ptrack_multiple_segments: try to avoid memory consumption
1 parent744c285 commit9bcefb2

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

‎tests/helpers/ptrack_helpers.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
fromtimeimportsleep
1616
importre
1717
importjson
18+
fromhashlibimportmd5
19+
importrandom
1820

1921
idx_ptrack= {
2022
't_heap': {
@@ -200,6 +202,32 @@ def kill(self, someone = None):
200202
os.kill(self.auxiliary_pids[someone][0],sig)
201203
self.is_started=False
202204

205+
deftable_checksum(self,table,sort,dbname="postgres"):
206+
curname="cur_"+str(random.randint(0,2**48))
207+
208+
sum=md5(b"\x01")
209+
210+
con=self.connect(dbname=dbname)
211+
212+
con.execute(f"""
213+
DECLARE{curname} NO SCROLL CURSOR FOR
214+
SELECT t::text FROM{table} as t ORDER BY{sort};
215+
""")
216+
217+
whileTrue:
218+
rows=con.execute(f"FETCH FORWARD 10000 FROM{curname}")
219+
ifnotrows:
220+
break
221+
forrowinrows:
222+
sum.update(row[0].encode('utf8'))
223+
sum.update(b'\x00')
224+
225+
con.execute(f"CLOSE{curname}; ROLLBACK;")
226+
227+
con.close()
228+
sum.update(b'\x02')
229+
returnsum.hexdigest()
230+
203231
classProbackupTest(object):
204232
# Class attributes
205233
enterprise=is_enterprise()

‎tests/ptrack_test.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,8 @@ def test_ptrack_multiple_segments(self):
20392039

20402040
# CREATE TABLE
20412041
node.pgbench_init(scale=100,options=['--tablespace=somedata'])
2042+
result=node.table_checksum("pgbench_accounts","aid",
2043+
dbname="postgres")
20422044
# FULL BACKUP
20432045
self.backup_node(backup_dir,'node',node,options=['--stream'])
20442046

@@ -2075,7 +2077,8 @@ def test_ptrack_multiple_segments(self):
20752077

20762078
# GET LOGICAL CONTENT FROM NODE
20772079
# it`s stupid, because hint`s are ignored by ptrack
2078-
result=node.safe_psql("postgres","select * from pgbench_accounts")
2080+
result=node.table_checksum("pgbench_accounts","aid",
2081+
dbname="postgres")
20792082
# FIRTS PTRACK BACKUP
20802083
self.backup_node(
20812084
backup_dir,'node',node,backup_type='ptrack',options=['--stream'])
@@ -2108,9 +2111,8 @@ def test_ptrack_multiple_segments(self):
21082111
restored_node, {'port':restored_node.port})
21092112
restored_node.slow_start()
21102113

2111-
result_new=restored_node.safe_psql(
2112-
"postgres",
2113-
"select * from pgbench_accounts")
2114+
result_new=restored_node.table_checksum("pgbench_accounts","aid",
2115+
dbname="postgres")
21142116

21152117
# COMPARE RESTORED FILES
21162118
self.assertEqual(result,result_new,'data is lost')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp