Skip to content

Delete expired session files when there is no traffic#8526

Merged
adityatoshniwal merged 2 commits intopgadmin-org:masterfrom
cbandy:cleanup-sessions
Mar 11, 2025
Merged

Delete expired session files when there is no traffic#8526
adityatoshniwal merged 2 commits intopgadmin-org:masterfrom
cbandy:cleanup-sessions

Conversation

@cbandy
Copy link
Copy Markdown
Contributor

@cbandy cbandy commented Mar 7, 2025

Most HTTP requests create a file in the sessions directory. Open browsers call /misc/cleanup every five minutes, but session files can accumulate after browsers are closed.

This wakes periodically to delete expired sessions according to the CHECK_SESSION_FILES_INTERVAL setting.

Fixes: #1999
Fixes: #8355

@adityatoshniwal
Copy link
Copy Markdown
Contributor

Hi @cbandy,
There shouldn't be any http request when the browser is closed then how are session files accumulated?
The health check URL /misc/ping doesn't generate any session file.

@cbandy
Copy link
Copy Markdown
Contributor Author

cbandy commented Mar 7, 2025

There shouldn't be any http request when the browser is closed then how are session files accumulated?

We run in server mode, so a request can come from anywhere on our intranet. We trust most things not to be malicious there, but there's no guarantee.

Here's what my idle (no recent user activity) pgAdmin sessions directory looks like before and after one OWASP scan:

$ du -sh /var/lib/pgadmin/sessions
44.0K   /var/lib/pgadmin/sessions

$ du -sh /var/lib/pgadmin/sessions
19.4M   /var/lib/pgadmin/sessions

Running a more intensive scan or scanning daily would quickly fill this disk.

@adityatoshniwal
Copy link
Copy Markdown
Contributor

In that case, I think cleanup_session_files can be removed from /misc/cleanup as it will be taken care by the new code.

cbandy added 2 commits March 10, 2025 22:33
Most HTTP requests create a file in the sessions directory. Open browsers
call "/misc/cleanup" every five minutes, but session files can accumulate
after browsers are closed.

Wake periodically to delete expired sessions according to the
CHECK_SESSION_FILES_INTERVAL setting.

Fixes: pgadmin-org#1999
Fixes: pgadmin-org#8355
Updates: pgadmin-org#2097
@cbandy cbandy force-pushed the cleanup-sessions branch from b9d2053 to eaf6151 Compare March 11, 2025 04:23
@cbandy
Copy link
Copy Markdown
Contributor Author

cbandy commented Mar 11, 2025

In that case, I think cleanup_session_files can be removed from /misc/cleanup as it will be taken care by the new code.

Done! I also moved the timer into a try..finally so it will recur if there is trouble with the session directory temporarily.

@adityatoshniwal adityatoshniwal merged commit 846d0ea into pgadmin-org:master Mar 11, 2025
32 checks passed
@cbandy cbandy deleted the cleanup-sessions branch March 11, 2025 11:44
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.

No garbage collection for session files No Session cleanup (RM #3550)

2 participants