Skip to content

Commit b652c0f

Browse files
committed
contest-hw: mctrl: fix exceptions on DB races
Not sure why but some connections in the pool seem to crash occasionally. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2a660c2 commit b652c0f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

contest/hw/machine_control.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ def get_nic_info():
189189
"ifname, ip4addr, ip6addr FROM nic_info"
190190
)
191191
rows = cur.fetchall()
192-
finally:
192+
except Exception:
193+
db_pool.putconn(conn, close=True)
194+
raise
195+
else:
193196
db_pool.putconn(conn)
194197

195198
result = []
@@ -232,7 +235,10 @@ def get_sol_logs():
232235
(machine_id, start_id, limit)
233236
)
234237
rows = cur.fetchall()
235-
finally:
238+
except Exception:
239+
db_pool.putconn(conn, close=True)
240+
raise
241+
else:
236242
db_pool.putconn(conn)
237243

238244
last_id = rows[-1][0] if rows else start_id

0 commit comments

Comments
 (0)