Skip to content

Commit

Permalink
merge to stable-23-3: filestore - LargeDeletionMarkers-related follow…
Browse files Browse the repository at this point in the history
…up work, TFileRingBuffer, some small fixes and enhancements (#2183)

* unstable-process: logging open sockets upon process start failure (#2048)

* issue-1541: implemented a ring buffer over a file to use it in HandleOpsQueue (#2047)

* issue-1541: ring buffer over a file

* issue-1541: TFileRingBufferTest::Should{Restore,Validate} + fixes

* issue-1541: randomized test for TFileRingBuffer + fixes

* issue-1541: moved TFileRingBuffer implementation to .cpp

* issue-1541: minor rename

* issue-1541: fixed ubsan (#2087)

* NBS and Filestore cluster deployment instructions (#2094)

* issue-1795: LargeDeletionMarkers - simple integration test (#2122)

* fixed StatFs diagnostics RequestType (#2127)

* issue-1795: backpressure for LargeDeletionMarkers (#2147)

* issue-1795: LargeDeletionMarkers backpressure - some fixes and cleanup (#2160)

* filestore-client: fixed crashes on DestroySession error, fixed ls node type output (#2168)

* filestore-client: fixed crashes on DestroySession error, fixed ls node type output

* filestore-client: fixed crashes on DestroySession error, fixed ls node type output - cleanup

* issue-1795: implemented Unsafe{Delete,Update,Get}Node to use it in private api for manual interventions - e.g. to clean up OrphanNodes (#2165)

* issue-1795: implemented Unsafe{Delete,Update,Get}Node to use it in private api for manual interventions - e.g. to clean up OrphanNodes

* issue-1795: tiny cleanup

* issue-1795: private api Unsafe{Delete,Update,Get}Node actions + ut

* issue-1795: cleanup

* updated CMakeLists.txt after merge, fixed includes

* fixed CMakeLists.txt
  • Loading branch information
qkrorlqr authored Oct 1, 2024
1 parent cabb133 commit 7c4e200
Show file tree
Hide file tree
Showing 171 changed files with 8,353 additions and 111 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
## Network Block Store
## Network Block Store and Network File Store

Network Block Device implementation over YDB BlobStorage or over our own storage nodes. Offers reliable thin-provisioned block devices which support snapshots.
Network File System implementation over YDB BlobStorage. Offers POSIX-compliant scalable filesystem which can be attached to virtual machines via virtiofs or simply mounted via FUSE.

### Quickstart

Follow the instructions [here](example/README.md) to build and run NBS on your machine and to attach an NBS-based disk via NBD. NBS-based disks can be attached via vhost-user-blk as well.

Follow the instructions [here](cloud/filestore/README.md) to build and run Filestore on your machine and to attach it to a virtual machine via virtiofs or mount it on your host via FUSE.

Follow the instructions [here](CLANG-FORMAT.md) to install clang-format for formatting the code.

### How to Deploy

TODO
Follow the instructions [here](deploy/README.md) to deploy NBS and Filestore on a cluster.
13 changes: 12 additions & 1 deletion cloud/filestore/apps/client/lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class TCommand
return Opts;
}

TLog& AccessLog()
{
return Log;
}

protected:
virtual void Init();

Expand Down Expand Up @@ -177,16 +182,22 @@ class TFileStoreCommand
class TSessionGuard final
{
TFileStoreCommand& FileStoreCmd;
TLog& Log;

public:
explicit TSessionGuard(TFileStoreCommand& fileStoreCmd)
: FileStoreCmd(fileStoreCmd)
, Log(FileStoreCmd.AccessLog())
{
}

~TSessionGuard()
{
FileStoreCmd.DestroySession();
try {
FileStoreCmd.DestroySession();
} catch (...) {
STORAGE_ERROR("~TSessionGuard: " << CurrentExceptionMessage());
}
}
};

Expand Down
2 changes: 2 additions & 0 deletions cloud/filestore/apps/client/lib/ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ TString NodeTypeToString(NProto::ENodeType nodeType)
return "l";
case NProto::E_SOCK_NODE:
return "s";
case NProto::E_SYMLINK_NODE:
return "L";
default:
ythrow yexception() << "must be unreachable";
}
Expand Down
7 changes: 7 additions & 0 deletions cloud/filestore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,11 @@ message TStorageConfig
// automatically recover after various races that may happen during index
// tablet startup due to bugs.
optional uint32 MaxBackpressurePeriodBeforeSuicide = 392; // in ms

// settings for ydb config dispatcher service.
// optional NCloud.NProto.TConfigDispatcherSettings ConfigDispatcherSettings = 393;

// If the number of blocks marked for deletion via large deletion markers
// exceeds this threshold, large truncate-like operations will be rejected.
optional uint64 LargeDeletionMarkersThresholdForBackpressure = 394;
}
1 change: 1 addition & 0 deletions cloud/filestore/libs/diagnostics/critical_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace NCloud::NFileStore{
xxx(AsyncDestroyHandleFailed) \
xxx(DuplicateRequestId) \
xxx(InvalidDupCacheEntry) \
xxx(GeneratedOrphanNode) \
// FILESTORE_CRITICAL_EVENTS

#define FILESTORE_IMPOSSIBLE_EVENTS(xxx) \
Expand Down
12 changes: 12 additions & 0 deletions cloud/filestore/libs/storage/api/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ namespace NCloud::NFileStore::NStorage {
xxx(GetStorageConfig, __VA_ARGS__) \
xxx(GetNodeAttrBatch, __VA_ARGS__) \
xxx(WriteCompactionMap, __VA_ARGS__) \
xxx(UnsafeDeleteNode, __VA_ARGS__) \
xxx(UnsafeUpdateNode, __VA_ARGS__) \
xxx(UnsafeGetNode, __VA_ARGS__) \
// FILESTORE_TABLET_REQUESTS

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -97,6 +100,15 @@ struct TEvIndexTablet
EvWriteCompactionMapRequest = EvBegin + 33,
EvWriteCompactionMapResponse,

EvUnsafeDeleteNodeRequest = EvBegin + 35,
EvUnsafeDeleteNodeResponse,

EvUnsafeUpdateNodeRequest = EvBegin + 37,
EvUnsafeUpdateNodeResponse,

EvUnsafeGetNodeRequest = EvBegin + 39,
EvUnsafeGetNodeResponse,

EvEnd
};

Expand Down
11 changes: 6 additions & 5 deletions cloud/filestore/libs/storage/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ using TAliases = NProto::TStorageConfig::TFilestoreAliases;
xxx(MaxBlocksPerTruncateTx, ui32, 0 /*TODO: 32GiB/4KiB*/ )\
xxx(MaxTruncateTxInflight, ui32, 10 )\
\
xxx(MaxFileBlocks, ui32, 300_GB / 4_KB )\
xxx(LargeDeletionMarkersEnabled, bool, false )\
xxx(LargeDeletionMarkerBlocks, ui64, 1_GB / 4_KB )\
xxx(LargeDeletionMarkersThreshold, ui64, 128_GB / 4_KB )\
xxx(LargeDeletionMarkersCleanupThreshold, ui64, 1_TB / 4_KB )\
xxx(MaxFileBlocks, ui32, 300_GB / 4_KB )\
xxx(LargeDeletionMarkersEnabled, bool, false )\
xxx(LargeDeletionMarkerBlocks, ui64, 1_GB / 4_KB )\
xxx(LargeDeletionMarkersThreshold, ui64, 128_GB / 4_KB )\
xxx(LargeDeletionMarkersCleanupThreshold, ui64, 1_TB / 4_KB )\
xxx(LargeDeletionMarkersThresholdForBackpressure, ui64, 10_TB / 4_KB )\
\
xxx(CompactionRetryTimeout, TDuration, TDuration::Seconds(1) )\
xxx(BlobIndexOpsPriority, \
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class TStorageConfig
ui64 GetLargeDeletionMarkerBlocks() const;
ui64 GetLargeDeletionMarkersThreshold() const;
ui64 GetLargeDeletionMarkersCleanupThreshold() const;
ui64 GetLargeDeletionMarkersThresholdForBackpressure() const;

bool GetMultipleStageRequestThrottlingEnabled() const;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_unsafe_node_ops.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_unsafe_node_ops.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_unsafe_node_ops.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_unsafe_node_ops.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
Expand Down
12 changes: 12 additions & 0 deletions cloud/filestore/libs/storage/service/service_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ class TStorageServiceActor final
TRequestInfoPtr requestInfo,
TString input);

NActors::IActorPtr CreateUnsafeDeleteNodeActionActor(
TRequestInfoPtr requestInfo,
TString input);

NActors::IActorPtr CreateUnsafeUpdateNodeActionActor(
TRequestInfoPtr requestInfo,
TString input);

NActors::IActorPtr CreateUnsafeGetNodeActionActor(
TRequestInfoPtr requestInfo,
TString input);

private:
void RenderSessions(IOutputStream& out);
void RenderLocalFileStores(IOutputStream& out);
Expand Down
12 changes: 12 additions & 0 deletions cloud/filestore/libs/storage/service/service_actor_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ void TStorageServiceActor::HandleExecuteAction(
"writecompactionmap",
&TStorageServiceActor::CreateWriteCompactionMapActionActor
},
{
"unsafedeletenode",
&TStorageServiceActor::CreateUnsafeDeleteNodeActionActor
},
{
"unsafeupdatenode",
&TStorageServiceActor::CreateUnsafeUpdateNodeActionActor
},
{
"unsafegetnode",
&TStorageServiceActor::CreateUnsafeGetNodeActionActor
},
};

auto it = actions.find(action);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#include "service_actor.h"

#include <cloud/filestore/libs/storage/api/service.h>
#include <cloud/filestore/libs/storage/api/tablet.h>
#include <cloud/filestore/libs/storage/api/tablet_proxy.h>
#include <cloud/filestore/libs/storage/core/public.h>
#include <cloud/filestore/private/api/protos/tablet.pb.h>

#include <library/cpp/actors/core/actor_bootstrapped.h>

#include <google/protobuf/util/json_util.h>

namespace NCloud::NFileStore::NStorage {

using namespace NActors;

using namespace NKikimr;

namespace {

////////////////////////////////////////////////////////////////////////////////

template <typename TRequest, typename TResponse>
class TTabletActionActor final
: public TActorBootstrapped<TTabletActionActor<TRequest, TResponse>>
{
private:
const TRequestInfoPtr RequestInfo;
const TString Input;

using TBase = TActorBootstrapped<TTabletActionActor<TRequest, TResponse>>;

public:
TTabletActionActor(
TRequestInfoPtr requestInfo,
TString input);

void Bootstrap(const TActorContext& ctx);

private:
void ReplyAndDie(
const TActorContext& ctx,
const TResponse::ProtoRecordType& responseRecord);

private:
STFUNC(StateWork)
{
switch (ev->GetTypeRewrite()) {
HFunc(TResponse, HandleResponse);

default:
HandleUnexpectedEvent(ev, TFileStoreComponents::SERVICE);
break;
}
}

void HandleResponse(const TResponse::TPtr& ev, const TActorContext& ctx);
};

////////////////////////////////////////////////////////////////////////////////

template <typename TRequest, typename TResponse>
TTabletActionActor<TRequest, TResponse>::TTabletActionActor(
TRequestInfoPtr requestInfo,
TString input)
: RequestInfo(std::move(requestInfo))
, Input(std::move(input))
{}

template <typename TRequest, typename TResponse>
void TTabletActionActor<TRequest, TResponse>::Bootstrap(
const TActorContext& ctx)
{
typename TRequest::ProtoRecordType request;
if (!google::protobuf::util::JsonStringToMessage(Input, &request).ok()) {
ReplyAndDie(
ctx,
TErrorResponse(E_ARGUMENT, "Failed to parse input"));
return;
}

if (!request.GetFileSystemId()) {
ReplyAndDie(
ctx,
TErrorResponse(E_ARGUMENT, "FileSystem id should be supplied"));
return;
}

auto requestToTablet = std::make_unique<TRequest>();
requestToTablet->Record = std::move(request);

NCloud::Send(
ctx,
MakeIndexTabletProxyServiceId(),
std::move(requestToTablet));

TBase::Become(&TTabletActionActor<TRequest, TResponse>::StateWork);
}

template <typename TRequest, typename TResponse>
void TTabletActionActor<TRequest, TResponse>::ReplyAndDie(
const TActorContext& ctx,
const TResponse::ProtoRecordType& response)
{
auto msg = std::make_unique<TEvService::TEvExecuteActionResponse>(
response.GetError());

google::protobuf::util::MessageToJsonString(
response,
msg->Record.MutableOutput());

NCloud::Reply(ctx, *RequestInfo, std::move(msg));
TBase::Die(ctx);
}

////////////////////////////////////////////////////////////////////////////////

template <typename TRequest, typename TResponse>
void TTabletActionActor<TRequest, TResponse>::HandleResponse(
const TResponse::TPtr& ev,
const TActorContext& ctx)
{
ReplyAndDie(ctx, ev->Get()->Record);
}

} // namespace

IActorPtr TStorageServiceActor::CreateUnsafeDeleteNodeActionActor(
TRequestInfoPtr requestInfo,
TString input)
{
using TUnsafeDeleteNodeActor = TTabletActionActor<
TEvIndexTablet::TEvUnsafeDeleteNodeRequest,
TEvIndexTablet::TEvUnsafeDeleteNodeResponse>;
return std::make_unique<TUnsafeDeleteNodeActor>(
std::move(requestInfo),
std::move(input));
}

IActorPtr TStorageServiceActor::CreateUnsafeUpdateNodeActionActor(
TRequestInfoPtr requestInfo,
TString input)
{
using TUnsafeUpdateNodeActor = TTabletActionActor<
TEvIndexTablet::TEvUnsafeUpdateNodeRequest,
TEvIndexTablet::TEvUnsafeUpdateNodeResponse>;
return std::make_unique<TUnsafeUpdateNodeActor>(
std::move(requestInfo),
std::move(input));
}

IActorPtr TStorageServiceActor::CreateUnsafeGetNodeActionActor(
TRequestInfoPtr requestInfo,
TString input)
{
using TUnsafeGetNodeActor = TTabletActionActor<
TEvIndexTablet::TEvUnsafeGetNodeRequest,
TEvIndexTablet::TEvUnsafeGetNodeResponse>;
return std::make_unique<TUnsafeGetNodeActor>(
std::move(requestInfo),
std::move(input));
}

} // namespace NCloud::NFileStore::NStorage
Loading

0 comments on commit 7c4e200

Please sign in to comment.