Port to psycopg3
Cc. @marmoute
Merge request reports
Activity
assigned to @olasd
Jenkins job DPROV/gitlab-builds #216 succeeded in 3 min 36 sec.
See Console Output, Blue Ocean and Coverage Report for more details.We need to mix this with !199 (merged) for better result. I'll look into that tomorrow/monday.
Edited by Pierre-Yves David
35 35 self._db = Db(db) 36 37 # See comment below 38 self._db.cursor().execute("SET TIME ZONE 'UTC'") 39 36 else: 40 self._pool = psycopg2.pool.ThreadedConnectionPool( 41 min_pool_conns, max_pool_conns, db 37 self._pool = psycopg_pool.ConnectionPool( 38 conninfo=db, 39 min_size=min_pool_conns, 40 max_size=max_pool_conns, 41 open=False, 42 42 ) 43 # Wait for the first connection to be ready, and raise the 44 # appropriate exception if connection fails 45 self._pool.open(wait=True, timeout=1) - Comment on lines +43 to +45
Do we really need this here? Because the test does not seems to depends on it, and in most case we don't do it (e.g. the scheduler does it, but the storage don't).
If we really want this,
self._pool.wait()
seems more appropriate (it open a bit more connections, but the semantic seems more appropriate), and we should consider doing it in all case too.(side note, this pattern of db/connection pool seems repeated in various places and could probably be factored out for consistency).
Ah! Yeah, you're right. The problem with
open=True
was two-fold:- You get the default 30 second timeout even on the initial connection (which is probably okay to recover from transient issues, but not great for initial connection checking)
- But
open=True
tells the /background/ workers to connect, so you need to callwait
anyway if you want an exception on a badly configured connection (and you'll only get it after the 30s timeout)
So creating the pool with
open=False
+ an explicitopen(wait=True, timeout=1)
ended up being the best compromise.!199 (merged) should be ready now.
mentioned in merge request !199 (merged)
Closed in favor of !199 (merged)