Andrew Kyle Purtell created PHOENIX-8114:
--------------------------------------------
Summary: UpgradeIT view index sequence tests race their own
sequence creates
Key: PHOENIX-8114
URL: https://issues.apache.org/jira/browse/PHOENIX-8114
Project: Phoenix
Issue Type: Test
Components: test
Affects Versions: 5.3.2
Reporter: Andrew Kyle Purtell
Assignee: Andrew Kyle Purtell
Fix For: 5.4.0, 5.3.3
{{UpgradeIT.testMergeViewIndexSequences}} and
{{UpgradeIT.testMergeViewIndexSequencesWithNamespaces}} fail sometimes. The
failing test is different from run to run. Both failures have the same error:
{{java.lang.AssertionError: expected null, but
was:<org.apache.phoenix.schema.SequenceNotFoundException:
ERROR 1201 (42Z01): Sequence undefined. tableName=TEST.T_N000024_ID_>
at
org.apache.phoenix.end2end.UpgradeIT.testMergeViewIndexSequencesHelper(UpgradeIT.java:682)}}
In a full IT run, {{testMergeViewIndexSequencesWithNamespaces}} failed at line
663 on {{{}TEST._IDX_T_..._ID_{}}}. In the isolated rerun, that test passed and
{{testMergeViewIndexSequences}} failed at line 682.
The test races its own writes at millisecond resolution.
A Phoenix sequence follows the usual timestamp visibility rule: a read at
timestamp T sees only cells written strictly before T. The client cache check
and the server-side increment both use this rule. A sequence create writes its
row at exactly the timestamp that the caller supplies.
The test helper creates the legacy view index sequences at
{{{}EnvironmentEdgeManager.currentTimeMillis(){}}}. The merge code,
{{{}UpgradeUtil.mergeViewIndexIdSequences{}}}, also creates a new sequence at
the current time. The test then increments these sequences at a new
{{{}currentTimeMillis(){}}}. On a fast host, the create and the next read
sometimes fall in the same millisecond. The row is then not visible to the
read, and the increment fails with {{{}SequenceNotFoundException{}}}.
There are two such races. The namespace-mapped variant reads the legacy rows
directly after creating them. The other variant reads the sequence that the
merge has just created.
The test and the merge code came in with PHOENIX-5138. Production code is not
affected.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)