aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnaury <snaury@ydb.tech>2023-02-20 13:08:57 +0300
committersnaury <snaury@ydb.tech>2023-02-20 13:08:57 +0300
commit631094142a5d76e135d6016c72a218be08277a46 (patch)
treef28e9cdc40a93fb684444a466847714acfcd01fd
parent0b55ada382bd88a001dd4272ded7fd0be438c4fa (diff)
downloadydb-631094142a5d76e135d6016c72a218be08277a46.tar.gz
Recreate missing families on reload
-rw-r--r--ydb/core/tx/datashard/datashard__init.cpp3
-rw-r--r--ydb/core/tx/datashard/datashard_user_table.cpp31
-rw-r--r--ydb/core/tx/datashard/datashard_user_table.h4
3 files changed, 38 insertions, 0 deletions
diff --git a/ydb/core/tx/datashard/datashard__init.cpp b/ydb/core/tx/datashard/datashard__init.cpp
index 1bd74006e2d..d609d6813ea 100644
--- a/ydb/core/tx/datashard/datashard__init.cpp
+++ b/ydb/core/tx/datashard/datashard__init.cpp
@@ -43,6 +43,9 @@ bool TDataShard::TTxInit::Execute(TTransactionContext& txc, const TActorContext&
if (done && Self->State != TShardState::Offline) {
Self->SnapshotManager.Fix_KIKIMR_12289(txc.DB);
Self->SnapshotManager.Fix_KIKIMR_14259(txc.DB);
+ for (const auto& pr : Self->TableInfos) {
+ pr.second->Fix_KIKIMR_17222(txc.DB);
+ }
}
return done;
diff --git a/ydb/core/tx/datashard/datashard_user_table.cpp b/ydb/core/tx/datashard/datashard_user_table.cpp
index 2a3558d909e..32e7ba1899a 100644
--- a/ydb/core/tx/datashard/datashard_user_table.cpp
+++ b/ydb/core/tx/datashard/datashard_user_table.cpp
@@ -609,4 +609,35 @@ void TUserTable::ApplyDefaults(TTransactionContext& txc) const
}
}
+void TUserTable::Fix_KIKIMR_17222(NTable::TDatabase& db) const
+{
+ Fix_KIKIMR_17222(db, LocalTid);
+ if (ShadowTid) {
+ Fix_KIKIMR_17222(db, ShadowTid);
+ }
+}
+
+void TUserTable::Fix_KIKIMR_17222(NTable::TDatabase& db, ui32 tid) const
+{
+ const auto* tableInfo = db.GetScheme().GetTableInfo(tid);
+ if (!tableInfo) {
+ // Local table does not exist, nothing to fix
+ return;
+ }
+
+ for (const auto& fam : Families) {
+ ui32 familyId = fam.first;
+ if (tableInfo->Families.contains(familyId)) {
+ // Family exists, nothing to fix
+ continue;
+ }
+
+ const TUserFamily& family = fam.second;
+
+ db.Alter().AddFamily(tid, familyId, family.GetRoomId());
+ db.Alter().SetFamily(tid, familyId, family.Cache, family.Codec);
+ db.Alter().SetFamilyBlobs(tid, familyId, family.GetOuterThreshold(), family.GetExternalThreshold());
+ }
+}
+
}}
diff --git a/ydb/core/tx/datashard/datashard_user_table.h b/ydb/core/tx/datashard/datashard_user_table.h
index 42e7dd5ae1d..f8a35d9f80a 100644
--- a/ydb/core/tx/datashard/datashard_user_table.h
+++ b/ydb/core/tx/datashard/datashard_user_table.h
@@ -389,6 +389,8 @@ struct TUserTable : public TThrRefBase {
const NKikimrSchemeOp::TTableDescription& alter, TString& strError);
void ApplyDefaults(NTabletFlatExecutor::TTransactionContext& txc) const;
+ void Fix_KIKIMR_17222(NTable::TDatabase& db) const;
+
TTableRange GetTableRange() const { return Range.ToTableRange(); }
const TString& GetSchema() const { return Schema; }
@@ -422,6 +424,8 @@ private:
void DoApplyCreate(NTabletFlatExecutor::TTransactionContext& txc, const TString& tableName, bool shadow,
const NKikimrSchemeOp::TPartitionConfig& partConfig) const;
+ void Fix_KIKIMR_17222(NTable::TDatabase& db, ui32 tid) const;
+
private:
TString Schema;
ui64 TableSchemaVersion = 0;