#240 Commit the session at the end of ODCS jobs to ensure there is no idle transaction.
Merged 5 years ago by jkaluza. Opened 5 years ago by jkaluza.
jkaluza/odcs session-commit  into  master

@@ -712,6 +712,10 @@ 

          koji_tag_cache = KojiTagCache()

          koji_tag_cache.cleanup_reused(compose)

  

+         # Commit the session to ensure that database transaction is closed and

+         # does not remain in Idle state acquiring the table lock.

+         db.session.commit()

+ 

  

  class ComposerThread(BackendThread):

      """

@@ -23,7 +23,7 @@ 

  

  import fedmsg.consumers

  

- from odcs.server import log, conf

+ from odcs.server import log, conf, db

  from odcs.server.backend import ComposerThread, RemoveExpiredComposesThread

  from odcs.server.models import Compose

  from odcs.server.utils import retry
@@ -74,6 +74,10 @@ 

          except Exception:

              log.exception('Failed while handling {0!r}'.format(message))

  

+         # Commit the session to ensure that database transaction is closed and

+         # does not remain in Idle state acquiring the table lock.

+         db.session.commit()

+ 

          if self.stop_condition and self.stop_condition(message):

              self.shutdown()

  

The idle transaction holds the PostgreSQL database lock and blocks the database
migration to happen, because database migration needs exclusive lock on table.

:+1:

As per our discussion in IRC, in the future we may need a more concise way of ensuring commit is called, but as is, it seems fine.

Pull-Request has been merged by jkaluza

5 years ago