[FIX] runbot: invalidate cache at each commit.

In some rare case db could become inconsistent if some data
in cache were used between two _schedule loop turn.
This commit is contained in:
Xavier-Do 2019-06-25 12:58:11 +02:00
parent 94a680f0c8
commit 5c72655e18
3 changed files with 7 additions and 1 deletions

View File

@ -508,6 +508,7 @@ class runbot_build(models.Model):
for build in self:
self.env.cr.commit() # commit between each build to minimise transactionnal errors due to state computations
self.invalidate_cache()
if build.local_state == 'deathrow':
build._kill(result='manually_killed')
continue
@ -607,6 +608,8 @@ class runbot_build(models.Model):
# cleanup only needed if it was not killed
if build.local_state == 'done':
build._local_cleanup()
self.env.cr.commit()
self.invalidate_cache()
def _path(self, *l, **kw):
"""Return the repo build path"""
@ -794,6 +797,7 @@ class runbot_build(models.Model):
self.env.cr.commit()
build._github_status()
build._local_cleanup()
self.invalidate_cache()
def _ask_kill(self):
# todo xdo, should we kill or skip children builds? it looks like yes, but we need to be carefull if subbuild can be duplicates

View File

@ -261,6 +261,7 @@ class ConfigStep(models.Model):
build_path = build._path()
build_port = build.port
self.env.cr.commit() # commit before docker run to be 100% sure that db state is consistent with dockers
self.invalidate_cache()
return docker_run(build_odoo_cmd(cmd), log_path, build_path, docker_name, exposed_ports=[build_port, build_port + 1])
def _run_odoo_install(self, build, log_path):

View File

@ -370,6 +370,7 @@ class runbot_repo(models.Model):
build_ids = Build.search(domain_host + [('local_state', 'in', ['testing', 'running', 'deathrow'])])
build_ids._schedule()
self.env.cr.commit()
self.invalidate_cache()
# launch new tests
@ -382,6 +383,7 @@ class runbot_repo(models.Model):
# commit transaction to reduce the critical section duration
def allocate_builds(where_clause, limit):
self.env.cr.commit()
self.invalidate_cache()
# self-assign to be sure that another runbot instance cannot self assign the same builds
query = """UPDATE
runbot_build
@ -421,7 +423,6 @@ class runbot_repo(models.Model):
pending_build = Build.search(domain_host + [('local_state', '=', 'pending')], limit=available_slots)
if pending_build:
pending_build._schedule()
self.env.cr.commit()
# terminate and reap doomed build
build_ids = Build.search(domain_host + [('local_state', '=', 'running')]).ids