Skip to content

Commit

Permalink
Additional cleanup of inactive sessions and viewed selfservice errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abador committed Feb 14, 2024
1 parent ce6b11a commit 4686884
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions persistence/sql/persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ func (p *Persister) CleanupDatabase(ctx context.Context, wait time.Duration, old
}
time.Sleep(wait)

p.r.Logger().Println("Cleaning seen selfservice errors")
if err := p.ClearErrorContainers(ctx, older, false); err != nil {
return err
}
time.Sleep(wait)

p.r.Logger().Println("Successfully cleaned up the latest batch of the SQL database! " +
"This should be re-run periodically, to be sure that all expired data is purged.")
return nil
Expand Down
2 changes: 1 addition & 1 deletion persistence/sql/persister_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func (p *Persister) DeleteExpiredSessions(ctx context.Context, expiresAt time.Ti

//#nosec G201 -- TableName is static
err = p.GetConnection(ctx).RawQuery(fmt.Sprintf(
"DELETE FROM %s WHERE id in (SELECT id FROM (SELECT id FROM %s c WHERE expires_at <= ? and nid = ? ORDER BY expires_at ASC LIMIT %d ) AS s )",
"DELETE FROM %s WHERE id in (SELECT id FROM (SELECT id FROM %s c WHERE (expires_at <= ? or active = false) and nid = ? ORDER BY expires_at ASC LIMIT %d ) AS s )",
new(session.Session).TableName(ctx),
new(session.Session).TableName(ctx),
limit,
Expand Down

0 comments on commit 4686884

Please sign in to comment.