satellite/metabase: remove AOST from deleteInactiveObjectsAndSegments
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
This commit is contained in:
parent
683f0c493f
commit
e129841130
@ -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
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user