Search 1.9 billion lines of Odoo code on GitHub

base_deterministic_session_gc

Author: Trobz,Odoo Community Association (OCA)
License: AGPL-3
Branch: 14.0
Repository: acsone/server-tools
Dependencies: mail
Languages: HTML (382, 70.3%), Python (56, 10.3%), XML (14, 2.6%), and reStructuredText (91, 16.8%)
Other branches: 12.0, 13.0, 13.0-bp-jsonifier-ape, 13.0-fix-cache-base_jsonify-ape, 13.0-fix-precommit-ape, 13.0-session_db-sbi, 13.0-update-dotfiles-sbi, and 14.0-session_db-sbi
Other repositories: AITIC/server-tools, Callino/server-tools, Change2improve/server-tools, Digital5-Odoo/server-tools, ERPLibre/server-tools, ForgeFlow/server-tools, Jarsa/server-tools, LevelPrime/server-tools, OCA/server-tools, Rad0van/server-tools, StefanRijnhart/server-tools, Tecnativa/server-tools, VanMoof/server-tools, YannickB/server-tools, aaltinisik/server-tools, akretion/server-tools, anhvu-sg/server-tools, aurestic/server-tools, blooparksystems/server-tools, brain-tec/server-tools, camptocamp/server-tools, coopiteasy/server-tools, eLBati/server-tools, ecosoft-odoo/server-tools, grindtildeath/server-tools, gurneyalex/server-tools, hbrunn/server-tools, kmee/server-tools, legalsylvain/server-tools, modoolar/server-tools, multidadosti-erp/server-tools, nilshamerlinck/server-tools, petrus-v/server-tools, praxigento/oca-server-tools, sunflowerit/server-tools, tegin/server-tools, tirma-sa/server-tools, ursais/server-tools, ypapouin/server-tools, and zarumaru/server-tools

<h1 class="title">Deterministic Session GC</h1> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/base_deterministic_session_gc"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_deterministic_session_gc"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p>Whenever a new request is processed by Odoo, this statement is evaluated: <cite>random.random() &lt; 0.001</cite> [<a class="reference external" href="https://github.com/odoo/odoo/blob/a0a11fd5e2d78e5fc0d1503275adade570fe0d42/odoo/http.py#L1192">1</a>]</p> <p>1 time out of 1000 in average, it will return <cite>True</cite> and trigger the Garbage Collection of sessions: sessions that have not been active for more than 1 week will be deleted [<a class="reference external" href="https://github.com/odoo/odoo/blob/a0a11fd5e2d78e5fc0d1503275adade570fe0d42/odoo/http.py#L1193">2</a>]</p> <p>This random approach can become a problem in some contexts.</p> <p>On a highly visited Odoo website, many sessions will be created. Going through all of them will take some time, especially on a slow/loaded FS. The Garbage Collection happening randomly, your users will report you cases of Odoo being randomly slow on random actions. They won't be able to reproduce these cases and you won't be able to trace them in your odoo logs neither, because calls' response time doesn't include the time Odoo spent on the Garbage Collection.</p> <p>Moreover, on a heavily loaded server, better be in a position to control when does the Garbage Collection happen. One might want to run it once per night only for example.</p> <p>That's why we created this module:</p> <ul class="simple"> <li>to disable the default random Garbage Collection</li> <li>to enable administrators to replace it by a deterministic approach:<ul> <li>either by using the included Scheduled Action;</li> <li>or by calling the added public method <cite>ir.autovacuum:gc_sessions()</cite> remotely</li> </ul> </li> </ul> <p><strong>Table of contents</strong></p> <div class="contents local topic" id="contents"> <ul class="simple"> <li><a class="reference internal" href="#installation" id="id3">Installation</a></li> <li><a class="reference internal" href="#configuration" id="id4">Configuration</a></li> <li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id6">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id7">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li> <li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li> </ul> </li> </ul> </div> <a name="installation"></a> <h2><a class="toc-backref" href="#id3">Installation</a></h2> <p>You need to load this module server-wide:</p> <ul class="simple"> <li>By starting Odoo with <code>--load=web,base_deterministic_session_gc</code></li> <li>Or by updating its configuration file:</li> </ul> <pre> <code lang="ini">[options] (...) server_wide_modules = web,base_deterministic_session_gc</code> </pre> <p>You also need to install it in your database if you want to use the provided deterministic approach.</p> <a name="configuration"></a> <h2><a class="toc-backref" href="#id4">Configuration</a></h2> <p>You can change the session expiry delay in the Odoo configuration file:</p> <pre> <code lang="ini">[options] (...) ; 1 day = 60*60*24 seconds session_expiry_delay = 86400</code> </pre> <p>Default value is 7 days.</p> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id5">Bug Tracker</a></h2> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed <a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_deterministic_session_gc%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <p>Do not contact contributors directly about support or help with technical issues.</p> <a name="credits"></a> <h2><a class="toc-backref" href="#id6">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id7">Authors</a></h3> <ul class="simple"> <li>Trobz</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id8">Contributors</a></h3> <ul class="simple"> <li>Nils Hamerlinck &lt;<a class="reference external" href="mailto:nils&#64;trobz.com">nils&#64;trobz.com</a>&gt;</li> </ul> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id9">Maintainers</a></h3> <p>This module is maintained by the OCA.</p> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/base_deterministic_session_gc">OCA/server-tools</a> project on GitHub.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>