diff --git a/runbot/models/build.py b/runbot/models/build.py index 9fa1bb47..fd2ee7a0 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -486,6 +486,7 @@ class runbot_build(models.Model): # For retro-compatibility, keep this parameter in seconds for build in self: + self.env.cr.commit() # commit between each build to minimise transactionnal errors due to state computations if build.local_state == 'deathrow': build._kill(result='manually_killed') continue diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index ebfef17a..abb17455 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -237,7 +237,12 @@ class ConfigStep(models.Model): smtp_host = docker_get_gateway_ip() if smtp_host: cmd += ['--smtp', smtp_host] - return docker_run(build_odoo_cmd(cmd), log_path, build._path(), build._get_docker_name(), exposed_ports=[build.port, build.port + 1]) + + docker_name = build._get_docker_name() + 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 + 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): cmd, _ = build._cmd() diff --git a/runbot/models/repo.py b/runbot/models/repo.py index d631fa91..e87ac62f 100644 --- a/runbot/models/repo.py +++ b/runbot/models/repo.py @@ -358,6 +358,7 @@ class runbot_repo(models.Model): # schedule jobs (transitions testing -> running, kill jobs, ...) build_ids = Build.search(domain_host + [('local_state', 'in', ['testing', 'running', 'deathrow'])]) build_ids._schedule() + self.env.cr.commit() # launch new tests @@ -365,7 +366,7 @@ class runbot_repo(models.Model): available_slots = workers - nb_testing reserved_slots = Build.search_count(domain_host + [('local_state', '=', 'pending')]) assignable_slots = available_slots - reserved_slots - if available_slots > 0: + if available_slots > 0: if assignable_slots > 0: # note: slots have been addapt to be able to force host on pending build. Normally there is no pending with host. # commit transaction to reduce the critical section duration self.env.cr.commit()