Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: additional cleanup of old data #3755

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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
Loading