Author: |
sewisoft |
License: |
AGPL-3 |
Branch: |
11.0 |
Repository: |
sewisoft/queue |
Dependencies: |
queue_job |
Languages: |
Python (43, 67.2%),
and
reStructuredText (21, 32.8%) |
<h1 class="title">Queue prevent duplicate jobs</h1>
<p>This module simply avoids the creation of a job, if there's already one executing the same function with absolutely the
equal parameters and it's state isn't in <cite>Started</cite> or <cite>Done</cite>.</p>
<a name="default-behaviour-of-job-queue"></a>
<h2>Default behaviour of Job Queue</h2>
<p>The default implementation doesn't identifies and eliminates duplicate pending jobs in the queue. So it is
possible that there are multiple jobs in the queue, which does eventually the same action e.g. exporting a product.</p>
<img alt="Without Queue job prevent duplicates installed" src="/queue_job_prevent_duplicates/static/description/example_queue_before.png" style="width: 100%;" />
<a name="after-installation"></a>
<h2>After installation</h2>
<p>Everytime a job will be created but there is already at least one job executing the same function and hasn't state
<cite>Done</cite> or <cite>Started</cite>, the job creation will be aborted. Instead a log information will be created.</p>
<img alt="After installation duplicate job creation will be prevented" src="/queue_job_prevent_duplicates/static/description/example_queue_after.png" style="width: 100%;" />
<a name="log-prevented-job-creation"></a>
<h2>Log prevented job-creation</h2>
<p>If the creation of a duplicate job was prevented, a log information will be created (see below):</p>
<pre class="code">
<code class="code">2017-12-11 08:02:51,770 10505 INFO v10_connector_db odoo.addons.queue_job_prevent_duplicates.models.queue_job: A job already exists for domain [('state', 'not in', ['started', 'done']), ('func_string', '=', 'sewi.shopware.synchronizer(6,)._import_all_records(only_new=True)')]
2017-12-11 08:02:51,775 10505 INFO v10_connector_db odoo.addons.queue_job_prevent_duplicates.models.queue_job: A job already exists for domain [('state', 'not in', ['started', 'done']), ('func_string', '=', 'sewi.shopware.synchronizer(7,)._import_all_records(only_new=True)')]</code>
</pre>
<a name="know-issues"></a>
<h2>Know Issues</h2>
<p>It can be expected, that it's possible when a record is modified but a job creation was prevented, because in this
cursors context was a pending job which does already the same action, but until the modifying cursor has
committed the record changes, the other job was already executed in a parallel thread / process. This will
lead to different versions of the record in both systems.</p>