Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions session_db/pg_session_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ def vacuum(self, max_lifetime=http.SESSION_LIFETIME):
(f"{max_lifetime} seconds",),
)

@with_lock
@with_cursor
def delete_from_identifiers(self, identifiers: list[str]) -> None:
for identifier in identifiers:
if not sessions._sha1_re.match(identifier):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_sha1_re is not the same regex as _session_identifier_re. Why do you change this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

hi @sbidoul
The module imports the sessions class from odoo.tools._vendor import sessions.

The generate_key method it calls is this one: https://github.com/odoo/odoo/blob/18.0/odoo/tools/_vendor/sessions.py#L33-L37 which creates a SHA (40 characters) and not a 42-character identifier.

I understand that we could modify the FilesystemSessionStore class to inherit from FilesystemSessionStore (https://github.com/odoo/odoo/blob/18.0/odoo/http.py#L911) and ensure consistent behavior. However, we would have to remove the validations to avoid errors with existing sessions.

Since we are on a stable version with many productive installations, I prefer to be conservative with the changes. I look forward to hearing your opinion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I see. And in 19, we don't have that problem because we use the generate_key method from FileSystemSessionStore here:

generate_key = http.FilesystemSessionStore.generate_key

Is that right?

So maybe we should do the same here, and support both regexes in delete_from_identifiers?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

raise ValueError(
"Identifier format incorrect, "
"did you pass in a string instead of a list?"
)
self._cr.execute(
"DELETE FROM http_sessions WHERE sid LIKE %s||'%%'", (identifier,)
)


_original_session_store = http.root.__class__.session_store

Expand Down