Skip to content

HIVE-29642: Remove racy test-only counters from PartitionManagementTask#6520

Merged
saihemanth-cloudera merged 2 commits into
apache:masterfrom
konstantinb:HIVE-29642
Jun 11, 2026
Merged

HIVE-29642: Remove racy test-only counters from PartitionManagementTask#6520
saihemanth-cloudera merged 2 commits into
apache:masterfrom
konstantinb:HIVE-29642

Conversation

@konstantinb

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

HIVE-29642: Remove racy test-only counters from PartitionManagementTask

Remove the test-only static counters (completedAttempts, skippedAttempts) and their @VisibleForTesting accessors from PartitionManagementTask. Rewrite
TestPartitionManagement.testPartitionDiscoveryTransactionalTable (renamed to testPartitionDiscoveryTransactionalTableConcurrent to highlight the contention scenario) to verify the same properties
via a Log4j2 ListAppender that observes the existing skip and discovery log messages emitted by PartitionManagementTask.run().

Why are the changes needed?

The current test asserts that exactly 2 of 3 concurrent tasks are skipped, using test-only static counters in PartitionManagementTask. The assertion is flaky for two reasons. First, the JVM may
schedule the 3 tasks so they do not actually overlap, in which case no skips happen at all. Second, the counters themselves are racy: the skippedAttempts = 0 reset inside the lock can clear the
value while other threads are running skippedAttempts++ outside the lock. The counters were added in HIVE-20707 for this test and nothing in production reads them.

Does this PR introduce any user-facing change?

No. The only change in production source besides removing the counter fields is dropping the trailing "..#N" counter format from one INFO log message; the message prefix is unchanged.

How was this patch tested?

Ran TestPartitionManagement locally (11 tests, all pass). The counter race was empirically reproduced before the fix by inserting a short Thread.sleep right after lock.tryLock() in production,
which caused the original assertion to fail deterministically; the refactored test does not depend on this timing.

@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

@konstantinb

Copy link
Copy Markdown
Contributor Author

@saihemanth-cloudera, could you take a look when you have a moment, please? It's a small fix (HIVE-29642), CI is green — removes the racy test-only counters in PartitionManagementTask behind the intermittent TestPartitionManagement failures. Happy to address any feedback.

pinging you because you've worked in this area recently (#5991)

Thanks!

@saihemanth-cloudera saihemanth-cloudera left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@saihemanth-cloudera saihemanth-cloudera merged commit cce3edb into apache:master Jun 11, 2026
6 checks passed
@konstantinb konstantinb deleted the HIVE-29642 branch June 11, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants