Skip to content

Commit

Permalink
[#26119] DocDB: Fix PgIndexBackfillTest.VectorIndex flakiness
Browse files Browse the repository at this point in the history
Summary:
Even in single dimension HNSW could produce incomplete result.
And we cannot use it for consistency testing.
Relaxed requirements for query based check.
It is not a problem, since we already use VerifyVectorIndexes for consistency check.

Also ensured that intents applied before VerifyVectorIndexes.
Jira: DB-15446

Test Plan: Jenkins

Reviewers: arybochkin

Reviewed By: arybochkin

Subscribers: ybase, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D42237
  • Loading branch information
spolitov committed Mar 3, 2025
1 parent 7325672 commit add35db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ private Path runQueryDiagnostics(Statement statement, String queryId,
return Paths.get(resultSet.getString("yb_query_diagnostics"));
}

private void waitForBundleCompletion(String queryId, Statement statement) throws Exception {
waitForBundleCompletion(queryId, statement, 0);
}
/*
* Waits for the bundle to complete by checking the yb_query_diagnostics_status view.
*/
Expand Down
13 changes: 12 additions & 1 deletion src/yb/yql/pgwrapper/pg_index_backfill-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2669,11 +2669,18 @@ struct VectorIndexWriter {
}

void Verify(PGConn& conn) {
int num_bad_results = 0;
for (int i = 2; i < counter.load(); ++i) {
auto rows = ASSERT_RESULT(conn.FetchAllAsString(Format(
"SELECT id FROM test ORDER BY embedding <-> '[$0]' LIMIT 3", i * 1.0 - 0.01)));
ASSERT_EQ(rows, Format("$0; $1; $2", i, i - 1, i + 1));
auto expected = Format("$0; $1; $2", i, i - 1, i + 1);
if (rows != expected) {
LOG(INFO) << "Bad result: " << rows << " vs " << expected;
++num_bad_results;
}
}
// Expect recall 98% or better.
ASSERT_LE(num_bad_results, counter.load() / 50);
}
};

Expand Down Expand Up @@ -2710,6 +2717,10 @@ TEST_F(PgIndexBackfillTest, VectorIndex) {
LOG(INFO) << "Max time without inserts: " << writer.max_time_without_inserts;
ASSERT_LT(writer.max_time_without_inserts, 1s * kBackfillSleepSec);
SCOPED_TRACE(Format("Total rows: $0", writer.counter.load()));

// VerifyVectorIndexes does not take intents into account, so could produce false failure.
ASSERT_OK(cluster_->WaitForAllIntentsApplied(30s * kTimeMultiplier));

for (size_t i = 0; i != cluster_->num_tablet_servers(); ++i) {
tserver::VerifyVectorIndexesRequestPB req;
tserver::VerifyVectorIndexesResponsePB resp;
Expand Down

0 comments on commit add35db

Please sign in to comment.