yugabyte-db
yugabyte-db copied to clipboard
[DocDB] Fix flaky CQL tests to wait on index tables to become readable
Jira Link: DB-3602
Description
We have a common race condition in our tests that is responsible for the flakiness in numerous tests, such as:
o.y.cql.PartialIndex.PartialIndexPart*
o.y.cql.PartialIndex.UniquePartialIndexPart*
o.y.cql.UserDefinedTypes.NestedUDTs
o.y.cql.SimpleQuery.2ndaryIndexes
o.y.cql.ReturnsClause.BatchDMLWithUniqueIndex
o.y.cql.IndexSelection.OrderByIndexScan
o.y.cql.IndexSelection.NullsInIndexScan
o.y.cql.Index.ReadWriteIndexTable
o.y.cql.YbBackup.YCQLBackupWithJsonIndex
o.y.cql.BooleanDataType.Index
o.y.cql.Index.CreateIndexOnStaticCol
o.y.cql.ReturnsClause.ReturnsStatusWithIndex
o.y.cql.ExplainPlan.SelectPlan*
On my machine, these tests fail about 5% of the time. This list is likely incomplete. The issue may affect any test that is 1) using CQL and 2) using secondary index tables.
In CQL, a CREATE INDEX
statement will generate async table alterations. The offending tests expect that these alterations will have completed by the time that the CREATE INDEX
returns. This is true most of the time, but the tests will fail if the table alterations are still outstanding.
For the Java tests, we can fix this with the existing waitForReadPermsOnAllIndexes
.