Use case
TestCursor::test_cache_size fails intermittently in CI. The third execute(query, cache_size=100) returns a new query ID instead of one of the two earlier ones:
AssertionError: assert 'ad46191a-…' in ['cbc9ad0e-…', '5b851bb1-…']
tests/pyathena/test_cursor.py:112
It failed twice in two days: in run 35939526000 on Python 3.12, and in run 36024670053 on Python 3.11. Both times, other pull requests' Test runs overlapped, and a rerun alone passed.
The cause is test isolation, not the cache feature.
cache_size=100 searches only the 100 most recent executions in the work group.
- The test uses the default
primary work group, which almost every other test also uses.
- While a single Test run is active,
primary receives 30–50 executions per second, so the test's own executions leave the window within a few seconds.
- Overlapping runs raise that rate further.
The rerun added in #811 applies only to Athena service-side error messages, so it doesn't cover this AssertionError. Running the three suites in parallel (#814) increases the rate in primary.
The investigation details are in the first comment.
Proposed change
- Run the tests that assert a cache hit in the
pyathena work group (ENV.work_group). That work group received about 40 executions during a whole Test run.
test_cache_size_with_work_group already does this.
- The same change applies to
test_cache_size and the cache-hit part of test_cache_expiration_time_with_cache_size.
- Tests that assert a cache miss, and the mocked schema/catalog tests, need no change.
- In
docs/usage.md, state that cache_size counts the most recent executions in the work group, including other clients' queries, so a busy work group can push a previous execution out of the window.
Alternatives considered:
- Increasing
cache_size in the tests (for example, to 1000) still depends on load. At the rates measured with overlapping runs, 1000 executions take only about 8–25 seconds. It also makes each lookup page through 20 ListQueryExecutions and BatchGetQueryExecution calls.
- A dedicated work group for the cache tests isolates them fully. However, it needs a CloudFormation, IAM, and environment variable change, and the
pyathena work group is already quiet enough.
- Adding the failure to the rerun list would hide the load dependency without removing it.
Validation plan (if implementing)
- Run the affected tests with
uv run --env-file .env pytest -n 1 tests/pyathena/test_cursor.py -k cache.
- Then run the full
just test pyathena in CI.
- Confirm the assertions still distinguish a hit from a miss.
This uses the existing test account's pyathena work group. No new AWS resources are needed.
Use case
TestCursor::test_cache_sizefails intermittently in CI. The thirdexecute(query, cache_size=100)returns a new query ID instead of one of the two earlier ones:It failed twice in two days: in run 35939526000 on Python 3.12, and in run 36024670053 on Python 3.11. Both times, other pull requests' Test runs overlapped, and a rerun alone passed.
The cause is test isolation, not the cache feature.
cache_size=100searches only the 100 most recent executions in the work group.primarywork group, which almost every other test also uses.primaryreceives 30–50 executions per second, so the test's own executions leave the window within a few seconds.The rerun added in #811 applies only to Athena service-side error messages, so it doesn't cover this
AssertionError. Running the three suites in parallel (#814) increases the rate inprimary.The investigation details are in the first comment.
Proposed change
pyathenawork group (ENV.work_group). That work group received about 40 executions during a whole Test run.test_cache_size_with_work_groupalready does this.test_cache_sizeand the cache-hit part oftest_cache_expiration_time_with_cache_size.docs/usage.md, state thatcache_sizecounts the most recent executions in the work group, including other clients' queries, so a busy work group can push a previous execution out of the window.Alternatives considered:
cache_sizein the tests (for example, to 1000) still depends on load. At the rates measured with overlapping runs, 1000 executions take only about 8–25 seconds. It also makes each lookup page through 20ListQueryExecutionsandBatchGetQueryExecutioncalls.pyathenawork group is already quiet enough.Validation plan (if implementing)
uv run --env-file .env pytest -n 1 tests/pyathena/test_cursor.py -k cache.just test pyathenain CI.This uses the existing test account's
pyathenawork group. No new AWS resources are needed.