Skip to content

Question: Difference between deleting stale sessions by user and by date #668

@MarkelJaure

Description

@MarkelJaure

Hi! I was reviewing how daloRADIUS handles stale session cleanup in acct-maintenance-cleanup.php and noticed a difference between the cleanup strategy used for a specific user versus cleanup by date.

  • When cleaning up by username, the system performs an UPDATE:
  UPDATE %s SET acctstoptime=NOW(), acctterminatecause='Admin-Reset'
   WHERE username='%s' AND acctstoptime IS NULL
  • However, when cleaning up by date, the system performs a DELETE:
   DELETE FROM %s
    WHERE acctstarttime < '%s'
    AND (acctstoptime = '0000-00-00 00:00:00' OR acctstoptime IS NULL)

In my application, maintaining an accurate and complete record of data usage is critical. I am planning to run a daily cron job to clean up expired sessions. However, I am concerned that using the date-based cleanup (DELETE) may remove historical session data that could still be relevant for accounting and reporting, and that using an UPDATE-based approach to close sessions might cause subsequent interim updates to fail to match the existing session, resulting in the creation of new sessions and potentially duplicating usage data.

Why was DELETE chosen instead of UPDATE for date-based cleanup? Is it safe to use the date-based cleanup in production environments where accounting accuracy is important?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions