Saturday, December 28, 2019
2 changes · master
Miscellaneous changes
A similar fix was originally done in [1], where the access to `env` was done before the parent dispatch. The issue was then reintroduced with [2], where the `env` was possibly accessed again after the dispatch. This works most of the time, but in the rare case where the session is destroyed during dispatch, which is the case on `/web/session/destroy`, accessing the environment after that point will crash. This issue didn't manifest before [3], because the `env` was always initialized
Original PR description
A similar fix was originally done in [1], where the access to `env` was done before the parent dispatch. The issue was then reintroduced with [2], where the `env` was possibly accessed again after…
A similar fix was originally done in [1], where the access to `env` was done before the parent dispatch. The issue was then reintroduced with [2], where the `env` was possibly accessed again after the dispatch. This works most of the time, but in the rare case where the session is destroyed during dispatch, which is the case on `/web/session/destroy`, accessing the environment after that point will crash. This issue didn't manifest before [3], because the `env` was always initialized during `checked_call` when calling the `clear` method on it (since `env` is a magic property). After that commit, the `clear` is not called if not necessary, therefore it might happen that the `env` is never initialized. This leads to the crash when trying to initialize it for the first time after the `db` attribute has been cleared during the destroy, since a `db` is required to initialize it. The current fix aims to prevent the crash. As opposed to [1] that actually kept the tracking fields by fetching them before the dispatch, it is decided on this commit to voluntarily lose the tracking fields when destroying the session, because keeping them would require too much refactoring for a fix in stable, but we also feel that it makes sense functionally: those tracking fields were maybe used for a specific purpose in the original database, but they might mean something completely different on another database. [1] 6780597f2d984a432341e70c8408de376c188fe0 [2] c78de22a098c810afa2c69a45220f83a8a8f45c0 [3] f6d56afba0ea96529b1419bf2ed4ac12fc5e98c1 closes #42260 Forward-Port-Of: odoo/odoo#42299
Before this commit nothing prevented high concurrency on a threaded http server to consume too much resources, ending up failing requests either because the OS is unable to spawn that many threads (`RuntimeError: can't start new thread`), either because the Odoo db connection pool is full (`PoolError: The Connection Pool Is Full`). This commit adds the ODOO_MAX_HTTP_THREADS environment variable which allows to limit the amount of concurrent socket connections accepted by a threaded serv
Original PR description
Before this commit nothing prevented high concurrency on a threaded http server to consume too much resources, ending up failing requests either because the OS is unable to spawn that many threads…
Before this commit nothing prevented high concurrency on a threaded http server to consume too much resources, ending up failing requests either because the OS is unable to spawn that many threads (`RuntimeError: can't start new thread`), either because the Odoo db connection pool is full (`PoolError: The Connection Pool Is Full`). This commit adds the ODOO_MAX_HTTP_THREADS environment variable which allows to limit the amount of concurrent socket connections accepted by a threaded server, implicitly limiting the amount of concurrent threads running for http requests handling. Note that if a value has been provided to ODOO_MAX_HTTP_THREADS that cannot be parsed as an integer, a value will be automatically set to half the db connection pool size (which defaults to 64). This dynamic value is chosen because while most requests will borrow only one cursor concurrently, there are some exceptions where some controllers might allocate two or more cursors. -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#37238