Skip to content

Commit fa37fe5

Browse files
committed
Fix BuildIndex/Export/Import operation listing order (#17814)
1 parent 21037c5 commit fa37fe5

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

ydb/core/tx/schemeshard/schemeshard_build_index__list.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,28 @@ struct TSchemeShard::TIndexBuilder::TTxList: public TSchemeShard::TIndexBuilder:
4343
const ui64 pageSize = Min(record.GetPageSize() ? Max(record.GetPageSize(), MinPageSize) : DefaultPageSize, MaxPageSize);
4444

4545

46-
auto it = Self->IndexBuilds.begin();
46+
auto it = Self->IndexBuilds.end();
4747
ui64 skip = (page - 1) * pageSize;
48-
while ((it != Self->IndexBuilds.end()) && skip) {
48+
while ((it != Self->IndexBuilds.begin()) && skip) {
49+
--it;
4950
if (it->second->DomainPathId == domainPathId) {
5051
--skip;
5152
}
52-
++it;
5353
}
5454

5555
auto& respRecord = Response->Record;
5656
respRecord.SetStatus(Ydb::StatusIds::SUCCESS);
5757

5858
ui64 size = 0;
59-
while ((it != Self->IndexBuilds.end()) && size < pageSize) {
59+
while ((it != Self->IndexBuilds.begin()) && size < pageSize) {
60+
--it;
6061
if (it->second->DomainPathId == domainPathId) {
6162
Fill(*respRecord.MutableEntries()->Add(), *it->second);
6263
++size;
6364
}
64-
++it;
6565
}
6666

67-
if (it == Self->IndexBuilds.end()) {
67+
if (it == Self->IndexBuilds.begin()) {
6868
respRecord.SetNextPageToken("0");
6969
} else {
7070
respRecord.SetNextPageToken(ToString(page + 1));

ydb/core/tx/schemeshard/schemeshard_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ class TSchemeShard
12501250
// } // NLongRunningCommon
12511251

12521252
// namespace NExport {
1253-
THashMap<ui64, TExportInfo::TPtr> Exports;
1253+
TMap<ui64, TExportInfo::TPtr> Exports;
12541254
THashMap<TString, TExportInfo::TPtr> ExportsByUid;
12551255
THashMap<TTxId, std::pair<ui64, ui32>> TxIdToExport;
12561256
THashMap<TTxId, THashSet<ui64>> TxIdToDependentExport;
@@ -1301,7 +1301,7 @@ class TSchemeShard
13011301
// } // NExport
13021302

13031303
// namespace NImport {
1304-
THashMap<ui64, TImportInfo::TPtr> Imports;
1304+
TMap<ui64, TImportInfo::TPtr> Imports;
13051305
THashMap<TString, TImportInfo::TPtr> ImportsByUid;
13061306
THashMap<TTxId, std::pair<ui64, ui32>> TxIdToImport;
13071307
THashSet<TActorId> RunningImportSchemeGetters;
@@ -1369,7 +1369,7 @@ class TSchemeShard
13691369
// namespace NIndexBuilder {
13701370
TControlWrapper AllowDataColumnForIndexTable;
13711371

1372-
THashMap<TIndexBuildId, TIndexBuildInfo::TPtr> IndexBuilds;
1372+
TMap<TIndexBuildId, TIndexBuildInfo::TPtr> IndexBuilds;
13731373
THashMap<TString, TIndexBuildInfo::TPtr> IndexBuildsByUid;
13741374
THashMap<TTxId, TIndexBuildId> TxIdToIndexBuilds;
13751375

ydb/core/tx/schemeshard/schemeshard_xxport__get.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct TSchemeShard::TXxport::TTxGet: public TSchemeShard::TXxport::TTxBase {
2020
{
2121
}
2222

23-
bool DoExecuteImpl(const THashMap<ui64, typename TInfo::TPtr>& container, TTransactionContext&, const TActorContext&) {
23+
bool DoExecuteImpl(const TMap<ui64, typename TInfo::TPtr>& container, TTransactionContext&, const TActorContext&) {
2424
const auto& request = Request->Get()->Record;
2525

2626
auto response = MakeHolder<TEvResponse>();

ydb/core/tx/schemeshard/schemeshard_xxport__list.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct TSchemeShard::TXxport::TTxList: public TSchemeShard::TXxport::TTxBase {
2525
{
2626
}
2727

28-
bool DoExecuteImpl(const THashMap<ui64, typename TInfo::TPtr>& container, TTransactionContext&, const TActorContext&) {
28+
bool DoExecuteImpl(const TMap<ui64, typename TInfo::TPtr>& container, TTransactionContext&, const TActorContext&) {
2929
const auto& record = Request->Get()->Record;
3030
const auto& request = record.GetRequest();
3131

@@ -54,26 +54,26 @@ struct TSchemeShard::TXxport::TTxList: public TSchemeShard::TXxport::TTxBase {
5454

5555
resp.SetStatus(Ydb::StatusIds::SUCCESS);
5656

57-
auto it = container.begin();
57+
auto it = container.end();
5858
ui64 skip = (page - 1) * pageSize;
59-
while (it != container.end() && skip) {
59+
while (it != container.begin() && skip) {
60+
--it;
6061
if (IsSameDomain(it->second, domainPathId) && it->second->Kind == kind) {
6162
--skip;
6263
}
63-
++it;
6464
}
6565

6666
ui64 size = 0;
67-
while (it != container.end() && size < pageSize) {
67+
while (it != container.begin() && size < pageSize) {
68+
--it;
6869
if (IsSameDomain(it->second, domainPathId) && it->second->Kind == kind) {
6970
Self->FromXxportInfo(*resp.MutableEntries()->Add(), it->second);
7071
++size;
7172
}
72-
++it;
7373
}
7474

75-
if (it == container.end()) {
76-
resp.SetNextPageToken("1");
75+
if (it == container.begin()) {
76+
resp.SetNextPageToken("0");
7777
} else {
7878
resp.SetNextPageToken(ToString(page + 1));
7979
}

ydb/core/viewer/tests/canondata/result.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
"status_code": 200,
44
"text": "1\n"
55
},
6+
"test.test_operations_list": {
7+
"next_page_token": "0",
8+
"status": "SUCCESS"
9+
},
10+
"test.test_operations_list_page": {
11+
"next_page_token": "0",
12+
"status": "SUCCESS"
13+
},
14+
"test.test_operations_list_page_bad": {
15+
"status_code": 400,
16+
"text": "offset must be a multiple of limit"
17+
},
618
"test.test_pqrb_tablet": {
719
"response_create_topic": {
820
"version": "not-zero-number"

0 commit comments

Comments
 (0)