Skip to content

Conversation

@Yasasr1
Copy link

@Yasasr1 Yasasr1 commented Oct 8, 2025

Purpose

This pull request introduces improvements to concurrency handling and error recovery in the registry codebase. The main changes focus on preventing race conditions during tenant initialization and ensuring robust handling of database constraint violations when adding paths.

Concurrency and synchronization improvements:

  • Added tenant-specific locking in RegistryUtils.java to prevent race conditions during tenant initialization by synchronizing on a per-tenant lock object. (initializeTenant, getTenantInitializationLock)

Database error handling enhancements:

  • Improved handling of constraint violations in JDBCPathCache.java by introducing getPathIDAfterRollback, which rolls back aborted transactions and retries path ID lookup after a failed insert due to a duplicate path. This change is applied in both overloaded addEntry methods.

Related issue

Copilot AI review requested due to automatic review settings October 8, 2025 11:20
* @param path the path that caused the constraint violation
* @return the existing path ID if found, or -1 if not found
*/
private int getPathIDAfterRollback(AbstractConnection conn, String path) throws SQLException {

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
private int getPathIDAfterRollback(AbstractConnection conn, String path) throws SQLException {
private int getPathIDAfterRollback(AbstractConnection conn, String path) throws SQLException {
if (log.isDebugEnabled()) {
log.debug("Attempting to retrieve path ID after rollback for path: " + path);
}

Copy link

@wso2-engineering wso2-engineering bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
  • Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.

✅ Before merging this pull request:

  • Review all AI-generated comments for accuracy and relevance.
  • Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Comment Accepted (Y/N) Reason
#### Log Improvement Suggestion No: 1
#### Log Improvement Suggestion No: 2
#### Log Improvement Suggestion No: 3
#### Log Improvement Suggestion No: 4
#### Log Improvement Suggestion No: 5
#### Log Improvement Suggestion No: 6
#### Log Improvement Suggestion No: 7
#### Log Improvement Suggestion No: 8

Copy link

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 race conditions during tenant initialization and improves database error handling for constraint violations. The changes focus on adding synchronization mechanisms and better transaction rollback handling to ensure robust concurrent operations.

  • Added tenant-specific synchronization locking to prevent race conditions during tenant initialization
  • Enhanced database error handling with proper transaction rollback for constraint violations
  • Improved error recovery by introducing a dedicated method for handling aborted transactions

Reviewed Changes

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

File Description
RegistryUtils.java Added tenant-specific locking mechanism with getTenantInitializationLock method and synchronized initializeTenant method
JDBCPathCache.java Enhanced constraint violation handling with getPathIDAfterRollback method and updated both addEntry methods to use it

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

@Yasasr1
Copy link
Author

Yasasr1 commented Oct 9, 2025

integration tests run in the fork
https://github.com/Yasasr1/product-is/actions/runs/18373109840

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/18375345415

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/18375345415
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/18375345415

@Yasasr1 Yasasr1 merged commit c1ad3ef into wso2:4.10.x Oct 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants