Skip to content

Commit 356c98d

Browse files
committed
Restore the commit fixing a memory leak in AWS SDK (#8823)
1 parent adc27fd commit 356c98d

File tree

26 files changed

+732
-373
lines changed

26 files changed

+732
-373
lines changed

ydb/core/driver_lib/run/kikimr_services_initializers.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@
240240

241241
#include <util/system/hostname.h>
242242

243+
#include <aws/core/Aws.h>
244+
245+
namespace {
246+
247+
struct TAwsApiGuard {
248+
TAwsApiGuard() {
249+
Aws::InitAPI(Options);
250+
}
251+
252+
~TAwsApiGuard() {
253+
Aws::ShutdownAPI(Options);
254+
}
255+
256+
private:
257+
Aws::SDKOptions Options;
258+
};
259+
260+
}
261+
243262
namespace NKikimr {
244263

245264
namespace NKikimrServicesInitializers {
@@ -2793,5 +2812,16 @@ void TGraphServiceInitializer::InitializeServices(NActors::TActorSystemSetup* se
27932812
TActorSetupCmd(NGraph::CreateGraphService(appData->TenantName), TMailboxType::HTSwap, appData->UserPoolId));
27942813
}
27952814

2815+
TAwsApiInitializer::TAwsApiInitializer(IGlobalObjectStorage& globalObjects)
2816+
: GlobalObjects(globalObjects)
2817+
{
2818+
}
2819+
2820+
void TAwsApiInitializer::InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) {
2821+
Y_UNUSED(setup);
2822+
Y_UNUSED(appData);
2823+
GlobalObjects.AddGlobalObject(std::make_shared<TAwsApiGuard>());
2824+
}
2825+
27962826
} // namespace NKikimrServicesInitializers
27972827
} // namespace NKikimr

ydb/core/driver_lib/run/kikimr_services_initializers.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,5 +612,14 @@ class TGraphServiceInitializer : public IKikimrServicesInitializer {
612612
void InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) override;
613613
};
614614

615+
class TAwsApiInitializer : public IServiceInitializer {
616+
IGlobalObjectStorage& GlobalObjects;
617+
618+
public:
619+
TAwsApiInitializer(IGlobalObjectStorage& globalObjects);
620+
621+
void InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) override;
622+
};
623+
615624
} // namespace NKikimrServicesInitializers
616625
} // namespace NKikimr

ydb/core/driver_lib/run/run.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,10 @@ TIntrusivePtr<TServiceInitializersList> TKikimrRunner::CreateServiceInitializers
16511651
sil->AddServiceInitializer(new TGraphServiceInitializer(runConfig));
16521652
}
16531653

1654+
if (serviceMask.EnableAwsService) {
1655+
sil->AddServiceInitializer(new TAwsApiInitializer(*this));
1656+
}
1657+
16541658
return sil;
16551659
}
16561660

ydb/core/driver_lib/run/service_mask.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ union TBasicKikimrServicesMask {
7878
bool EnableDatabaseMetadataCache:1;
7979
bool EnableGraphService:1;
8080
bool EnableCompDiskLimiter:1;
81+
bool EnableAwsService:1;
8182
};
8283

8384
struct {

ydb/core/driver_lib/run/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ SRCS(
2020
)
2121

2222
PEERDIR(
23+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2324
contrib/libs/protobuf
2425
ydb/library/actors/core
2526
ydb/library/actors/dnsresolver

ydb/core/tx/columnshard/ut_schema/ut_columnshard_schema.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
#include <util/system/hostname.h>
1919
#include <library/cpp/deprecated/atomic/atomic.h>
20+
#include <library/cpp/testing/hook/hook.h>
21+
22+
#include <aws/core/Aws.h>
2023

2124
namespace NKikimr {
2225

@@ -32,6 +35,16 @@ enum class EInitialEviction {
3235

3336
namespace {
3437

38+
Aws::SDKOptions Options;
39+
40+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
41+
Aws::InitAPI(Options);
42+
}
43+
44+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
45+
Aws::ShutdownAPI(Options);
46+
}
47+
3548
static const std::vector<NArrow::NTest::TTestColumn> testYdbSchema = TTestSchema::YdbSchema();
3649
static const std::vector<NArrow::NTest::TTestColumn> testYdbPk = TTestSchema::YdbPkSchema();
3750

ydb/core/tx/columnshard/ut_schema/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PEERDIR(
1818
library/cpp/getopt
1919
library/cpp/regex/pcre
2020
library/cpp/svnversion
21+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2122
ydb/core/testlib/default
2223
ydb/core/tx/columnshard/hooks/abstract
2324
ydb/core/tx/columnshard/hooks/testing

ydb/core/tx/datashard/import_s3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <ydb/core/tablet/resource_broker.h>
1515
#include <ydb/core/wrappers/s3_wrapper.h>
1616
#include <ydb/core/wrappers/s3_storage.h>
17+
#include <ydb/core/wrappers/s3_storage_config.h>
1718
#include <ydb/core/io_formats/ydb_dump/csv_ydb_dump.h>
1819
#include <ydb/public/lib/scheme_types/scheme_type_id.h>
1920

ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@
77
#include <util/string/cast.h>
88
#include <util/string/printf.h>
99

10+
#include <library/cpp/testing/hook/hook.h>
11+
12+
#include <aws/core/Aws.h>
13+
1014
using namespace NSchemeShardUT_Private;
1115
using namespace NKikimr::NWrappers::NTestHelpers;
1216

17+
namespace {
18+
19+
Aws::SDKOptions Options;
20+
21+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
22+
Aws::InitAPI(Options);
23+
}
24+
25+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
26+
Aws::ShutdownAPI(Options);
27+
}
28+
29+
}
30+
1331
Y_UNIT_TEST_SUITE(TBackupTests) {
1432
using TFillFn = std::function<void(TTestBasicRuntime&)>;
1533

ydb/core/tx/schemeshard/ut_backup/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ IF (NOT OS_WINDOWS)
2020
library/cpp/getopt
2121
library/cpp/regex/pcre
2222
library/cpp/svnversion
23+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2324
ydb/core/testlib/default
2425
ydb/core/tx
2526
ydb/core/tx/schemeshard/ut_helpers

0 commit comments

Comments
 (0)