Skip to content

Commit c6437d1

Browse files
committed
Reduce test_backend_transaction_age flakiness
Add the timestamp to the application name to reduce the risk of leftover query and connection being present when metrics are collected.
1 parent c2d779a commit c6437d1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

postgres/tests/test_pg_integration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def _increase_txid(cur):
119119
else:
120120
query = 'select txid_current();'
121121
cur.execute(query)
122+
assert cur.fetchone() is not None
122123

123124

124125
def test_initialization_tags(integration_check, pg_instance):
@@ -485,7 +486,7 @@ def test_backend_transaction_age(aggregator, integration_check, pg_instance):
485486

486487
check.run()
487488

488-
app = 'test_backend_transaction_age'
489+
app = f'test_backend_transaction_age_{time.time()}'
489490
conn1 = _get_conn(pg_instance, application_name=app)
490491
cur = conn1.cursor()
491492

@@ -498,8 +499,6 @@ def test_backend_transaction_age(aggregator, integration_check, pg_instance):
498499
cur.execute('BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;')
499500
# Force assignement of a txid and keep the transaction opened
500501
_increase_txid(cur)
501-
# Make sure to fetch the result to make sure we start the timer after the transaction started
502-
cur.fetchall()
503502
start_transaction_time = time.time()
504503

505504
aggregator.reset()

0 commit comments

Comments
 (0)