diff options
| author | Denis Ledoux <dle@odoo.com> | 2018-05-29 14:30:10 +0000 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2018-10-15 07:46:52 +0000 |
| commit | dcb56412d667231c5427b0cd76cfc1c6c4b1dd3c (patch) | |
| tree | b00c695314edb235e21a4a313dd3a1ba546299b5 /addons/web/static/src/js/views/basic | |
| parent | 4691c6be182dbf274b37f74d5ee4581e5cf50e2b (diff) | |
[IMP] server.py: implements limits (real) for multi-threading
The multi-threaded server graceful stop policy is now as follows:
- shutdown the server so it does not accept new requests (the socket remains open),
- wait for remaining requests to finish up to a certain time (e.g. 1 second)
Previously, the multi-threaded server waited indefinitely for requests to finish.
The reload policy when a thread reaches a limit is as following:
- wait there is no other running requests, up to 1 minute
- then stop the server (with the above graceful stop policy applied),
- then reload the server, therefore accepting new requests again.
- The socket is not closed during this operation.
This allows the inverse proxy to queue the requests arriving during
the time the server is shutted down and therefore not accepting new requests.
This allows a transparent restart for the users, as their
requests done during the shutting down of the server are not rejected but queued.
- When a thread reaches a limit, we reload the whole threaded server instead of
just killing this thread. Killing a thread is not a good practice as it could
lead to dead locks in case these threads acquire locks.
Killing a thread that acquired a lock would lead for this lock to never be
released.
Regarding the override of `_handle_request_noblock`:
In `socketserver`,
when `shutdown` is called
`__shutdown_request` is set to True,
https://github.com/python/cpython/blob/6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d/Lib/socketserver.py#L241-L249
This tells the server to no longer accept requests. Callstack below:
- https://github.com/python/cpython/blob/6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d/Lib/socketserver.py#L231-L234
- https://github.com/python/cpython/blob/6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d/Lib/socketserver.py#L308
- https://github.com/python/cpython/blob/6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d/Lib/socketserver.py#L487
Unfortunately, this is very possible the HTTP server is already polling for a request when this flag is set
to `True` by the main thread:
- https://github.com/python/cpython/blob/6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d/Lib/socketserver.py#L232
As the poll_interval is set to 0.5s:
- https://github.com/python/cpython/blob/6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d/Lib/socketserver.py#L215
if a request arrives within 500ms after the server is shut down,
the request is accepted, while the server is shutdown.
We want to prevent this: Once the server is marked as shut down, we want it to no longer accept requests:
so the inverse proxy knows it has to queue the request.
closes odoo/odoo#24982
Diffstat (limited to 'addons/web/static/src/js/views/basic')
0 files changed, 0 insertions, 0 deletions
