From 644860284bdedb66868aedf2c12c1a40648c436c Mon Sep 17 00:00:00 2001 From: abador Date: Tue, 17 May 2022 10:34:13 +0200 Subject: [PATCH] Delete using subselect, ISSUE-952 --- cmd/cleanup/root.go | 3 ++- cmd/cleanup/sql.go | 4 +++- cmd/cliclient/cleanup.go | 6 ++++- continuity/persistence.go | 2 +- continuity/test/persistence.go | 23 ++++++++++++++++++++ driver/config/config.go | 9 +++++--- driver/config/config_test.go | 16 +++++++++++++- go.mod | 2 +- internal/driver.go | 1 + persistence/reference.go | 2 +- persistence/sql/persister.go | 16 +++++++------- persistence/sql/persister_continuity.go | 7 ++++-- persistence/sql/persister_login.go | 7 ++++-- persistence/sql/persister_recovery.go | 7 ++++-- persistence/sql/persister_registration.go | 7 ++++-- persistence/sql/persister_session.go | 8 ++++--- persistence/sql/persister_settings.go | 7 ++++-- persistence/sql/persister_test.go | 9 ++++++++ persistence/sql/persister_verification.go | 7 ++++-- selfservice/flow/login/persistence.go | 2 +- selfservice/flow/recovery/persistence.go | 2 +- selfservice/flow/registration/persistence.go | 2 +- selfservice/flow/settings/persistence.go | 2 +- selfservice/flow/verification/persistence.go | 2 +- session/persistence.go | 2 +- 25 files changed, 116 insertions(+), 39 deletions(-) diff --git a/cmd/cleanup/root.go b/cmd/cleanup/root.go index 5305b679a1c..ac2f0b88797 100644 --- a/cmd/cleanup/root.go +++ b/cmd/cleanup/root.go @@ -1,8 +1,9 @@ package cleanup import ( - "github.com/ory/x/configx" "github.com/spf13/cobra" + + "github.com/ory/x/configx" ) func NewCleanupCmd() *cobra.Command { diff --git a/cmd/cleanup/sql.go b/cmd/cleanup/sql.go index f3d1740b90f..d81439881e7 100644 --- a/cmd/cleanup/sql.go +++ b/cmd/cleanup/sql.go @@ -16,9 +16,10 @@ import ( "fmt" "time" - "github.com/ory/kratos/driver/config" "github.com/spf13/cobra" + "github.com/ory/kratos/driver/config" + "github.com/ory/kratos/cmd/cliclient" "github.com/ory/x/configx" ) @@ -48,6 +49,7 @@ Before running this command on an existing database, create a back up! configx.RegisterFlags(c.PersistentFlags()) c.Flags().BoolP("read-from-env", "e", true, "If set, reads the database connection string from the environment variable DSN or config file key dsn.") c.Flags().Duration(config.ViperKeyDatabaseCleanupSleepTables, time.Minute, "How long to wait between each table cleanup") + c.Flags().IntP(config.ViperKeyDatabaseCleanupBatchSize, "b", 100, "Set the number of records to be cleaned per run") c.Flags().Duration("keep-last", 0, "Don't remove records younger than") return c } diff --git a/cmd/cliclient/cleanup.go b/cmd/cliclient/cleanup.go index 99b29f2d9e4..76abfb5eb05 100644 --- a/cmd/cliclient/cleanup.go +++ b/cmd/cliclient/cleanup.go @@ -56,7 +56,11 @@ func (h *CleanupHandler) CleanupSQL(cmd *cobra.Command, args []string) error { keepLast := flagx.MustGetDuration(cmd, "keep-last") - err = d.Persister().CleanupDatabase(cmd.Context(), d.Config(cmd.Context()).DatabaseCleanupSleepTables(), keepLast) + err = d.Persister().CleanupDatabase( + cmd.Context(), + d.Config(cmd.Context()).DatabaseCleanupSleepTables(), + keepLast, + d.Config(cmd.Context()).DatabaseCleanupBatchSize()) if err != nil { return errors.Wrap(err, "An error occurred while cleaning up expired data") } diff --git a/continuity/persistence.go b/continuity/persistence.go index bc6c2036b59..b536b692df6 100644 --- a/continuity/persistence.go +++ b/continuity/persistence.go @@ -15,5 +15,5 @@ type Persister interface { SaveContinuitySession(ctx context.Context, c *Container) error GetContinuitySession(ctx context.Context, id uuid.UUID) (*Container, error) DeleteContinuitySession(ctx context.Context, id uuid.UUID) error - DeleteExpiredContinuitySessions(context.Context, time.Time) error + DeleteExpiredContinuitySessions(context.Context, time.Time, int) error } diff --git a/continuity/test/persistence.go b/continuity/test/persistence.go index 2eb4270e3be..9dbf2b6e39a 100644 --- a/continuity/test/persistence.go +++ b/continuity/test/persistence.go @@ -94,5 +94,28 @@ func TestPersister(ctx context.Context, p interface { require.ErrorIs(t, err, sqlcon.ErrNoRows) }) }) + + t.Run("case=cleanup", func(t *testing.T) { + id := x.NewUUID() + now := time.Now().Add(-24 * time.Hour).UTC().Truncate(time.Second) + m := sqlxx.NullJSONRawMessage(`{"foo": "bar"}`) + expected := continuity.Container{Name: "foo", IdentityID: x.PointToUUID(createIdentity(t).ID), + ExpiresAt: now, + Payload: m, + } + expected.ID = id + + t.Run("can cleanup", func(t *testing.T) { + require.NoError(t, p.SaveContinuitySession(ctx, &expected)) + + assert.EqualValues(t, id, expected.ID) + assert.EqualValues(t, nid, expected.NID) + + require.NoError(t, p.DeleteExpiredContinuitySessions(ctx, time.Now(), 5)) + + _, err := p.GetContinuitySession(ctx, id) + require.Error(t, err) + }) + }) } } diff --git a/driver/config/config.go b/driver/config/config.go index 741cad3aa1f..21c0ae6a151 100644 --- a/driver/config/config.go +++ b/driver/config/config.go @@ -15,8 +15,6 @@ import ( "testing" "time" - "github.com/santhosh-tekuri/jsonschema" - "github.com/ory/jsonschema/v3/httploader" "github.com/ory/x/httpx" @@ -156,6 +154,7 @@ const ( ViperKeyHasherBcryptCost = "hashers.bcrypt.cost" ViperKeyCipherAlgorithm = "ciphers.algorithm" ViperKeyDatabaseCleanupSleepTables = "database.cleanup.sleep.tables" + ViperKeyDatabaseCleanupBatchSize = "database.cleanup.batch_size" ViperKeyLinkLifespan = "selfservice.methods.link.config.lifespan" ViperKeyLinkBaseURL = "selfservice.methods.link.config.base_url" ViperKeyPasswordHaveIBeenPwnedHost = "selfservice.methods.password.config.haveibeenpwned_host" @@ -1084,7 +1083,11 @@ func (p *Config) SelfServiceLinkMethodBaseURL() *url.URL { } func (p *Config) DatabaseCleanupSleepTables() time.Duration { - return p.p.DurationF(ViperKeyDatabaseCleanupSleepTables, 1*time.Minute) + return p.p.DurationF(ViperKeyDatabaseCleanupSleepTables, 5*time.Second) +} + +func (p *Config) DatabaseCleanupBatchSize() int { + return p.p.IntF(ViperKeyDatabaseCleanupBatchSize, 100) } func (p *Config) SelfServiceFlowRecoveryAfterHooks(strategy string) []SelfServiceHook { diff --git a/driver/config/config_test.go b/driver/config/config_test.go index 4dbe7113641..1739c8f1331 100644 --- a/driver/config/config_test.go +++ b/driver/config/config_test.go @@ -48,7 +48,7 @@ func TestViperProvider(t *testing.T) { p := config.MustNew(t, logrusx.New("", ""), os.Stderr, configx.WithConfigFiles("stub/.kratos.yaml")) - t.Run("gourp=client config", func(t *testing.T) { + t.Run("group=client config", func(t *testing.T) { assert.False(t, p.ClientHTTPNoPrivateIPRanges(), "Should not have private IP ranges disabled per default") p.MustSet(config.ViperKeyClientHTTPNoPrivateIPRanges, true) assert.True(t, p.ClientHTTPNoPrivateIPRanges(), "Should disallow private IP ranges if set") @@ -1152,3 +1152,17 @@ func TestCourierTemplatesConfig(t *testing.T) { assert.Equal(t, courierTemplateConfig, c.CourierTemplatesHelper(config.ViperKeyCourierTemplatesRecoveryValidEmail)) }) } + +func TestCleanup(t *testing.T) { + p := config.MustNew(t, logrusx.New("", ""), os.Stderr, + configx.WithConfigFiles("stub/.kratos.yaml")) + + t.Run("group=cleanup config", func(t *testing.T) { + assert.Equal(t, p.DatabaseCleanupSleepTables(), 1*time.Minute) + p.MustSet(config.ViperKeyDatabaseCleanupSleepTables, time.Second) + assert.Equal(t, p.DatabaseCleanupSleepTables(), time.Second) + assert.Equal(t, p.DatabaseCleanupBatchSize(), 100) + p.MustSet(config.ViperKeyDatabaseCleanupBatchSize, 1) + assert.Equal(t, p.DatabaseCleanupSleepTables(), 1) + }) +} diff --git a/go.mod b/go.mod index accb5e093cb..15984f490a1 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( github.com/dgraph-io/ristretto v0.1.0 github.com/duo-labs/webauthn v0.0.0-20220330035159-03696f3d4499 github.com/fatih/color v1.13.0 - github.com/form3tech-oss/jwt-go v3.2.3+incompatible github.com/ghodss/yaml v1.0.0 github.com/go-errors/errors v1.0.1 github.com/go-openapi/strfmt v0.20.3 @@ -151,6 +150,7 @@ require ( github.com/evanphx/json-patch v4.11.0+incompatible // indirect github.com/fatih/structs v1.1.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect + github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/fullstorydev/grpcurl v1.8.1 // indirect github.com/fxamacker/cbor/v2 v2.4.0 // indirect diff --git a/internal/driver.go b/internal/driver.go index a2e6f1c36b6..7d8ab2f3ff9 100644 --- a/internal/driver.go +++ b/internal/driver.go @@ -47,6 +47,7 @@ func NewConfigurationWithDefaults(t *testing.T) *config.Config { config.ViperKeySelfServiceBrowserDefaultReturnTo: "https://www.ory.sh/redirect-not-set", config.ViperKeySecretsCipher: []string{"secret-thirty-two-character-long"}, config.ViperKeyDatabaseCleanupSleepTables: 1 * time.Minute, + config.ViperKeyDatabaseCleanupBatchSize: 100, }), configx.SkipValidation(), ) diff --git a/persistence/reference.go b/persistence/reference.go index 68e7c2eb9b9..eb01d1d5c66 100644 --- a/persistence/reference.go +++ b/persistence/reference.go @@ -44,7 +44,7 @@ type Persister interface { link.RecoveryTokenPersister link.VerificationTokenPersister - CleanupDatabase(context.Context, time.Duration, time.Duration) error + CleanupDatabase(context.Context, time.Duration, time.Duration, int) error Close(context.Context) error Ping() error MigrationStatus(c context.Context) (popx.MigrationStatuses, error) diff --git a/persistence/sql/persister.go b/persistence/sql/persister.go index b8c3620d3fc..ac8e6578d4f 100644 --- a/persistence/sql/persister.go +++ b/persistence/sql/persister.go @@ -136,48 +136,48 @@ type node interface { GetNID() uuid.UUID } -func (p *Persister) CleanupDatabase(ctx context.Context, wait time.Duration, older time.Duration) error { +func (p *Persister) CleanupDatabase(ctx context.Context, wait time.Duration, older time.Duration, batchSize int) error { currentTime := time.Now().Add(-older) p.r.Logger().Printf("Cleaning up records older than %s\n", currentTime) p.r.Logger().Println("Cleaning up expired sessions") - if err := p.DeleteExpiredSessions(ctx, currentTime); err != nil { + if err := p.DeleteExpiredSessions(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) p.r.Logger().Println("Cleaning up expired continuity containers") - if err := p.DeleteExpiredContinuitySessions(ctx, currentTime); err != nil { + if err := p.DeleteExpiredContinuitySessions(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) p.r.Logger().Println("Cleaning up expired login flows") - if err := p.DeleteExpiredLoginFlows(ctx, currentTime); err != nil { + if err := p.DeleteExpiredLoginFlows(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) p.r.Logger().Println("Cleaning up expired recovery flows") - if err := p.DeleteExpiredRecoveryFlows(ctx, currentTime); err != nil { + if err := p.DeleteExpiredRecoveryFlows(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) p.r.Logger().Println("Cleaning up expired registation flows") - if err := p.DeleteExpiredRegistrationFlows(ctx, currentTime); err != nil { + if err := p.DeleteExpiredRegistrationFlows(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) p.r.Logger().Println("Cleaning up expired settings flows") - if err := p.DeleteExpiredSettingsFlows(ctx, currentTime); err != nil { + if err := p.DeleteExpiredSettingsFlows(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) p.r.Logger().Println("Cleaning up expired verification flows") - if err := p.DeleteExpiredVerificationFlows(ctx, currentTime); err != nil { + if err := p.DeleteExpiredVerificationFlows(ctx, currentTime, batchSize); err != nil { return err } time.Sleep(wait) diff --git a/persistence/sql/persister_continuity.go b/persistence/sql/persister_continuity.go index 7c4c43e0f04..29482dc5ddf 100644 --- a/persistence/sql/persister_continuity.go +++ b/persistence/sql/persister_continuity.go @@ -43,13 +43,16 @@ func (p *Persister) DeleteContinuitySession(ctx context.Context, id uuid.UUID) e return nil } -func (p *Persister) DeleteExpiredContinuitySessions(ctx context.Context, expiresAt time.Time) error { +func (p *Persister) DeleteExpiredContinuitySessions(ctx context.Context, expiresAt time.Time, limit int) error { // #nosec G201 err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", new(continuity.Container).TableName(ctx), + new(continuity.Container).TableName(ctx), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/persistence/sql/persister_login.go b/persistence/sql/persister_login.go index 7eb5024020e..790cddc81c5 100644 --- a/persistence/sql/persister_login.go +++ b/persistence/sql/persister_login.go @@ -54,13 +54,16 @@ func (p *Persister) ForceLoginFlow(ctx context.Context, id uuid.UUID) error { }) } -func (p *Persister) DeleteExpiredLoginFlows(ctx context.Context, expiresAt time.Time) error { +func (p *Persister) DeleteExpiredLoginFlows(ctx context.Context, expiresAt time.Time, limit int) error { // #nosec G201 err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", new(login.Flow).TableName(ctx), + new(login.Flow).TableName(ctx), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/persistence/sql/persister_recovery.go b/persistence/sql/persister_recovery.go index 557259e5f15..84c2bd630fa 100644 --- a/persistence/sql/persister_recovery.go +++ b/persistence/sql/persister_recovery.go @@ -94,13 +94,16 @@ func (p *Persister) DeleteRecoveryToken(ctx context.Context, token string) error return p.GetConnection(ctx).RawQuery(fmt.Sprintf("DELETE FROM %s WHERE token=? AND nid = ?", new(link.RecoveryToken).TableName(ctx)), token, corp.ContextualizeNID(ctx, p.nid)).Exec() } -func (p *Persister) DeleteExpiredRecoveryFlows(ctx context.Context, expiresAt time.Time) error { +func (p *Persister) DeleteExpiredRecoveryFlows(ctx context.Context, expiresAt time.Time, limit int) error { // #nosec G201 err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", new(recovery.Flow).TableName(ctx), + new(recovery.Flow).TableName(ctx), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/persistence/sql/persister_registration.go b/persistence/sql/persister_registration.go index 90bcf8750a5..70684d87a07 100644 --- a/persistence/sql/persister_registration.go +++ b/persistence/sql/persister_registration.go @@ -37,13 +37,16 @@ func (p *Persister) GetRegistrationFlow(ctx context.Context, id uuid.UUID) (*reg return &r, nil } -func (p *Persister) DeleteExpiredRegistrationFlows(ctx context.Context, expiresAt time.Time) error { +func (p *Persister) DeleteExpiredRegistrationFlows(ctx context.Context, expiresAt time.Time, limit int) error { // #nosec G201 err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", new(registration.Flow).TableName(ctx), + new(registration.Flow).TableName(ctx), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/persistence/sql/persister_session.go b/persistence/sql/persister_session.go index cf9d5194527..95cdbc00f70 100644 --- a/persistence/sql/persister_session.go +++ b/persistence/sql/persister_session.go @@ -198,13 +198,15 @@ func (p *Persister) RevokeSessionsIdentityExcept(ctx context.Context, iID, sID u return count, nil } -func (p *Persister) DeleteExpiredSessions(ctx context.Context, expiresAt time.Time) error { - // #nosec G201 +func (p *Persister) DeleteExpiredSessions(ctx context.Context, expiresAt time.Time, limit int) error { err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", + corp.ContextualizeTableName(ctx, "sessions"), corp.ContextualizeTableName(ctx, "sessions"), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/persistence/sql/persister_settings.go b/persistence/sql/persister_settings.go index 4d7999e0f6d..c8e16e96a96 100644 --- a/persistence/sql/persister_settings.go +++ b/persistence/sql/persister_settings.go @@ -45,13 +45,16 @@ func (p *Persister) UpdateSettingsFlow(ctx context.Context, r *settings.Flow) er return p.update(ctx, cp) } -func (p *Persister) DeleteExpiredSettingsFlows(ctx context.Context, expiresAt time.Time) error { +func (p *Persister) DeleteExpiredSettingsFlows(ctx context.Context, expiresAt time.Time, limit int) error { // #nosec G201 err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", new(settings.Flow).TableName(ctx), + new(settings.Flow).TableName(ctx), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/persistence/sql/persister_test.go b/persistence/sql/persister_test.go index a5981de9add..456b808dae9 100644 --- a/persistence/sql/persister_test.go +++ b/persistence/sql/persister_test.go @@ -315,3 +315,12 @@ func TestPersister_Transaction(t *testing.T) { assert.Equal(t, sqlcon.ErrNoRows.Error(), err.Error()) }) } + +func TestPersister_Cleanup(t *testing.T) { + _, reg := internal.NewFastRegistryWithMocks(t) + p := reg.Persister() + + t.Run("case=should not throw error on cleanup", func(t *testing.T) { + assert.Nil(t, p.CleanupDatabase(context.Background(), 0, 0, reg.Config(context.Background()).DatabaseCleanupBatchSize())) + }) +} diff --git a/persistence/sql/persister_verification.go b/persistence/sql/persister_verification.go index 3c546ea816c..b0fbd90e511 100644 --- a/persistence/sql/persister_verification.go +++ b/persistence/sql/persister_verification.go @@ -96,13 +96,16 @@ func (p *Persister) DeleteVerificationToken(ctx context.Context, token string) e return p.GetConnection(ctx).RawQuery(fmt.Sprintf("DELETE FROM %s WHERE token=? AND nid = ?", new(link.VerificationToken).TableName(ctx)), token, nid).Exec() } -func (p *Persister) DeleteExpiredVerificationFlows(ctx context.Context, expiresAt time.Time) error { +func (p *Persister) DeleteExpiredVerificationFlows(ctx context.Context, expiresAt time.Time, limit int) error { // #nosec G201 err := p.GetConnection(ctx).RawQuery(fmt.Sprintf( - "DELETE FROM %s WHERE expires_at <= ?", + "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 )", new(verification.Flow).TableName(ctx), + new(verification.Flow).TableName(ctx), + limit, ), expiresAt, + corp.ContextualizeNID(ctx, p.nid), ).Exec() if err != nil { return sqlcon.HandleError(err) diff --git a/selfservice/flow/login/persistence.go b/selfservice/flow/login/persistence.go index e128d95cbee..fac9daab56e 100644 --- a/selfservice/flow/login/persistence.go +++ b/selfservice/flow/login/persistence.go @@ -13,7 +13,7 @@ type ( CreateLoginFlow(context.Context, *Flow) error GetLoginFlow(context.Context, uuid.UUID) (*Flow, error) ForceLoginFlow(ctx context.Context, id uuid.UUID) error - DeleteExpiredLoginFlows(context.Context, time.Time) error + DeleteExpiredLoginFlows(context.Context, time.Time, int) error } FlowPersistenceProvider interface { LoginFlowPersister() FlowPersister diff --git a/selfservice/flow/recovery/persistence.go b/selfservice/flow/recovery/persistence.go index fd44e2c8c5a..35f482cc329 100644 --- a/selfservice/flow/recovery/persistence.go +++ b/selfservice/flow/recovery/persistence.go @@ -12,7 +12,7 @@ type ( CreateRecoveryFlow(context.Context, *Flow) error GetRecoveryFlow(ctx context.Context, id uuid.UUID) (*Flow, error) UpdateRecoveryFlow(context.Context, *Flow) error - DeleteExpiredRecoveryFlows(context.Context, time.Time) error + DeleteExpiredRecoveryFlows(context.Context, time.Time, int) error } FlowPersistenceProvider interface { RecoveryFlowPersister() FlowPersister diff --git a/selfservice/flow/registration/persistence.go b/selfservice/flow/registration/persistence.go index 8f9a711ea98..f19965789a2 100644 --- a/selfservice/flow/registration/persistence.go +++ b/selfservice/flow/registration/persistence.go @@ -11,7 +11,7 @@ type FlowPersister interface { UpdateRegistrationFlow(context.Context, *Flow) error CreateRegistrationFlow(context.Context, *Flow) error GetRegistrationFlow(context.Context, uuid.UUID) (*Flow, error) - DeleteExpiredRegistrationFlows(context.Context, time.Time) error + DeleteExpiredRegistrationFlows(context.Context, time.Time, int) error } type FlowPersistenceProvider interface { diff --git a/selfservice/flow/settings/persistence.go b/selfservice/flow/settings/persistence.go index 9a3fdf5e4d5..fe7d78108f6 100644 --- a/selfservice/flow/settings/persistence.go +++ b/selfservice/flow/settings/persistence.go @@ -12,7 +12,7 @@ type ( CreateSettingsFlow(context.Context, *Flow) error GetSettingsFlow(ctx context.Context, id uuid.UUID) (*Flow, error) UpdateSettingsFlow(context.Context, *Flow) error - DeleteExpiredSettingsFlows(context.Context, time.Time) error + DeleteExpiredSettingsFlows(context.Context, time.Time, int) error } FlowPersistenceProvider interface { SettingsFlowPersister() FlowPersister diff --git a/selfservice/flow/verification/persistence.go b/selfservice/flow/verification/persistence.go index 96be1950036..f8898a1d71a 100644 --- a/selfservice/flow/verification/persistence.go +++ b/selfservice/flow/verification/persistence.go @@ -15,6 +15,6 @@ type ( CreateVerificationFlow(context.Context, *Flow) error GetVerificationFlow(ctx context.Context, id uuid.UUID) (*Flow, error) UpdateVerificationFlow(context.Context, *Flow) error - DeleteExpiredVerificationFlows(context.Context, time.Time) error + DeleteExpiredVerificationFlows(context.Context, time.Time, int) error } ) diff --git a/session/persistence.go b/session/persistence.go index ae1b75d588b..48bb98c7d6e 100644 --- a/session/persistence.go +++ b/session/persistence.go @@ -42,7 +42,7 @@ type Persister interface { GetSessionByToken(context.Context, string) (*Session, error) // DeleteExpiredSessions deletes sessions that expired before the given time. - DeleteExpiredSessions(context.Context, time.Time) error + DeleteExpiredSessions(context.Context, time.Time, int) error // DeleteSessionByToken deletes a session associated with the given token. //