Skip to content

Commit

Permalink
NBS-4827 Fix review issues and tests flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
drbasic committed Mar 15, 2024
1 parent 45142c4 commit 3094168
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cloud/blockstore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ message TStorageServiceConfig
optional string CachedDiskAgentSessionsPath = 351;

// Max bandwidth used for shadow disk fill in MiB/s (actual bandwidth is x2
// due to the need to read and write).
// due to the need to read and write).
optional uint32 MaxShadowDiskFillBandwidth = 352;
// Minimum delay between shadow disk acquire attempts when writes to the
// source disk are blocked (in ms).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ TMigrationTimeoutCalculator::TMigrationTimeoutCalculator(
TDuration TMigrationTimeoutCalculator::CalculateTimeout(
TBlockRange64 nextProcessingRange) const
{

// migration range is 4_MB
const auto migrationFactorPerAgent = MaxMigrationBandwidthMiBs / 4;
const auto migrationFactorPerAgent = MaxMigrationBandwidthMiBs / 4.0;

if (PartitionConfig->GetUseSimpleMigrationBandwidthLimiter()) {
return TDuration::Seconds(1) / migrationFactorPerAgent;
Expand All @@ -41,7 +40,7 @@ TDuration TMigrationTimeoutCalculator::CalculateTimeout(

const auto factor =
Max(migrationFactorPerAgent * agentDeviceCount / ExpectedDiskAgentSize,
1U);
1.0);

return TDuration::Seconds(1) / factor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TAcquireShadowDiskActor
const TDevices& shadowDiskDevices,
TShadowDiskActor::EAcquireReason acquireReason,
bool readOlyMount,
bool isWritesToSourceBlocked,
bool areWritesToSourceBlocked,
ui64 mountSeqNumber,
ui32 generation,
TActorId parentActor);
Expand Down Expand Up @@ -153,26 +153,26 @@ TAcquireShadowDiskActor::TAcquireShadowDiskActor(
const TDevices& shadowDiskDevices,
TShadowDiskActor::EAcquireReason acquireReason,
bool readOnlyMount,
bool isWritesToSourceBlocked,
bool areWritesToSourceBlocked,
ui64 mountSeqNumber,
ui32 generation,
TActorId parentActor)
: ShadowDiskId(std::move(shadowDiskId))
, AcquireReason(acquireReason)
, ReadOnlyMount(readOnlyMount)
, TotalTimeout(
isWritesToSourceBlocked
areWritesToSourceBlocked
? config->GetMaxAcquireShadowDiskTotalTimeoutWhenBlocked()
: config->GetMaxAcquireShadowDiskTotalTimeoutWhenNonBlocked())
, ParentActor(parentActor)
, MountSeqNumber(mountSeqNumber)
, Generation(generation)
, ShadowDiskDevices(shadowDiskDevices)
, RetryDelayProvider(
isWritesToSourceBlocked
areWritesToSourceBlocked
? config->GetMinAcquireShadowDiskRetryDelayWhenBlocked()
: config->GetMinAcquireShadowDiskRetryDelayWhenNonBlocked(),
isWritesToSourceBlocked
areWritesToSourceBlocked
? config->GetMaxAcquireShadowDiskRetryDelayWhenBlocked()
: config->GetMaxAcquireShadowDiskRetryDelayWhenNonBlocked())
{
Expand Down Expand Up @@ -768,8 +768,6 @@ void TShadowDiskActor::CreateShadowDiskPartitionActor(
PoisonPillHelper.TakeOwnership(ctx, DstActorId);

if (State == EActorState::WaitAcquireForRead) {
STORAGE_CHECK_PRECONDITION(Acquired());

// Ready to serve checkpoint reads.
State = EActorState::CheckpointReady;
} else {
Expand All @@ -779,7 +777,6 @@ void TShadowDiskActor::CreateShadowDiskPartitionActor(

// Ready to fill shadow disk with data.
State = EActorState::Preparing;
STORAGE_CHECK_PRECONDITION(Acquired());

TNonreplicatedPartitionMigrationCommonActor::InitWork(
ctx,
Expand All @@ -798,6 +795,7 @@ void TShadowDiskActor::CreateShadowDiskPartitionActor(
SrcConfig->GetBlockCount()));
}

STORAGE_CHECK_PRECONDITION(Acquired());
SchedulePeriodicalReAcquire(ctx);
}

Expand Down
13 changes: 6 additions & 7 deletions cloud/blockstore/libs/storage/volume/actors/shadow_disk_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <contrib/ydb/library/actors/core/actor_bootstrapped.h>
#include <contrib/ydb/library/actors/core/events.h>
#include <contrib/ydb/library/actors/interconnect/types.h>

namespace NCloud::NBlockStore::NStorage {

Expand Down Expand Up @@ -91,17 +90,17 @@ class TShadowDiskActor final
const TString ShadowDiskId;
const ui64 MountSeqNumber = 0;
const ui32 Generation = 0;
const TActorId VolumeActorId;
const TActorId SrcActorId;
const NActors::TActorId VolumeActorId;
const NActors::TActorId SrcActorId;

TNonreplicatedPartitionConfigPtr DstConfig;
TActorId DstActorId;
NActors::TActorId DstActorId;
ui64 ProcessedBlockCount = 0;

EActorState State = EActorState::Error;
std::optional<TMigrationTimeoutCalculator> TimeoutCalculator;

TActorId AcquireActorId;
NActors::TActorId AcquireActorId;
// The list of devices received on first acquire.
TDevices ShadowDiskDevices;

Expand All @@ -117,8 +116,8 @@ class TShadowDiskActor final
ui64 mountSeqNumber,
ui32 generation,
TNonreplicatedPartitionConfigPtr srcConfig,
TActorId volumeActorId,
TActorId srcActorId,
NActors::TActorId volumeActorId,
NActors::TActorId srcActorId,
const TActiveCheckpointInfo& checkpointInfo);

~TShadowDiskActor() override;
Expand Down
12 changes: 11 additions & 1 deletion cloud/blockstore/libs/storage/volume/volume_ut_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3359,12 +3359,18 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
NCloud::NProto::STORAGE_MEDIA_SSD_NONREPLICATED);
}

Y_UNIT_TEST(ShouldCreateCheckpointWithShadowDiskMirror)
Y_UNIT_TEST(ShouldCreateCheckpointWithShadowDiskMirror2)
{
DoShouldCreateCheckpointWithShadowDisk(
NCloud::NProto::STORAGE_MEDIA_SSD_MIRROR2);
}

Y_UNIT_TEST(ShouldCreateCheckpointWithShadowDiskMirror3)
{
DoShouldCreateCheckpointWithShadowDisk(
NCloud::NProto::STORAGE_MEDIA_SSD_MIRROR3);
}

Y_UNIT_TEST(ShouldCreateCheckpointWithShadowDiskHddNonrepl)
{
DoShouldCreateCheckpointWithShadowDisk(
Expand Down Expand Up @@ -3553,6 +3559,7 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
{
NProto::TStorageServiceConfig config;
config.SetUseShadowDisksForNonreplDiskCheckpoints(true);
config.SetMaxShadowDiskFillBandwidth(1);
auto runtime = PrepareTestActorRuntime(config);

const ui64 expectedBlockCount = 32768;
Expand Down Expand Up @@ -3631,6 +3638,7 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
expectedBlockCount);

volume.SendToPipe(std::move(request));
runtime->DispatchEvents({}, TDuration::MilliSeconds(100));
}

// Steal the acquire response.
Expand Down Expand Up @@ -3675,6 +3683,7 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
{
NProto::TStorageServiceConfig config;
config.SetUseShadowDisksForNonreplDiskCheckpoints(true);
config.SetMaxShadowDiskFillBandwidth(1);
config.SetMaxAcquireShadowDiskTotalTimeoutWhenBlocked(5000);
auto runtime = PrepareTestActorRuntime(config);

Expand Down Expand Up @@ -3740,6 +3749,7 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
expectedBlockCount);

volume.SendToPipe(std::move(request));
runtime->DispatchEvents({}, TDuration::MilliSeconds(100));
}

// Steal the acquire response.
Expand Down

0 comments on commit 3094168

Please sign in to comment.