Skip to content

Commit

Permalink
Check alter version only for ss applyIf (#3823)
Browse files Browse the repository at this point in the history
  • Loading branch information
niksaveliev authored May 24, 2024
1 parent 6f48846 commit d1fcb9c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions ydb/core/protos/flat_scheme_op.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ message TApplyIf {
optional uint64 PathId = 1;
optional uint64 PathVersion = 2;
optional uint64 LockedTxId = 3;
optional bool CheckEntityVersion = 4 [default = false];
}

message TUpgradeSubDomain {
Expand Down
67 changes: 66 additions & 1 deletion ydb/core/tx/schemeshard/schemeshard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,72 @@ bool TSchemeShard::CheckApplyIf(const NKikimrSchemeOp::TModifyScheme &scheme, TS

if (item.HasPathVersion()) {
const auto requiredVersion = item.GetPathVersion();
const auto actualVersion = GetPathVersion(TPath::Init(pathId, this)).GetGeneralVersion();
arc_ui64 actualVersion;
auto path = TPath::Init(pathId, this);
auto pathVersion = GetPathVersion(path);

if (item.HasCheckEntityVersion() && item.GetCheckEntityVersion()) {
switch(path.Base()->PathType) {
case NKikimrSchemeOp::EPathTypePersQueueGroup:
actualVersion = pathVersion.GetPQVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeSubDomain:
case NKikimrSchemeOp::EPathType::EPathTypeExtSubDomain:
actualVersion = pathVersion.GetSubDomainVersion();
break;
case NKikimrSchemeOp::EPathTypeTable:
actualVersion = pathVersion.GetTableSchemaVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeBlockStoreVolume:
actualVersion = pathVersion.GetBSVVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeFileStore:
actualVersion = pathVersion.GetFileStoreVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeKesus:
actualVersion = pathVersion.GetKesusVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeRtmrVolume:
actualVersion = pathVersion.GetRTMRVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeSolomonVolume:
actualVersion = pathVersion.GetSolomonVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeTableIndex:
actualVersion = pathVersion.GetTableIndexVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeColumnStore:
actualVersion = pathVersion.GetColumnStoreVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeColumnTable:
actualVersion = pathVersion.GetColumnTableVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeCdcStream:
actualVersion = pathVersion.GetCdcStreamVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeSequence:
actualVersion = pathVersion.GetSequenceVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeReplication:
actualVersion = pathVersion.GetReplicationVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeExternalTable:
actualVersion = pathVersion.GetExternalTableVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeExternalDataSource:
actualVersion = pathVersion.GetExternalDataSourceVersion();
break;
case NKikimrSchemeOp::EPathType::EPathTypeView:
actualVersion = pathVersion.GetViewVersion();
break;
default:
actualVersion = pathVersion.GetGeneralVersion();
break;
}
} else {
actualVersion = pathVersion.GetGeneralVersion();
}

if (requiredVersion != actualVersion) {
errStr = TStringBuilder()
<< "fail user constraint in ApplyIf section:"
Expand Down

0 comments on commit d1fcb9c

Please sign in to comment.