Skip to content

Commit

Permalink
import: dummy metadata for views
Browse files Browse the repository at this point in the history
  • Loading branch information
jepett0 committed Jan 14, 2025
1 parent 9da853b commit 06878e5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
8 changes: 7 additions & 1 deletion ydb/core/tx/schemeshard/schemeshard_export__create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,14 @@ struct TSchemeShard::TExport::TTxProgress: public TSchemeShard::TXxport::TTxBase
Y_ABORT_UNLESS(exportSettings.ParseFromString(exportInfo->Settings));
const auto databaseRoot = TStringBuilder() << '/' << JoinSeq('/', Self->RootPathElements);

NBackup::TMetadata metadata;
// do not check hashes of views in backups
constexpr bool EnableChecksums = false;
metadata.SetVersion(EnableChecksums ? 1 : 0);

item.SchemeUploader = ctx.Register(CreateSchemeUploader(
Self->SelfId(), exportInfo->Id, itemIdx, item.SourcePathId, exportSettings, databaseRoot
Self->SelfId(), exportInfo->Id, itemIdx, item.SourcePathId,
exportSettings, databaseRoot, metadata.Serialize()
));
}
}
Expand Down
57 changes: 51 additions & 6 deletions ydb/core/tx/schemeshard/schemeshard_export_scheme_uploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
void HandleSchemeDescription(TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev) {
const auto& describeResult = ev->Get()->GetRecord();

LOG_D("HandleSchemeDescription TEvSchemeShard::TEvDescribeSchemeResult"
LOG_D("HandleSchemeDescription"
<< ", self: " << this->SelfId()
<< ", status: " << describeResult.GetStatus()
);
Expand Down Expand Up @@ -109,7 +109,7 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
void HandleSchemePutResponse(TEvExternalStorage::TEvPutObjectResponse::TPtr& ev) {
const auto& result = ev->Get()->Result;

LOG_D("HandleSchemePutResponse TEvExternalStorage::TEvPutObjectResponse"
LOG_D("HandleSchemePutResponse"
<< ", self: " << this->SelfId()
<< ", result: " << result
);
Expand Down Expand Up @@ -137,7 +137,7 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
void HandlePermissionsPutResponse(TEvExternalStorage::TEvPutObjectResponse::TPtr& ev) {
const auto& result = ev->Get()->Result;

LOG_D("HandlePermissionsPutResponse TEvExternalStorage::TEvPutObjectResponse"
LOG_D("HandlePermissionsPutResponse"
<< ", self: " << this->SelfId()
<< ", result: " << result
);
Expand All @@ -146,6 +146,34 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
return;
}
PermissionsUploaded = true;
UploadMetadata();
}

void UploadMetadata() {
Y_ABORT_UNLESS(!MetadataUploaded);

if (!Metadata) {
return Finish(false, "empty metadata");
}
auto request = Aws::S3::Model::PutObjectRequest()
.WithKey(Sprintf("%s/metadata.json", DestinationPrefix.c_str()));

this->Send(StorageOperator, new TEvExternalStorage::TEvPutObjectRequest(request, TString(Metadata)));
this->Become(&TThis::StateUploadMetadata);
}

void HandleMetadataPutResponse(TEvExternalStorage::TEvPutObjectResponse::TPtr& ev) {
const auto& result = ev->Get()->Result;

LOG_D("HandleMetadataPutResponse"
<< ", self: " << this->SelfId()
<< ", result: " << result
);

if (!CheckResult(result, TStringBuf("PutObject (metadata)"))) {
return;
}
MetadataUploaded = true;
Finish();
}

Expand Down Expand Up @@ -212,7 +240,8 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
ui32 itemIdx,
TPathId sourcePathId,
const Ydb::Export::ExportToS3Settings& settings,
const TString& databaseRoot
const TString& databaseRoot,
const TString& metadata
)
: SchemeShard(schemeShard)
, ExportId(exportId)
Expand All @@ -221,6 +250,7 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
, ExternalStorageConfig(new TS3ExternalStorageConfig(settings))
, Retries(settings.number_of_retries())
, DatabaseRoot(databaseRoot)
, Metadata(metadata)
{
if (itemIdx < ui32(settings.items_size())) {
DestinationPrefix = settings.items(itemIdx).destination_prefix();
Expand All @@ -245,6 +275,10 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
UploadPermissions();
return;
}
if (!MetadataUploaded) {
UploadMetadata();
return;
}
Finish();
}

Expand Down Expand Up @@ -279,6 +313,14 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
}
}

STATEFN(StateUploadMetadata) {
switch (ev->GetTypeRewrite()) {
hFunc(TEvExternalStorage::TEvPutObjectResponse, HandleMetadataPutResponse);
default:
return StateBase(ev);
}
}

private:

TActorId SchemeShard;
Expand Down Expand Up @@ -306,12 +348,15 @@ class TSchemeUploader: public TActorBootstrapped<TSchemeUploader> {
TString Permissions;
bool PermissionsUploaded = false;

TString Metadata;
bool MetadataUploaded = false;

}; // TSchemeUploader

IActor* CreateSchemeUploader(TActorId schemeShard, ui64 exportId, ui32 itemIdx, TPathId sourcePathId,
const Ydb::Export::ExportToS3Settings& settings, const TString& databaseRoot
const Ydb::Export::ExportToS3Settings& settings, const TString& databaseRoot, const TString& metadata
) {
return new TSchemeUploader(schemeShard, exportId, itemIdx, sourcePathId, settings, databaseRoot);
return new TSchemeUploader(schemeShard, exportId, itemIdx, sourcePathId, settings, databaseRoot, metadata);
}

} // NKikimr::NSchemeShard
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Ydb::Export {
namespace NKikimr::NSchemeShard {

NActors::IActor* CreateSchemeUploader(NActors::TActorId schemeShard, ui64 exportId, ui32 itemIdx, TPathId sourcePathId,
const Ydb::Export::ExportToS3Settings& settings, const TString& databaseRoot
const Ydb::Export::ExportToS3Settings& settings, const TString& databaseRoot, const TString& metadata
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class TSchemeUploaderFallback: public TActorBootstrapped<TSchemeUploaderFallback


IActor* CreateSchemeUploader(TActorId schemeShard, ui64 exportId, ui32 itemIdx, TPathId sourcePathId,
const Ydb::Export::ExportToS3Settings& settings, const TString& databaseRoot
const Ydb::Export::ExportToS3Settings& settings, const TString& databaseRoot, const TString& metadata
) {
Y_UNUSED(sourcePathId, settings, databaseRoot, metadata);
return new TSchemeUploaderFallback(schemeShard, exportId, itemIdx);
}

Expand Down

0 comments on commit 06878e5

Please sign in to comment.