Skip to content

20.0 mig session_redis - #538

Merged
leemannd merged 54 commits into
20.0from
20.0-mig-session_redis
Oct 27, 2026
Merged

leemannd merged 54 commits into
20.0from
20.0-mig-session_redis

Conversation

@leemannd

@leemannd leemannd commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

BSTOOLS-29

guewen and others added 30 commits October 26, 2026 11:49
The default expiration of sessions is 7 days. With healthchecks run
every few seconds, we quickly have millions of anonymous sessions in
Redis. Allow to define a custom expiration for some sessions and set a
very short one for the monitoring requests.
In several places, odoo sets a datetime object directly in the
session. It works with the default session handler of odoo which
uses pickle.

But datetime and date are not json serializable by default.

Add custom encoder / decoder to handle them (from
https://github.com/OCA/queue/blob/dc12a6a20ecfd15c5b90f9b089c9a64cf9d8bbe4/queue_job/fields.py#L57-L99)

See the discussion raised by @PCatinean on #176
The main goal is to be able to easily do grep and sed when we
do mass update on them
vrenaville and others added 23 commits October 26, 2026 11:49
Co-authored-by: Hugo Santos <hugo.santos@factorlibre.com>
Use copier template from oca/oca-addons-repo-template

Apply linting
`Session.vacuum` method contains extra arguments since this PR odoo/odoo#122888

accept parameters to adapter this change
``session_redis`` is not compatible with ``auth_session_timeout``.
``session_redis`` overrides property ``odoo.http.Application.session_store`` by returning a ``RedisSessionStore`` object instead of a ``odoo.http.FilesystemSessionStore`` object.
``auth_session_timeout`` expects ``odoo.http.Application.session_store`` object to define method ``get_session_filename()``, which does not exist for ``RedisSessionStore`` objects.
This results in an ``AttributeError`` that prevents user authentication, and Odoo becomes inaccessible.
* lazy_property is deprecated
* Since odoo/odoo@cea66be, Session
  must be used as a dictionary when setting custom values
* Session default lifetime is now defined in odoo.http, so we can just reuse that
* Handle new session rotation logic (sessions must be findable by the first 42 chars of they key)
* Handle new session key generation for rotation (keys must be longer than 42 chars to handle devices)
Co-authored-by: Florent Xicluna <142113+florentx@users.noreply.github.com>
On the cloud platform of Camptocamp, a shared redis is used to store the
sessions of the different projects -> the number of keys is huge, and
using an iterative match kills the performance because of the networking
overhead.

We switch to using redis.key(pattern), and since the pattern typically
has a leading string which will allow redis to find the correct bucket,
the performance should be good.
- odoo.http is now a package: the session store is the
  odoo.http.session.SessionStore class, instantiated by the cached
  odoo.http.session.session_store() factory which is imported by name
  everywhere. Replace the class it instantiates and clear its cache
  instead of patching the removed Application.session_store.
- RedisSessionStore inherits from the new core SessionStore
  (generate_key, is_valid_session_id, new and rotate are reused) and
  follows its API (session_cls, get(sid, keep_sid=...)).
- Fix the key pattern of get_missing_session_identifiers, which never
  matched and reported every device session as revoked.
- Ignore malformed identifiers in delete_from_identifiers like core.
- ruff fixes: ValueError for the configuration error, str env defaults.

@imlopes imlopes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leemannd
leemannd merged commit 3eaa845 into 20.0 Oct 27, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.