Skip to content

Commit

Permalink
satellite/metabase: remove AOST from deleteInactiveObjectsAndSegments
Browse files Browse the repository at this point in the history
By mistake AOST was added to query in deleteInactiveObjectsAndSegments
in DeleteZombieObjects. Delete statement is not supporting it.
Unfortunately unit tests didn't cover this case. This change removes
AOST from mentioned method and it adding AOST cases to unit tests.

Change-Id: Ib7f65134290df08c490c96b7e367d12f497a3373
  • Loading branch information
mniewrzal committed Jun 28, 2023
1 parent 683f0c4 commit e129841
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions satellite/metabase/delete_objects.go
Expand Up @@ -249,7 +249,8 @@ func (db *DB) deleteInactiveObjectsAndSegments(ctx context.Context, objects []Ob
for _, obj := range objects {
batch.Queue(`
WITH check_segments AS (
SELECT 1 FROM segments WHERE stream_id = $5::BYTEA AND created_at > $6
SELECT 1 FROM segments
WHERE stream_id = $5::BYTEA AND created_at > $6
), deleted_objects AS (
DELETE FROM objects
WHERE
Expand All @@ -258,9 +259,7 @@ func (db *DB) deleteInactiveObjectsAndSegments(ctx context.Context, objects []Ob
RETURNING stream_id
)
DELETE FROM segments
`+db.impl.AsOfSystemInterval(opts.AsOfSystemInterval)+`
WHERE
segments.stream_id IN (SELECT stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT stream_id FROM deleted_objects)
`, obj.ProjectID, []byte(obj.BucketName), []byte(obj.ObjectKey), obj.Version, obj.StreamID, opts.InactiveDeadline)
}

Expand Down
5 changes: 3 additions & 2 deletions satellite/metabase/delete_objects_test.go
Expand Up @@ -332,8 +332,9 @@ func TestDeleteZombieObjects(t *testing.T) {
// object will be checked if is inactive and will be deleted with segment
metabasetest.DeleteZombieObjects{
Opts: metabase.DeleteZombieObjects{
DeadlineBefore: now.Add(1 * time.Hour),
InactiveDeadline: now.Add(2 * time.Hour),
DeadlineBefore: now.Add(1 * time.Hour),
InactiveDeadline: now.Add(2 * time.Hour),
AsOfSystemInterval: -1 * time.Microsecond,
},
}.Check(ctx, t, db)

Expand Down
2 changes: 1 addition & 1 deletion satellite/metabase/zombiedeletion/zombiedeletion_test.go
Expand Up @@ -27,7 +27,7 @@ func TestZombieDeletion(t *testing.T) {
Reconfigure: testplanet.Reconfigure{
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
config.ZombieDeletion.Interval = 500 * time.Millisecond
config.ZombieDeletion.AsOfSystemInterval = 0
config.ZombieDeletion.AsOfSystemInterval = -1 * time.Microsecond
},
},
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
Expand Down

0 comments on commit e129841

Please sign in to comment.