Skip to content

Conversation

@KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Oct 14, 2025

Description

This PR adds more waits for cache expiry in integration test cases for administrative operations. The purpose is to resolve the test failure issue caused by stale metadata cache on Cluster side.

Related issues and/or PRs

Changes made

  • Adds more waits for table metadata cache expiry.
  • Update cases with DMLs to use a unique table name to avoid the stale cache issue.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@KodaiD KodaiD self-assigned this Oct 14, 2025
@KodaiD
Copy link
Contributor Author

KodaiD commented Oct 14, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses flaky integration tests caused by metadata cache staleness. The changes introduce two strategies: adding explicit waits for cache expiry and refactoring tests to use unique table names to ensure isolation.

The refactoring to use unique table names in DistributedTransactionAdminIntegrationTestBase is a great improvement. It makes the tests more robust and isolated, and the code is cleaner with the improved use of try-with-resources.

The addition of sleepUninterruptibly(1, TimeUnit.SECONDS) is a pragmatic fix for the caching issue. However, the sleep duration 1 is a magic number. I've left comments suggesting to extract this value into a shared constant in the DistributedTransactionAdminIntegrationTestBase class to improve readability and maintainability.

Overall, the changes are good and should help improve the stability of the test suite.

@KodaiD KodaiD marked this pull request as ready for review October 14, 2025 10:07
@KodaiD KodaiD requested review from brfrn169 and Copilot October 14, 2025 10:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses test failure issues caused by stale metadata cache in integration tests by adding cache expiry waits and using unique table names for DML operations.

  • Adds 1-second waits before transactional insert and scan operations to allow cache expiry
  • Updates test methods to use unique table names instead of shared ones to avoid stale cache conflicts
  • Refactors test cases to use try-with-resources for better resource management

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
SingleCrudOperationTransactionAdminIntegrationTestBase.java Added cache expiry waits in transactional operations
ConsensusCommitAdminIntegrationTestBase.java Added cache expiry waits in transactional operations
DistributedTransactionAdminIntegrationTestBase.java Used unique table names and improved resource management in DML test cases
JdbcTransactionAdminIntegrationTest.java Added cache expiry waits in transactional operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@KodaiD
Copy link
Contributor Author

KodaiD commented Oct 15, 2025

To resolve the following test failure due to the Cassandra stale cache issue, I revised the code to use a separate transaction manager instance for each DML operation in f3f5726.

java.lang.IllegalArgumentException: DB-CORE-10016: The table does not exist. Table: int_test_tx_admin_cc1.table_for_create_index
	at com.scalar.db.transaction.consensuscommit.ConsensusCommitUtils.getTransactionTableMetadata(ConsensusCommitUtils.java:351)
	at com.scalar.db.transaction.consensuscommit.ConsensusCommitMutationOperationChecker.check(ConsensusCommitMutationOperationChecker.java:50)
	at com.scalar.db.transaction.consensuscommit.ConsensusCommitMutationOperationChecker.check(ConsensusCommitMutationOperationChecker.java:41)
	at com.scalar.db.transaction.consensuscommit.ConsensusCommit.checkMutation(ConsensusCommit.java:239)
	at com.scalar.db.transaction.consensuscommit.ConsensusCommit.insert(ConsensusCommit.java:128)
	at com.scalar.db.common.DecoratedDistributedTransaction.insert(DecoratedDistributedTransaction.java:114)
	at com.scalar.db.common.StateManagedDistributedTransactionManager$StateManagedTransaction.insert(StateManagedDistributedTransactionManager.java:113)
	at com.scalar.db.common.DecoratedDistributedTransaction.insert(DecoratedDistributedTransaction.java:114)
	at com.scalar.db.common.ActiveTransactionManagedDistributedTransactionManager$ActiveTransaction.insert(ActiveTransactionManagedDistributedTransactionManager.java:158)
	at com.scalar.db.transaction.consensuscommit.ConsensusCommitAdminIntegrationTestBase.transactionalInsert(ConsensusCommitAdminIntegrationTestBase.java:43)
	at com.scalar.db.api.DistributedTransactionAdminIntegrationTestBase.createIndex_ForAllDataTypesWithExistingData_ShouldCreateIndexesCorrectly(DistributedTransactionAdminIntegrationTestBase.java:569)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at java.util.ArrayList.forEach(ArrayList.java:1259)

@brfrn169 brfrn169 enabled auto-merge (squash) October 15, 2025 04:56
@brfrn169 brfrn169 disabled auto-merge October 15, 2025 04:56
@feeblefakie feeblefakie enabled auto-merge (squash) October 15, 2025 05:18
@brfrn169 brfrn169 requested a review from feeblefakie October 15, 2025 05:26
Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

brfrn169 pushed a commit that referenced this pull request Oct 17, 2025
brfrn169 pushed a commit that referenced this pull request Oct 17, 2025
brfrn169 pushed a commit that referenced this pull request Oct 17, 2025
brfrn169 pushed a commit that referenced this pull request Oct 17, 2025
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