Skip to content

Commit

Permalink
YQ-3192 Fix validate settings fail on start (ydb-platform#4390)
Browse files Browse the repository at this point in the history
  • Loading branch information
kardymonds authored May 12, 2024
1 parent 28bdd95 commit 60f2bd7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ydb/public/sdk/cpp/client/ydb_topic/impl/read_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ void TReadSession::UpdateOffsets(const NTable::TTransaction& tx)
bool TReadSession::Close(TDuration timeout) {
LOG_LAZY(Log, TLOG_INFO, GetLogPrefix() << "Closing read session. Close timeout: " << timeout);
// Log final counters.
CountersLogger->Stop();
if (CountersLogger) {
CountersLogger->Stop();
}
with_lock (Lock) {
if (DumpCountersContext) {
DumpCountersContext->Cancel();
Expand Down Expand Up @@ -352,7 +354,9 @@ void TReadSession::AbortImpl(TDeferredActions<false>&) {
if (DumpCountersContext) {
DumpCountersContext->Cancel();
}
CbContext->TryGet()->Abort();
if (CbContext) {
CbContext->TryGet()->Abort();
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions ydb/public/sdk/cpp/client/ydb_topic/ut/basic_usage_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,23 @@ Y_UNIT_TEST_SUITE(TSettingsValidation) {
//Specify msg groupId and don't specify deduplication. Should work with dedup enable
runTest({}, "msgGroup", {}, true, EExpectedTestResult::SUCCESS);
runTest({}, "msgGroup", {}, false, EExpectedTestResult::SUCCESS);
}

Y_UNIT_TEST(ValidateSettingsFailOnStart) {
TTopicSdkTestSetup setup(TEST_CASE_NAME);
TTopicClient client = setup.MakeClient();

auto readSettings = TReadSessionSettings()
.ConsumerName(TEST_CONSUMER)
.MaxMemoryUsageBytes(0)
.AppendTopics(TEST_TOPIC);

auto readSession = client.CreateReadSession(readSettings);
auto event = readSession->GetEvent(true);
UNIT_ASSERT(event.Defined());

auto& closeEvent = std::get<NYdb::NTopic::TSessionClosedEvent>(*event);
UNIT_ASSERT(closeEvent.DebugString().Contains("Too small max memory usage"));
}

} // Y_UNIT_TEST_SUITE(TSettingsValidation)
Expand Down

0 comments on commit 60f2bd7

Please sign in to comment.