Skip to content

Commit

Permalink
merge to stable-23-3: filestore-vhost local mode + async read/write i…
Browse files Browse the repository at this point in the history
…n local service; lazy filestore counters init; support for large unaligned writes in ThreeStageWrite mode (#1770)

* issue-1668: TLocalFileSystem::ReadDataAsync/WriteDataAsync  (#1686)

* issue-1668: preparing to make TLocalFileSystem::ReadData/ReadData async

* issue-1668: preparing to make TLocalFileSystem::ReadData/ReadData async - fix

* issue-1668: fixed LocalService double start, fixed missing xattr error code

* issue-1668: LocalService now uses TFileHandle instead of TFile; LocalService now uses libaio instead of synchronous pread/pwrite for ReadData/WriteData calls; added move assignment operator to TFileHandle

* issue-1668: fixed LocalService ut

* issue-1350: GetNodeAttrBatchEnabled: true for multitablet filestore tests (#1706)

* issue-1161: not generating deletion markers upon symlink removal (#1707)

* issue-1161: not initializing most of the per-filesystem request counters until we actually receive at least 1 request of the type (#1711)

* issue-1161: fixed stupid lazy counter init race (#1722)

* issue-1673: Unaligned requests support in ThreeStageWrite pipeline - IndexTablet part (#1740)

* issue-1673: UnalignedDataParts support in TIndexTabletActor::AddData, TODO: uts

* issue-1673: AddData now properly handles outdated UnalignedDataParts

* issue-1673: AddData + UnalignedDataParts ut

* issue-1673: AddData + UnalignedDataParts: using CommitId, generated in AddBlobTx (since the same CommitId is used for the blobs), adding some checks (#1754)

* issue-1673: AddData + UnalignedDataParts: using CommitId, generated in AddBlobTx (since the same CommitId is used for the blobs), adding some checks

* issue-1673: AddData + UnalignedDataParts: better error processing and logging, fixed ut

* issue-1673: supported ThreeStageWrites for large unaligned requests in StorageServiceActor (#1769)

* issue-1673: supported ThreeStageWrites for large unaligned requests in StorageServiceActor

* issue-1673: supported ThreeStageWrites for large unaligned requests in StorageServiceActor - fixed logging

* updated CMakeLists after merge
  • Loading branch information
qkrorlqr authored Aug 11, 2024
1 parent 9fac18b commit 5e607ad
Show file tree
Hide file tree
Showing 62 changed files with 1,107 additions and 265 deletions.
3 changes: 3 additions & 0 deletions cloud/filestore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,7 @@ message TStorageConfig
// Blob compression experiment params.
optional uint32 BlobCompressionRate = 364;
optional string BlobCompressionCodec = 365;

// Enables ThreeStageWrite for unaligned requests.
optional bool UnalignedThreeStageWriteEnabled = 366;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_link_libraries(filestore-libs-daemon-common PUBLIC
filestore-libs-service
filestore-libs-storage-core
libs-storage-init
core-libs-aio
core-libs-common
core-libs-daemon
core-libs-diagnostics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target_link_libraries(filestore-libs-daemon-common PUBLIC
filestore-libs-service
filestore-libs-storage-core
libs-storage-init
core-libs-aio
core-libs-common
core-libs-daemon
core-libs-diagnostics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target_link_libraries(filestore-libs-daemon-common PUBLIC
filestore-libs-service
filestore-libs-storage-core
libs-storage-init
core-libs-aio
core-libs-common
core-libs-daemon
core-libs-diagnostics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target_link_libraries(filestore-libs-daemon-common PUBLIC
filestore-libs-service
filestore-libs-storage-core
libs-storage-init
core-libs-aio
core-libs-common
core-libs-daemon
core-libs-diagnostics
Expand Down
6 changes: 6 additions & 0 deletions cloud/filestore/libs/daemon/common/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <cloud/filestore/libs/storage/core/config.h>
#include <cloud/filestore/libs/storage/init/actorsystem.h>

#include <cloud/storage/core/libs/aio/service.h>
#include <cloud/storage/core/libs/common/file_io_service.h>
#include <cloud/storage/core/libs/common/scheduler.h>
#include <cloud/storage/core/libs/common/task_queue.h>
#include <cloud/storage/core/libs/common/thread_pool.h>
Expand Down Expand Up @@ -116,6 +118,7 @@ void TBootstrapCommon::Start()
{
FILESTORE_LOG_START_COMPONENT(Logging);
FILESTORE_LOG_START_COMPONENT(Monitoring);
FILESTORE_LOG_START_COMPONENT(FileIOService);
FILESTORE_LOG_START_COMPONENT(Metrics);
FILESTORE_LOG_START_COMPONENT(TraceProcessor);
FILESTORE_LOG_START_COMPONENT(TraceSerializer);
Expand Down Expand Up @@ -160,6 +163,7 @@ void TBootstrapCommon::Stop()
FILESTORE_LOG_STOP_COMPONENT(TraceSerializer);
FILESTORE_LOG_STOP_COMPONENT(TraceProcessor);
FILESTORE_LOG_STOP_COMPONENT(Metrics);
FILESTORE_LOG_STOP_COMPONENT(FileIOService);
FILESTORE_LOG_STOP_COMPONENT(Monitoring);
FILESTORE_LOG_STOP_COMPONENT(Logging);
}
Expand Down Expand Up @@ -216,6 +220,8 @@ void TBootstrapCommon::Init()
InitActorSystem();
}

FileIOService = CreateAIOService();

InitDiagnostics();
InitComponents();

Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/libs/daemon/common/bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TBootstrapCommon
ISchedulerPtr BackgroundScheduler;
ILoggingServicePtr Logging;
IMonitoringServicePtr Monitoring;
IFileIOServicePtr FileIOService;
NMetrics::IMetricsServicePtr Metrics;
IRequestStatsRegistryPtr StatsRegistry;
IStatsUpdaterPtr RequestStatsUpdater;
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/libs/daemon/common/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PEERDIR(
cloud/filestore/libs/storage/core
cloud/filestore/libs/storage/init

cloud/storage/core/libs/aio
cloud/storage/core/libs/common
cloud/storage/core/libs/daemon
cloud/storage/core/libs/diagnostics
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/libs/daemon/server/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ void TBootstrapServer::InitLocalService()
Timer,
Scheduler,
Logging,
FileIOService,
ThreadPool);
}

Expand Down
5 changes: 3 additions & 2 deletions cloud/filestore/libs/daemon/vhost/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ void TBootstrapVhost::InitEndpoints()
Timer,
Scheduler,
Logging,
FileIOService,
ThreadPool);

STORAGE_INFO("initialized LocalService: %s",
Expand Down Expand Up @@ -375,7 +376,7 @@ void TBootstrapVhost::StartComponents()
NVhost::StartServer();

FILESTORE_LOG_START_COMPONENT(ThreadPool);
FILESTORE_LOG_START_COMPONENT(LocalService);
// LocalService is started inside FileStoreEndpoints
FILESTORE_LOG_START_COMPONENT(FileStoreEndpoints);
FILESTORE_LOG_START_COMPONENT(EndpointManager);
FILESTORE_LOG_START_COMPONENT(Server);
Expand All @@ -390,7 +391,7 @@ void TBootstrapVhost::StopComponents()
FILESTORE_LOG_STOP_COMPONENT(Server);
FILESTORE_LOG_STOP_COMPONENT(EndpointManager);
FILESTORE_LOG_STOP_COMPONENT(FileStoreEndpoints);
FILESTORE_LOG_STOP_COMPONENT(LocalService);
// LocalService is stopped inside FileStoreEndpoints
FILESTORE_LOG_STOP_COMPONENT(ThreadPool);

NVhost::StopServer();
Expand Down
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 @@ -33,6 +33,7 @@ namespace NCloud::NFileStore{
xxx(ChildRefIsNull) \
xxx(NewChildNodeIsNull) \
xxx(IndexOutOfBounds) \
xxx(CheckFreshBytesFailed) \
// FILESTORE_IMPOSSIBLE_EVENTS

////////////////////////////////////////////////////////////////////////////////
Expand Down
27 changes: 20 additions & 7 deletions cloud/filestore/libs/diagnostics/request_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ bool IsReadWriteRequest(EFileStoreRequest rt)
|| rt == EFileStoreRequest::ReadData;
}

const auto REQUEST_COUNTERS_OPTIONS =
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::ReportControlPlaneHistogram;

TRequestCountersPtr MakeRequestCounters(
ITimerPtr timer,
TDynamicCounters& counters)
TDynamicCounters& counters,
TRequestCounters::EOptions options)
{
auto requestCounters = std::make_shared<TRequestCounters>(
std::move(timer),
Expand All @@ -51,8 +56,7 @@ TRequestCountersPtr MakeRequestCounters(
[] (TRequestCounters::TRequestType t) {
return IsReadWriteRequest(static_cast<EFileStoreRequest>(t));
},
TRequestCounters::EOption::ReportDataPlaneHistogram |
TRequestCounters::EOption::ReportControlPlaneHistogram
options
);
requestCounters->Register(counters);
return requestCounters;
Expand Down Expand Up @@ -157,13 +161,18 @@ class TRequestStats final
TDuration totalTimeThreshold)
: TRequestLogger(executionTimeThreshold, totalTimeThreshold)
, RootCounters(std::move(counters))
, TotalCounters(MakeRequestCounters(timer, *RootCounters))
, TotalCounters(MakeRequestCounters(
timer,
*RootCounters,
REQUEST_COUNTERS_OPTIONS))
, SsdCounters(MakeRequestCounters(
timer,
*RootCounters->GetSubgroup("type", "ssd")))
*RootCounters->GetSubgroup("type", "ssd"),
REQUEST_COUNTERS_OPTIONS))
, HddCounters(MakeRequestCounters(
timer,
*RootCounters->GetSubgroup("type", "hdd")))
*RootCounters->GetSubgroup("type", "hdd"),
REQUEST_COUNTERS_OPTIONS))
{
auto revisionGroup =
RootCounters->GetSubgroup("revision", GetFullVersionString());
Expand Down Expand Up @@ -420,7 +429,11 @@ class TFileSystemStats final
: TRequestLogger{executionTimeThreshold, totalTimeThreshold}
, FileSystemId{std::move(fileSystemId)}
, ClientId{std::move(clientId)}
, Counters{MakeRequestCounters(timer, *counters)}
, Counters{MakeRequestCounters(
timer,
*counters,
REQUEST_COUNTERS_OPTIONS
| TRequestCounters::EOption::LazyRequestInitialization)}
, Predictor{std::move(predictor)}
, PredictorStats{counters, std::move(timer)}
{}
Expand Down
75 changes: 75 additions & 0 deletions cloud/filestore/libs/diagnostics/request_stats_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,81 @@ Y_UNIT_TEST_SUITE(TRequestStatRegistryTest)
UNIT_ASSERT(!counters);
}
}

Y_UNIT_TEST(ShouldNotReportZeroCounters)
{
const TString FS = "test";
const TString CLIENT = "client";

TBootstrap bootstrap;

auto fsCounters = bootstrap.Counters
->FindSubgroup("component", METRIC_FS_COMPONENT);
UNIT_ASSERT(fsCounters);
fsCounters = fsCounters->FindSubgroup("host", "cluster");
UNIT_ASSERT(fsCounters);

auto stats = bootstrap.Registry->GetFileSystemStats(FS, CLIENT);
UNIT_ASSERT(stats);
fsCounters = fsCounters->FindSubgroup("filesystem", FS);
UNIT_ASSERT(fsCounters);
fsCounters = fsCounters->FindSubgroup("client", CLIENT);
UNIT_ASSERT(fsCounters);

// non lazy-init request
auto readData = fsCounters->FindSubgroup("request", "ReadData");
UNIT_ASSERT(readData);

// lazy-init request
auto createHandle = fsCounters->FindSubgroup("request", "CreateHandle");
UNIT_ASSERT(createHandle);

// these ones should always be present
auto readDataCount = readData->FindCounter("Count");
auto readDataErrors = readData->FindCounter("Errors");

// non lazy-init counters
auto createHandleCount = createHandle->FindCounter("Count");
auto createHandleErrorsFatal =
createHandle->FindCounter("Errors/Fatal");
// lazy-init counter
auto createHandleErrors = createHandle->FindCounter("Errors");

UNIT_ASSERT(readDataCount);
UNIT_ASSERT_VALUES_EQUAL(0, readDataCount->Val());
UNIT_ASSERT(readDataErrors);
UNIT_ASSERT_VALUES_EQUAL(0, readDataErrors->Val());
UNIT_ASSERT(createHandleCount);
UNIT_ASSERT_VALUES_EQUAL(0, createHandleCount->Val());
UNIT_ASSERT(createHandleErrorsFatal);
UNIT_ASSERT_VALUES_EQUAL(0, createHandleErrorsFatal->Val());
UNIT_ASSERT(!createHandleErrors);

{
auto context = MakeIntrusive<TCallContext>(FS);
context->RequestType = EFileStoreRequest::CreateHandle;
stats->RequestStarted(*context);
stats->RequestCompleted(*context, MakeError(S_OK));

// we got a request - now all counters for this request should be
// initialized
createHandleErrors = createHandle->FindCounter("Errors");
UNIT_ASSERT(createHandleErrors);
UNIT_ASSERT_VALUES_EQUAL(0, createHandleErrors->Val());
UNIT_ASSERT_VALUES_EQUAL(1, createHandleCount->Val());
}

{
auto context = MakeIntrusive<TCallContext>(FS);
context->RequestType = EFileStoreRequest::CreateHandle;
stats->RequestStarted(*context);
stats->RequestCompleted(*context, MakeError(E_REJECTED));

// and now we successfully registered an error
UNIT_ASSERT_VALUES_EQUAL(1, createHandleErrors->Val());
UNIT_ASSERT_VALUES_EQUAL(1, createHandleCount->Val());
}
}
}

} // namespace NCloud::NFileStore::NStorage
4 changes: 3 additions & 1 deletion cloud/filestore/libs/service_local/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ TLocalFileSystem::TLocalFileSystem(
TFsPath root,
ITimerPtr timer,
ISchedulerPtr scheduler,
ILoggingServicePtr logging)
ILoggingServicePtr logging,
IFileIOServicePtr fileIOService)
: Config(std::move(config))
, Root(std::move(root))
, Timer(std::move(timer))
, Scheduler(std::move(scheduler))
, FileIOService(std::move(fileIOService))
, Store(std::move(store))
{
Log = logging->CreateLog(Store.GetFileSystemId());
Expand Down
69 changes: 64 additions & 5 deletions cloud/filestore/libs/service_local/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,56 @@ namespace NCloud::NFileStore {

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

#define FILESTORE_DATA_METHODS_LOCAL_SYNC(xxx, ...) \
xxx(StatFileStore, __VA_ARGS__) \
\
xxx(SubscribeSession, __VA_ARGS__) \
xxx(GetSessionEvents, __VA_ARGS__) \
xxx(ResetSession, __VA_ARGS__) \
\
xxx(ResolvePath, __VA_ARGS__) \
xxx(CreateNode, __VA_ARGS__) \
xxx(UnlinkNode, __VA_ARGS__) \
xxx(RenameNode, __VA_ARGS__) \
xxx(AccessNode, __VA_ARGS__) \
xxx(ListNodes, __VA_ARGS__) \
xxx(ReadLink, __VA_ARGS__) \
\
xxx(SetNodeAttr, __VA_ARGS__) \
xxx(GetNodeAttr, __VA_ARGS__) \
xxx(SetNodeXAttr, __VA_ARGS__) \
xxx(GetNodeXAttr, __VA_ARGS__) \
xxx(ListNodeXAttr, __VA_ARGS__) \
xxx(RemoveNodeXAttr, __VA_ARGS__) \
\
xxx(CreateHandle, __VA_ARGS__) \
xxx(DestroyHandle, __VA_ARGS__) \
\
xxx(AcquireLock, __VA_ARGS__) \
xxx(ReleaseLock, __VA_ARGS__) \
xxx(TestLock, __VA_ARGS__) \
\
xxx(AllocateData, __VA_ARGS__) \
// FILESTORE_DATA_METHODS_LOCAL_SYNC

#define FILESTORE_DATA_METHODS_LOCAL_ASYNC(xxx, ...) \
xxx(ReadData, __VA_ARGS__) \
xxx(WriteData, __VA_ARGS__) \
// FILESTORE_DATA_METHODS_LOCAL_ASYNC

#define FILESTORE_SERVICE_LOCAL_SYNC(xxx, ...) \
xxx(Ping, __VA_ARGS__) \
xxx(PingSession, __VA_ARGS__) \
FILESTORE_SERVICE_METHODS(xxx, __VA_ARGS__) \
FILESTORE_DATA_METHODS_LOCAL_SYNC(xxx, __VA_ARGS__) \
// FILESTORE_SERVICE_LOCAL_SYNC

#define FILESTORE_SERVICE_LOCAL_ASYNC(xxx, ...) \
FILESTORE_DATA_METHODS_LOCAL_ASYNC(xxx, __VA_ARGS__) \
// FILESTORE_SERVICE_LOCAL_SYNC

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

class TLocalFileSystem final
: public std::enable_shared_from_this<TLocalFileSystem>
{
Expand All @@ -38,6 +88,7 @@ class TLocalFileSystem final
const TFsPath Root;
const ITimerPtr Timer;
const ISchedulerPtr Scheduler;
const IFileIOServicePtr FileIOService;

NProto::TFileStore Store;
TLog Log;
Expand All @@ -59,16 +110,24 @@ class TLocalFileSystem final
TFsPath root,
ITimerPtr timer,
ISchedulerPtr scheduler,
ILoggingServicePtr logging);
ILoggingServicePtr logging,
IFileIOServicePtr fileIOService);

#define FILESTORE_DECLARE_METHOD(name, ...) \
#define FILESTORE_DECLARE_METHOD_SYNC(name, ...) \
NProto::T##name##Response name( \
const NProto::T##name##Request& request); \
// FILESTORE_DECLARE_METHOD
// FILESTORE_DECLARE_METHOD_SYNC

#define FILESTORE_DECLARE_METHOD_ASYNC(name, ...) \
NThreading::TFuture<NProto::T##name##Response> name##Async( \
NProto::T##name##Request& request); \
// FILESTORE_DECLARE_METHOD_SYNC

FILESTORE_SERVICE(FILESTORE_DECLARE_METHOD)
FILESTORE_SERVICE_LOCAL_SYNC(FILESTORE_DECLARE_METHOD_SYNC)
FILESTORE_SERVICE_LOCAL_ASYNC(FILESTORE_DECLARE_METHOD_ASYNC)

#undef FILESTORE_DECLARE_METHOD
#undef FILESTORE_DECLARE_METHOD_SYNC
#undef FILESTORE_DECLARE_METHOD_ASYNC

NProto::TFileStore GetConfig() const
{
Expand Down
Loading

0 comments on commit 5e607ad

Please sign in to comment.