Skip to content
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
7 changes: 7 additions & 0 deletions ydb/core/persqueue/pqtablet/partition/partition_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ TMaybe<TReadAnswer> TReadInfo::AddBlobsFromBody(const TVector<NPQ::TRequestedBlo
if (res.IsLastPart()) {
PartNo = 0;
++Offset;
if (LastOffset && Offset >= LastOffset) {
needStop = true;
break;
}
} else {
++PartNo;
}
Expand Down Expand Up @@ -657,6 +661,9 @@ TReadAnswer TReadInfo::FormAnswer(
if (updateUsage(writeBlob)) {
break;
}
if (LastOffset && Offset >= LastOffset) {
break;
}
}
}

Expand Down
49 changes: 34 additions & 15 deletions ydb/core/persqueue/ut/pq_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <ydb/core/persqueue/ut/common/pq_ut_common.h>
#include <ydb/core/security/ticket_parser.h>

#include <ydb/core/protos/grpc_pq_old.pb.h>

#include <ydb/core/testlib/fake_scheme_shard.h>
#include <ydb/core/testlib/tablet_helpers.h>

Expand Down Expand Up @@ -1470,10 +1472,22 @@ Y_UNIT_TEST(TestTimeRetention) {
});
}

Y_UNIT_TEST(TestCompactifiedWithRetention) {
// TODO(abcdef): temporarily deleted
return;
TString GetSerializedData(ui64 seqNo, const TString& payload, const TString& key) {
NKikimrPQClient::TDataChunk proto;
proto.SetSeqNo(seqNo);
proto.SetData(payload);
if (!key.empty()) {
auto *msgMeta = proto.AddMessageMeta();
msgMeta->set_key("__key");
msgMeta->set_value(key);
}
TString dataChunkStr;
bool res = proto.SerializeToString(&dataChunkStr);
Y_ABORT_UNLESS(res);
return dataChunkStr;
}

Y_UNIT_TEST(TestCompactifiedWithRetention) {
TTestContext tc;
RunTestWithReboots(tc.TabletIds, [&]() {
return tc.InitialEventsFilter.Prepare();
Expand All @@ -1485,24 +1499,29 @@ Y_UNIT_TEST(TestCompactifiedWithRetention) {

tc.Runtime->GetAppData(0).PQConfig.MutableCompactionConfig()->SetBlobsCount(0);

TVector<std::pair<ui64, TString>> data;
activeZone = PlainOrSoSlow(true, false);

ui64 key = 1;
TString s{32, 'c'};
ui32 pp = 8 + 4 + 2 + 9;
for (ui32 i = 0; i < 10; ++i) {
data.push_back({i + 1, s.substr(pp)});
}
auto getData = [&] () {
TVector<std::pair<ui64, TString>> data;
for (ui32 i = 0; i < 10; ++i) {
data.push_back({i + 1, GetSerializedData(i + 1, s.substr(pp), ToString(key++))});
}
return data;
};
activeZone = PlainOrSoSlow(true, false);


PQTabletPrepare({.maxCountInPartition=1000, .deleteTime=0, .lowWatermark=100, .enableCompactificationByKey = true}, {}, tc);
CmdWrite(0, "sourceid0", data, tc, false, {}, true);
CmdWrite(0, "sourceid1", data, tc, false);
CmdWrite(0, "sourceid2", data, tc, false);
CmdWrite(0, "sourceid0", getData(), tc, false, {}, true);
CmdWrite(0, "sourceid1", getData(), tc, false);
CmdWrite(0, "sourceid2", getData(), tc, false);
PQGetPartInfo(0, 30, tc);

PQTabletPrepare({.maxCountInPartition=1000, .deleteTime=0, .lowWatermark=100, .enableCompactificationByKey = false}, {}, tc);
CmdWrite(0, "sourceid3", data, tc, false);
CmdWrite(0, "sourceid4", data, tc, false);
CmdWrite(0, "sourceid5", data, tc, false);
CmdWrite(0, "sourceid3", getData(), tc, false);
CmdWrite(0, "sourceid4", getData(), tc, false);
CmdWrite(0, "sourceid5", getData(), tc, false);
Cerr << "Get part info with compactification disabled\n";
PQGetPartInfo(50, 60, tc);
});
Expand Down
16 changes: 11 additions & 5 deletions ydb/core/viewer/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,17 @@ def test_topic_data_cdc(cls):
'query': "alter table table_test_topic_data_cdc add changefeed updates_feed WITH (FORMAT = 'JSON', MODE = 'UPDATES', INITIAL_SCAN = TRUE)"
})

insert_response = cls.call_viewer("/viewer/query", {
'database': cls.dedicated_db,
'query': 'insert into table_test_topic_data_cdc(id, name) values(11, "elleven")',
'schema': 'multi'
})
insert_response = None
for i in range(3):
insert_response = cls.call_viewer("/viewer/query", {
'database': cls.dedicated_db,
'query': 'insert into table_test_topic_data_cdc(id, name) values(11, "elleven")',
'schema': 'multi'
})
if 'error' in insert_response and insert_response['error']['issue_code'] == 2034:
continue
else:
break

update_response = cls.call_viewer("/viewer/query", {
'database': cls.dedicated_db,
Expand Down
8 changes: 4 additions & 4 deletions ydb/services/persqueue_v1/persqueue_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3266,9 +3266,9 @@ Y_UNIT_TEST_SUITE(TPersQueueTest) {
Cerr << ">>>>> 2" << Endl << Flush;
auto info16 = server.AnnoyingClient->ReadFromPQ({DEFAULT_TOPIC_NAME, 0, 16, 16, "user"}, 16);

UNIT_ASSERT_VALUES_EQUAL(info0.BlobsFromCache, 2);
UNIT_ASSERT_VALUES_EQUAL(info16.BlobsFromCache, 2);
UNIT_ASSERT_VALUES_EQUAL(info0.BlobsFromDisk + info16.BlobsFromDisk, 1);
UNIT_ASSERT_VALUES_EQUAL(info0.BlobsFromCache, 1);
UNIT_ASSERT_VALUES_EQUAL(info16.BlobsFromCache, 1);
UNIT_ASSERT_VALUES_EQUAL(info0.BlobsFromDisk + info16.BlobsFromDisk, 3);

for (ui32 i = 0; i < 8; ++i)
server.AnnoyingClient->WriteToPQ({DEFAULT_TOPIC_NAME, 0, "source1", 32+i}, value);
Expand Down Expand Up @@ -3341,7 +3341,7 @@ Y_UNIT_TEST_SUITE(TPersQueueTest) {

UNIT_ASSERT(info_half1.BlobsFromCache > 0);
UNIT_ASSERT(info_half2.BlobsFromCache > 0);
UNIT_ASSERT_VALUES_EQUAL(info_half1.BlobsFromDisk, 0);
UNIT_ASSERT_VALUES_EQUAL(info_half1.BlobsFromDisk, 1); //Because of async compaction
UNIT_ASSERT_VALUES_EQUAL(info_half2.BlobsFromDisk, 0);
}
}
Expand Down
Loading