Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,12 @@ func (t *createSnapshotFromFilesystemTask) Run(

func (t *createSnapshotFromFilesystemTask) Cancel(
ctx context.Context,
execCtx tasks.ExecutionContext,
_ tasks.ExecutionContext,
) error {

_, err := t.storage.DeletingFilesystemSnapshot(
ctx,
t.request.GetSnapshotId(),
execCtx.GetTaskID(),
)
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,21 @@ func (t *deleteFilesystemSnapshotTask) Load(request, state []byte) error {

func (t *deleteFilesystemSnapshotTask) deleteFilesystemSnapshot(
ctx context.Context,
execCtx tasks.ExecutionContext,
) error {

_, err := t.storage.DeletingFilesystemSnapshot(
ctx,
t.request.SnapshotId,
execCtx.GetTaskID(),
)
return err
}

func (t *deleteFilesystemSnapshotTask) Run(
ctx context.Context,
execCtx tasks.ExecutionContext,
_ tasks.ExecutionContext,
) error {

err := t.deleteFilesystemSnapshot(ctx, execCtx)
err := t.deleteFilesystemSnapshot(ctx)
if err != nil {
return errors.NewRetriableErrorWithIgnoreRetryLimit(err)
}
Expand All @@ -62,10 +60,10 @@ func (t *deleteFilesystemSnapshotTask) Run(

func (t *deleteFilesystemSnapshotTask) Cancel(
ctx context.Context,
execCtx tasks.ExecutionContext,
_ tasks.ExecutionContext,
) error {

return t.deleteFilesystemSnapshot(ctx, execCtx)
return t.deleteFilesystemSnapshot(ctx)
}

func (t *deleteFilesystemSnapshotTask) GetMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ func (s *StorageMock) FilesystemSnapshotCreated(
func (s *StorageMock) DeletingFilesystemSnapshot(
ctx context.Context,
snapshotID string,
taskID string,
) (*storage.FilesystemSnapshotMeta, error) {

args := s.Called(ctx, snapshotID, taskID)
args := s.Called(ctx, snapshotID)
return args.Get(0).(*storage.FilesystemSnapshotMeta), args.Error(1)
}

Expand Down Expand Up @@ -99,23 +98,23 @@ func (s *StorageMock) GetTotalFilesystemSnapshotStorageSize(ctx context.Context)
return args.Get(0).(uint64), args.Error(1)
}

func (s *StorageMock) LockFilesystemSnapshot(
func (s *StorageMock) AcquireFilesystemSnapshotBarrier(
ctx context.Context,
snapshotID string,
lockTaskID string,
) (locked bool, err error) {
taskID string,
) error {

args := s.Called(ctx, snapshotID, lockTaskID)
return args.Get(0).(bool), args.Error(1)
args := s.Called(ctx, snapshotID, taskID)
return args.Error(0)
}

func (s *StorageMock) UnlockFilesystemSnapshot(
func (s *StorageMock) ReleaseFilesystemSnapshotBarrier(
ctx context.Context,
snapshotID string,
lockTaskID string,
taskID string,
) error {

args := s.Called(ctx, snapshotID, lockTaskID)
args := s.Called(ctx, snapshotID, taskID)
return args.Error(0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ func Create(
}
logging.Info(ctx, "Created filesystem_snapshots table")

err = db.CreateOrAlterTable(
ctx,
storageFolder,
"filesystem_snapshot_lock_holders",
persistence.NewCreateTableDescription(
persistence.WithColumn("snapshot_id", persistence.Optional(persistence.TypeUTF8)),
persistence.WithColumn("lock_task_id", persistence.Optional(persistence.TypeUTF8)),
persistence.WithPrimaryKeyColumn("snapshot_id", "lock_task_id"),
),
dropUnusedColumns,
)
if err != nil {
return err
}
logging.Info(ctx, "Created filesystem_snapshot_lock_holders table")

err = db.CreateOrAlterTable(
ctx,
storageFolder,
Expand Down Expand Up @@ -176,7 +192,13 @@ func Drop(

logging.Info(ctx, "Dropping schema for dataplane filesystem snapshot storage in %v", db.AbsolutePath(storageFolder))

err := db.DropTable(ctx, storageFolder, "filesystem_snapshots")
err := db.DropTable(ctx, storageFolder, "filesystem_snapshot_lock_holders")
if err != nil {
return err
}
logging.Info(ctx, "Dropped filesystem_snapshot_lock_holders table")

err = db.DropTable(ctx, storageFolder, "filesystem_snapshots")
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Storage interface {
DeletingFilesystemSnapshot(
ctx context.Context,
snapshotID string,
taskID string,
) (*FilesystemSnapshotMeta, error)

GetFilesystemSnapshotsToDelete(
Expand Down Expand Up @@ -77,16 +76,21 @@ type Storage interface {
ctx context.Context,
) (storageSize uint64, err error)

LockFilesystemSnapshot(
// AcquireFilesystemSnapshotBarrier joins taskID to the snapshot's shared
// deletion barrier. Repeated calls with the same taskID are idempotent.
AcquireFilesystemSnapshotBarrier(
ctx context.Context,
snapshotID string,
lockTaskID string,
) (locked bool, err error)
taskID string,
) error

UnlockFilesystemSnapshot(
// ReleaseFilesystemSnapshotBarrier removes taskID from the shared deletion
// barrier. It is idempotent, including for deleting or missing snapshots;
// deletion is unblocked after the last holder exits.
ReleaseFilesystemSnapshotBarrier(
ctx context.Context,
snapshotID string,
lockTaskID string,
taskID string,
) error

GetFilesystemSnapshotMeta(
Expand Down
Loading
Loading