Skip to content

Fixed temp dir owner actor id serialization #20683

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions ydb/core/kqp/runtime/kqp_write_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ class TKqpTableWriteActor : public TActorBootstrapped<TKqpTableWriteActor> {
void RetryShard(const ui64 shardId, const std::optional<ui64> ifCookieEqual) {
const auto metadata = ShardedWriteController->GetMessageMetadata(shardId);
if (!metadata || (ifCookieEqual && metadata->Cookie != ifCookieEqual)) {
CA_LOG_W("Retry failed: not found ShardID=" << shardId << " with Cookie=" << ifCookieEqual.value_or(0));
CA_LOG_I("Retry failed: not found ShardID=" << shardId << " with Cookie=" << ifCookieEqual.value_or(0));
return;
}

Expand All @@ -1119,7 +1119,7 @@ class TKqpTableWriteActor : public TActorBootstrapped<TKqpTableWriteActor> {
}

void Handle(TEvPrivate::TEvShardRequestTimeout::TPtr& ev) {
CA_LOG_W("Timeout shardID=" << ev->Get()->ShardId);
CA_LOG_I("Timeout shardID=" << ev->Get()->ShardId);
YQL_ENSURE(InconsistentTx);
RetryShard(ev->Get()->ShardId, ev->Cookie);
}
Expand Down
13 changes: 13 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__background_cleaning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ NOperationQueue::EStartStatus TSchemeShard::StartBackgroundCleaning(const TPathI
auto ctx = ActorContext();
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "RunBackgroundCleaning "
"for temp dir# " << JoinPath({info->WorkingDir, info->Name})
<< ", pathId# " << pathId
<< ", ownerId# " << info->TempDirOwnerActorId
<< ", next wakeup# " << BackgroundCleaningQueue->GetWakeupDelta()
<< ", rate# " << BackgroundCleaningQueue->GetRate()
Expand Down Expand Up @@ -309,6 +310,13 @@ void TSchemeShard::RetryNodeSubscribe(ui32 nodeId) {
}

retryState.RetryNumber++;
auto ctx = ActorContext();
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Retry node subscribe BackgroundCleaning "
"for nodeId# " << nodeId
<< ", count of retries# " << retryState.RetryNumber
<< ", retries limit# " << BackgroundCleaningRetrySettings.GetMaxRetryNumber()
<< ", last retry at# " << retryState.LastRetryAt
<< " at schemeshard " << TabletID());

if (retryState.RetryNumber > BackgroundCleaningRetrySettings.GetMaxRetryNumber()) {
for (const auto& ownerActorId: nodeState.Owners) {
Expand Down Expand Up @@ -359,6 +367,11 @@ bool TSchemeShard::CheckOwnerUndelivered(TEvents::TEvUndelivered::TPtr& ev) {
}

auto& currentTempDirs = it->second;
auto ctx = ActorContext();
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "Owner undelivered for BackgroundCleaning "
"for ownerActorId# " << ownerActorId
<< ", undelivered reason# " << ev->Get()->Reason
<< " at schemeshard " << TabletID());

for (auto& pathId: currentTempDirs) {
EnqueueBackgroundCleaning(pathId);
Expand Down
10 changes: 6 additions & 4 deletions ydb/core/tx/schemeshard/schemeshard__init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {
rowSet.template GetValueOrDefault<typename SchemaTable::DirAlterVersion>(1),
rowSet.template GetValueOrDefault<typename SchemaTable::UserAttrsAlterVersion>(1),
rowSet.template GetValueOrDefault<typename SchemaTable::ACLVersion>(0),
rowSet.template GetValueOrDefault<typename SchemaTable::TempDirOwnerActorId>()
rowSet.template GetValueOrDefault<typename SchemaTable::TempDirOwnerActorIdProto>()
);
}

Expand All @@ -138,7 +138,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {

TPathElement::TPtr path = new TPathElement(pathId, parentPathId, domainId, name, owner);

TString tempDirOwnerActorId;
TString tempDirOwnerActorIdProto;
std::tie(
std::ignore, //pathId
std::ignore, //parentPathId
Expand All @@ -154,14 +154,16 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {
path->DirAlterVersion,
path->UserAttrs->AlterVersion,
path->ACLVersion,
tempDirOwnerActorId) = rec;
tempDirOwnerActorIdProto) = rec;

path->PathState = TPathElement::EPathState::EPathStateNoChanges;
if (path->StepDropped) {
path->PathState = TPathElement::EPathState::EPathStateNotExist;
}

path->TempDirOwnerActorId.Parse(tempDirOwnerActorId.c_str(), tempDirOwnerActorId.size());
if (NActorsProto::TActorId protoId; protoId.ParseFromString(tempDirOwnerActorIdProto)) {
path->TempDirOwnerActorId = ActorIdFromProto(protoId);
}

return path;
}
Expand Down
10 changes: 8 additions & 2 deletions ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,10 @@ void TSchemeShard::PersistLastTxId(NIceDb::TNiceDb& db, const TPathElement::TPtr
void TSchemeShard::PersistPath(NIceDb::TNiceDb& db, const TPathId& pathId) {
Y_ABORT_UNLESS(PathsById.contains(pathId));
TPathElement::TPtr elem = PathsById.at(pathId);

NActorsProto::TActorId tempDirOwnerActorIdProto;
ActorIdToProto(elem->TempDirOwnerActorId, &tempDirOwnerActorIdProto);

if (IsLocalId(pathId)) {
db.Table<Schema::Paths>().Key(pathId.LocalPathId).Update(
NIceDb::TUpdate<Schema::Paths::ParentOwnerId>(elem->ParentPathId.OwnerId),
Expand All @@ -2127,7 +2131,8 @@ void TSchemeShard::PersistPath(NIceDb::TNiceDb& db, const TPathId& pathId) {
NIceDb::TUpdate<Schema::Paths::DirAlterVersion>(elem->DirAlterVersion),
NIceDb::TUpdate<Schema::Paths::UserAttrsAlterVersion>(elem->UserAttrs->AlterVersion),
NIceDb::TUpdate<Schema::Paths::ACLVersion>(elem->ACLVersion),
NIceDb::TUpdate<Schema::Paths::TempDirOwnerActorId>(elem->TempDirOwnerActorId.ToString())
NIceDb::TUpdate<Schema::Paths::TempDirOwnerActorId>(elem->TempDirOwnerActorId.ToString()),
NIceDb::TUpdate<Schema::Paths::TempDirOwnerActorIdProto>(tempDirOwnerActorIdProto.SerializeAsString())
);
} else {
db.Table<Schema::MigratedPaths>().Key(pathId.OwnerId, pathId.LocalPathId).Update(
Expand All @@ -2145,7 +2150,8 @@ void TSchemeShard::PersistPath(NIceDb::TNiceDb& db, const TPathId& pathId) {
NIceDb::TUpdate<Schema::MigratedPaths::DirAlterVersion>(elem->DirAlterVersion),
NIceDb::TUpdate<Schema::MigratedPaths::UserAttrsAlterVersion>(elem->UserAttrs->AlterVersion),
NIceDb::TUpdate<Schema::MigratedPaths::ACLVersion>(elem->ACLVersion),
NIceDb::TUpdate<Schema::MigratedPaths::TempDirOwnerActorId>(elem->TempDirOwnerActorId.ToString())
NIceDb::TUpdate<Schema::MigratedPaths::TempDirOwnerActorId>(elem->TempDirOwnerActorId.ToString()),
NIceDb::TUpdate<Schema::MigratedPaths::TempDirOwnerActorIdProto>(tempDirOwnerActorIdProto.SerializeAsString())
);
}
}
Expand Down
19 changes: 11 additions & 8 deletions ydb/core/tx/schemeshard/schemeshard_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ struct Schema : NIceDb::Schema {
struct UserAttrsAlterVersion : Column<14, NScheme::NTypeIds::Uint64> {};
struct ACLVersion : Column<15, NScheme::NTypeIds::Uint64> {};
struct ParentOwnerId : Column<16, NScheme::NTypeIds::Uint64> { using Type = TOwnerId; static constexpr Type Default = InvalidOwnerId; };
struct TempDirOwnerActorId : Column<17, NScheme::NTypeIds::String> {}; // Only for EPathType::EPathTypeDir.
// Not empty if dir must be deleted after loosing connection with TempDirOwnerActorId actor.
// See schemeshard__background_cleaning.cpp.
struct TempDirOwnerActorId : Column<17, NScheme::NTypeIds::String> {}; // legacy
struct TempDirOwnerActorIdProto : Column<18, NScheme::NTypeIds::String> {}; // Only for EPathType::EPathTypeDir.
// Not empty if dir must be deleted after loosing connection with TempDirOwnerActorId actor.
// See schemeshard__background_cleaning.cpp.

using TKey = TableKey<Id>;
using TColumns = TableColumns<Id, ParentId, Name, CreateFinished, PathType, StepCreated, CreateTxId,
StepDropped, DropTxId, Owner, ACL, LastTxId, DirAlterVersion, UserAttrsAlterVersion, ACLVersion,
ParentOwnerId, TempDirOwnerActorId>;
ParentOwnerId, TempDirOwnerActorId, TempDirOwnerActorIdProto>;
};

struct MigratedPaths : Table<50> {
Expand All @@ -62,13 +63,15 @@ struct Schema : NIceDb::Schema {
struct DirAlterVersion : Column<14, NScheme::NTypeIds::Uint64> {};
struct UserAttrsAlterVersion : Column<15, NScheme::NTypeIds::Uint64> {};
struct ACLVersion : Column<16, NScheme::NTypeIds::Uint64> {};
struct TempDirOwnerActorId : Column<17, NScheme::NTypeIds::String> {}; // Only for EPathType::EPathTypeDir.
// Not empty if dir must be deleted after loosing connection with TempDirOwnerActorId actor.
// See schemeshard__background_cleaning.cpp.
struct TempDirOwnerActorId : Column<17, NScheme::NTypeIds::String> {}; // legacy
struct TempDirOwnerActorIdProto : Column<18, NScheme::NTypeIds::String> {}; // Only for EPathType::EPathTypeDir.
// Not empty if dir must be deleted after loosing connection with TempDirOwnerActorId actor.
// See schemeshard__background_cleaning.cpp.

using TKey = TableKey<OwnerPathId, LocalPathId>;
using TColumns = TableColumns<OwnerPathId, LocalPathId, ParentOwnerId, ParentLocalId, Name, PathType, StepCreated, CreateTxId,
StepDropped, DropTxId, Owner, ACL, LastTxId, DirAlterVersion, UserAttrsAlterVersion, ACLVersion, TempDirOwnerActorId>;
StepDropped, DropTxId, Owner, ACL, LastTxId, DirAlterVersion, UserAttrsAlterVersion, ACLVersion, TempDirOwnerActorId,
TempDirOwnerActorIdProto>;
};

struct TxInFlight : Table<2> { // not in use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
1
],
"ColumnsAdded": [
{
"ColumnId": 17,
"ColumnName": "TempDirOwnerActorId",
"ColumnType": "String"
},
{
"ColumnId": 1,
"ColumnName": "Id",
Expand Down Expand Up @@ -90,13 +85,22 @@
"ColumnId": 16,
"ColumnName": "ParentOwnerId",
"ColumnType": "Uint64"
},
{
"ColumnId": 17,
"ColumnName": "TempDirOwnerActorId",
"ColumnType": "String"
},
{
"ColumnId": 18,
"ColumnName": "TempDirOwnerActorIdProto",
"ColumnType": "String"
}
],
"ColumnsDropped": [],
"ColumnFamilies": {
"0": {
"Columns": [
17,
1,
2,
3,
Expand All @@ -112,7 +116,9 @@
13,
14,
15,
16
16,
17,
18
],
"RoomID": 0,
"Codec": 0,
Expand Down Expand Up @@ -3537,11 +3543,6 @@
2
],
"ColumnsAdded": [
{
"ColumnId": 17,
"ColumnName": "TempDirOwnerActorId",
"ColumnType": "String"
},
{
"ColumnId": 1,
"ColumnName": "OwnerPathId",
Expand Down Expand Up @@ -3621,13 +3622,22 @@
"ColumnId": 16,
"ColumnName": "ACLVersion",
"ColumnType": "Uint64"
},
{
"ColumnId": 17,
"ColumnName": "TempDirOwnerActorId",
"ColumnType": "String"
},
{
"ColumnId": 18,
"ColumnName": "TempDirOwnerActorIdProto",
"ColumnType": "String"
}
],
"ColumnsDropped": [],
"ColumnFamilies": {
"0": {
"Columns": [
17,
1,
2,
3,
Expand All @@ -3643,7 +3653,9 @@
13,
14,
15,
16
16,
17,
18
],
"RoomID": 0,
"Codec": 0,
Expand Down
Loading