Skip to content

Commit 4ab2331

Browse files
committed
YT-22250: Fill tableMountInfo.UpperCapBound for chaos queues like it's done for replicated tables
commit_hash:5c2672609977be17b7392405cae5ab086d728dee
1 parent ca2bf22 commit 4ab2331

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

yt/yt/client/api/rpc_proxy/table_mount_cache.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ class TTableMountCache
117117
tableInfo->UpperCapBound = MaxKey();
118118
} else {
119119
tableInfo->LowerCapBound = MakeUnversionedOwningRow(static_cast<int>(0));
120-
tableInfo->UpperCapBound = MakeUnversionedOwningRow(static_cast<int>(tableInfo->Tablets.size()));
120+
121+
auto tabletCount = tableInfo->IsChaosReplicated()
122+
? rsp->tablet_count()
123+
: static_cast<int>(tableInfo->Tablets.size());
124+
tableInfo->UpperCapBound = MakeUnversionedOwningRow(tabletCount);
121125
}
122126

123127
YT_LOG_DEBUG("Table mount info received (Path: %v, TableId: %v, TabletCount: %v, Dynamic: %v)",

yt/yt/client/driver/driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ class TDriver
230230
REGISTER (TGetTablePivotKeysCommand, "get_table_pivot_keys", Null, Structured, false, false, ApiVersion4);
231231
REGISTER (TGetTabletInfosCommand, "get_tablet_infos", Null, Structured, true, false, ApiVersion4);
232232
REGISTER (TGetTabletErrorsCommand, "get_tablet_errors", Null, Structured, true, false, ApiVersion4);
233+
REGISTER (TGetTableMountInfoCommand, "get_table_mount_info", Null, Structured, false, false, ApiVersion4);
233234

234235
REGISTER (TCreateTableBackupCommand, "create_table_backup", Null, Null, true, false, ApiVersion3);
235236
REGISTER (TRestoreTableBackupCommand, "restore_table_backup", Null, Null, true, false, ApiVersion3);

yt/yt/client/driver/internal_commands.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <yt/yt/client/chunk_client/config.h>
66

7+
#include <yt/yt/client/tablet_client/table_mount_cache.h>
8+
79
#include <yt/yt/core/ytree/fluent.h>
810

911
namespace NYT::NDriver {

yt/yt/client/driver/table_commands.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,4 +1814,35 @@ void TGetTabletErrorsCommand::DoExecute(ICommandContextPtr context)
18141814

18151815
////////////////////////////////////////////////////////////////////////////////
18161816

1817+
void TGetTableMountInfoCommand::Register(TRegistrar registrar)
1818+
{
1819+
registrar.Parameter("path", &TThis::Path_);
1820+
}
1821+
1822+
void TGetTableMountInfoCommand::DoExecute(ICommandContextPtr context)
1823+
{
1824+
auto tableMountCache = context->GetClient()->GetTableMountCache();
1825+
auto tableInfo = WaitFor(tableMountCache->GetTableInfo(Path_))
1826+
.ValueOrThrow();
1827+
1828+
// Rudimentary, for tests only
1829+
context->ProduceOutputValue(BuildYsonStringFluently()
1830+
.BeginMap()
1831+
.Item("lower_cap_bound").Value(tableInfo->LowerCapBound)
1832+
.Item("upper_cap_bound").Value(tableInfo->UpperCapBound)
1833+
.Item("primary_revision").Value(tableInfo->PrimaryRevision)
1834+
.Item("secondary_revision").Value(tableInfo->SecondaryRevision)
1835+
.Item("schemas")
1836+
.DoMap([&tableInfo] (auto fluent) {
1837+
for (auto kind : TEnumTraits<ETableSchemaKind>::GetDomainValues()) {
1838+
if (auto schemaPtr = tableInfo->Schemas[kind]) {
1839+
fluent.Item(ToString(kind)).Value(schemaPtr);
1840+
}
1841+
}
1842+
})
1843+
.EndMap());
1844+
}
1845+
1846+
////////////////////////////////////////////////////////////////////////////////
1847+
18171848
} // namespace NYT::NDriver

yt/yt/client/driver/table_commands.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,23 @@ class TRestoreTableBackupCommand
606606

607607
////////////////////////////////////////////////////////////////////////////////
608608

609+
struct TGetTableMountInfoCommandOptions
610+
{ };
611+
612+
class TGetTableMountInfoCommand
613+
: public TTypedCommand<TGetTableMountInfoCommandOptions>
614+
{
615+
public:
616+
REGISTER_YSON_STRUCT_LITE(TGetTableMountInfoCommand);
617+
618+
static void Register(TRegistrar registrar);
619+
620+
private:
621+
NYTree::TYPath Path_;
622+
623+
void DoExecute(ICommandContextPtr context) override;
624+
};
625+
626+
////////////////////////////////////////////////////////////////////////////////
627+
609628
} // namespace NYT::NDriver

yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,7 @@ message TRspGetTableMountInfo
14651465
repeated TReplicaInfo replicas = 6;
14661466
optional string physical_path = 7;
14671467
repeated TIndexInfo indices = 8;
1468+
optional int32 tablet_count = 9;
14681469
}
14691470

14701471
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)