mirror of
https://github.com/odoo/runbot.git
synced 2025-03-16 07:55:45 +07:00
[FIX] runbot: minimize transactionnal errors
With recursive states computation, schedule is most likely to have transactionnal errors. This is particularly a problem when external operations are done during the transaction, like running a docker. Adding some commits will help to reduce transactionnal errors, and ensure that the db is consistent with docker states.
This commit is contained in:
parent
45516f9d33
commit
534368b675
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user