Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NBS-4773 [blockstore] Fix checkpoint without data creation #738

Merged
merged 4 commits into from
Mar 18, 2024
Merged
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
11 changes: 9 additions & 2 deletions cloud/blockstore/libs/storage/volume/testlib/test_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,18 @@ std::unique_ptr<TEvVolume::TEvDescribeBlocksRequest> TVolumeClient::CreateDescri
std::unique_ptr<TEvService::TEvCreateCheckpointRequest>
TVolumeClient::CreateCreateCheckpointRequest(
const TString& checkpointId,
bool isLight)
bool isLight,
bool withoutData)
{
auto request = std::make_unique<TEvService::TEvCreateCheckpointRequest>();
request->Record.SetCheckpointId(checkpointId);
request->Record.SetIsLight(isLight);
if (withoutData) {
request->Record.SetCheckpointType(NProto::ECheckpointType::WITHOUT_DATA);
} else if (isLight) {
request->Record.SetCheckpointType(NProto::ECheckpointType::LIGHT);
} else {
request->Record.SetCheckpointType(NProto::ECheckpointType::NORMAL);
}
return request;
}

Expand Down
3 changes: 2 additions & 1 deletion cloud/blockstore/libs/storage/volume/testlib/test_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ class TVolumeClient

std::unique_ptr<TEvService::TEvCreateCheckpointRequest> CreateCreateCheckpointRequest(
const TString& checkpointId,
bool isLight = false);
drbasic marked this conversation as resolved.
Show resolved Hide resolved
bool isLight = false,
bool withoutData = false);

std::unique_ptr<TEvService::TEvDeleteCheckpointRequest> CreateDeleteCheckpointRequest(
const TString& checkpointId);
Expand Down
14 changes: 14 additions & 0 deletions cloud/blockstore/libs/storage/volume/volume_actor_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class TCheckpointActor final
const TActorId VolumeActorId;
leftmain marked this conversation as resolved.
Show resolved Hide resolved
const TPartitionDescrs PartitionDescrs;
const TRequestTraceInfo TraceInfo;
const ECheckpointRequestType RequestType;
const bool CreateCheckpointShadowDisk;

ui32 DrainResponses = 0;
Expand All @@ -156,6 +157,7 @@ class TCheckpointActor final
TActorId volumeActorId,
TPartitionDescrs partitionDescrs,
TRequestTraceInfo traceInfo,
ECheckpointRequestType requestType,
bool createCheckpointShadowDisk);

void Bootstrap(const TActorContext& ctx);
Expand Down Expand Up @@ -228,6 +230,7 @@ TCheckpointActor<TMethod>::TCheckpointActor(
TActorId volumeActorId,
TPartitionDescrs partitionDescrs,
TRequestTraceInfo traceInfo,
ECheckpointRequestType requestType,
bool createCheckpointShadowDisk)
: RequestInfo(std::move(requestInfo))
, RequestId(requestId)
Expand All @@ -237,6 +240,7 @@ TCheckpointActor<TMethod>::TCheckpointActor(
, VolumeActorId(volumeActorId)
, PartitionDescrs(std::move(partitionDescrs))
, TraceInfo(std::move(traceInfo))
, RequestType(requestType)
, CreateCheckpointShadowDisk(createCheckpointShadowDisk)
, ChildCallContexts(Reserve(PartitionDescrs.size()))
{}
Expand Down Expand Up @@ -687,6 +691,13 @@ void TCheckpointActor<TMethod>::DoActionForBlobStorageBasedPartition(
const auto selfId = TBase::SelfId();
auto request = std::make_unique<typename TMethod::TRequest>();
request->Record.SetCheckpointId(CheckpointId);
if constexpr (std::is_same_v<TMethod, TCreateCheckpointMethod>) {
request->Record.SetCheckpointType(
leftmain marked this conversation as resolved.
Show resolved Hide resolved
RequestType == ECheckpointRequestType::CreateWithoutData
? NProto::ECheckpointType::WITHOUT_DATA
: NProto::ECheckpointType::NORMAL
);
}

ForkTraces(request->CallContext);

Expand Down Expand Up @@ -1155,6 +1166,7 @@ void TVolumeActor::ProcessNextCheckpointRequest(const TActorContext& ctx)
requestInfo->IsTraced,
requestInfo->TraceTs,
TraceSerializer),
request.ReqType,
Config->GetUseShadowDisksForNonreplDiskCheckpoints());
break;
}
Expand All @@ -1179,6 +1191,7 @@ void TVolumeActor::ProcessNextCheckpointRequest(const TActorContext& ctx)
requestInfo->IsTraced,
requestInfo->TraceTs,
TraceSerializer),
request.ReqType,
Config->GetUseShadowDisksForNonreplDiskCheckpoints());
break;
}
Expand All @@ -1197,6 +1210,7 @@ void TVolumeActor::ProcessNextCheckpointRequest(const TActorContext& ctx)
requestInfo->IsTraced,
requestInfo->TraceTs,
TraceSerializer),
request.ReqType,
Config->GetUseShadowDisksForNonreplDiskCheckpoints());
break;
}
Expand Down
68 changes: 68 additions & 0 deletions cloud/blockstore/libs/storage/volume/volume_ut_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,74 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
}
}

Y_UNIT_TEST(ShouldNotReadFromCheckpointWithoutData)
{
leftmain marked this conversation as resolved.
Show resolved Hide resolved
NProto::TStorageServiceConfig config;
auto runtime = PrepareTestActorRuntime(config);

TVolumeClient volume(*runtime);
volume.UpdateVolumeConfig();

volume.WaitReady();

auto clientInfo = CreateVolumeClientInfo(
NProto::VOLUME_ACCESS_READ_WRITE,
NProto::VOLUME_MOUNT_LOCAL,
0);
volume.AddClient(clientInfo);

volume.WriteBlocks(
TBlockRange64::WithLength(0, 1024),
clientInfo.GetClientId(),
1);
volume.CreateCheckpoint("c1", false, true);
volume.WriteBlocks(
TBlockRange64::WithLength(0, 1024),
clientInfo.GetClientId(),
2);

{
// Read from checkpoint without data failed
volume.SendReadBlocksRequest(
GetBlockRangeById(0),
clientInfo.GetClientId(),
"c1");

auto response = volume.RecvReadBlocksResponse();
UNIT_ASSERT_VALUES_EQUAL(E_NOT_FOUND, response->GetStatus());
UNIT_ASSERT_VALUES_EQUAL(
"checkpoint not found: \"c1\"",
response->GetError().GetMessage());
UNIT_ASSERT(HasProtoFlag(
response->GetError().GetFlags(),
NProto::EF_SILENT));
}

volume.CreateCheckpoint("c2");
volume.DeleteCheckpointData("c2");
volume.WriteBlocks(
TBlockRange64::WithLength(0, 1024),
clientInfo.GetClientId(),
2);

{
// Read from checkpoint without data failed
volume.SendReadBlocksRequest(
GetBlockRangeById(0),
clientInfo.GetClientId(),
"c2");

auto response = volume.RecvReadBlocksResponse();
UNIT_ASSERT_VALUES_EQUAL(E_NOT_FOUND, response->GetStatus());
UNIT_ASSERT_VALUES_EQUAL(
"checkpoint not found: \"c2\"",
response->GetError().GetMessage());
UNIT_ASSERT(HasProtoFlag(
response->GetError().GetFlags(),
NProto::EF_SILENT));
}
}

Y_UNIT_TEST(ShouldNotRejectRZRequestsDuringSinglePartionCheckpointCreation)
{
NProto::TStorageServiceConfig config;
Expand Down