Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added configurable connection pool support for mssql #38818

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

sneha122
Copy link
Contributor

@sneha122 sneha122 commented Jan 23, 2025

Description

With current implementation, MSSQL is configured with HikariCP to have maximum pool size of 10. But this means that if multiple concurrent users are accessing multiple queries of the same datasource at the same time, some of the queries might time out due to max pool size of 10. We have encountered this issue in https://theappsmith.slack.com/archives/C0341RERY4R/p1736150680663059. Where 40-50 concurrent users are simultaneously making 20-30 queries to MSSQL database.

This PR makes this connection pool size configurable from admin settings for MSSQL as well.

Fixes #https://github.com/appsmithorg/appsmith-ee/issues/5928
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12925650660
Commit: ebda936
Cypress dashboard.
Tags: @tag.All
Spec:


Thu, 23 Jan 2025 11:18:35 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced connection pool configuration for MSSQL plugin
    • Added support for dynamically setting maximum connection pool size
  • Improvements

    • Increased flexibility in database connection management
    • Implemented configurable connection pool settings
  • Tests

    • Added mock configuration for testing connection pool settings

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

The pull request introduces enhanced configurability for the MSSQL plugin's connection pool management. By integrating a ConnectionPoolConfig object, the changes allow dynamic configuration of the maximum connection pool size. The modifications enable retrieving the pool size configuration asynchronously, replacing the previous hardcoded approach with a more flexible mechanism that can potentially draw configuration from external settings.

Changes

File Change Summary
app/server/appsmith-plugins/mssqlPlugin/src/main/java/.../MssqlPlugin.java Added connectionPoolConfig field, updated constructor and datasourceCreate method to support dynamic connection pool size configuration
app/server/appsmith-plugins/mssqlPlugin/src/test/java/.../MssqlTestDBContainerManager.java Introduced MockConnectionPoolConfig inner class to provide a mock implementation for connection pool size configuration in tests

Sequence Diagram

sequenceDiagram
    participant Executor as MssqlPluginExecutor
    participant Config as ConnectionPoolConfig
    participant DataSource as HikariDataSource
    
    Executor->>Config: getMaxConnectionPoolSize()
    Config-->>Executor: Mono<Integer> maxPoolSize
    Executor->>DataSource: createConnectionPool(config, maxPoolSize)
Loading

Possibly related issues

Possibly related PRs

Suggested labels

Bug, High, Production, Needs Triaging, Query & JS Pod, Integrations Product, ok-to-test, Integrations Pod General, MariaDB

Suggested reviewers

  • AnaghHegde
  • ApekshaBhosale

Poem

🔌 Connections dance, no longer bound
By hardcoded limits, freedom found
Pool size flexes, config's delight
MSSQL plugin, scaling new height!
Async magic, code's sweet refrain 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sneha122 sneha122 added the ok-to-test Required label for CI label Jan 23, 2025
@github-actions github-actions bot added the Bug Something isn't working label Jan 23, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (1)

Line range hint 575-590: Add input validation for maxPoolSize

While the implementation is correct, consider adding validation to ensure maxPoolSize is not negative or unreasonably large.

 private static HikariDataSource createConnectionPool(
         DatasourceConfiguration datasourceConfiguration, Integer maxPoolSize) throws AppsmithPluginException {
+    if (maxPoolSize != null && maxPoolSize <= 0) {
+        throw new AppsmithPluginException(
+            AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
+            "Maximum pool size must be greater than 0");
+    }
     // ... rest of the method
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7871822 and ebda936.

📒 Files selected for processing (2)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (5 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlTestDBContainerManager.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: server-unit-tests / server-unit-tests
🔇 Additional comments (4)
app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlTestDBContainerManager.java (2)

23-28: LGTM - Mock implementation is clean and focused

The mock implementation provides a clear, single-responsibility test double for connection pool configuration.


30-31: LGTM - Proper initialization with mock config

The static executor is correctly initialized with the mock connection pool configuration.

app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (2)

118-122: LGTM - Clean dependency injection pattern

The connection pool configuration is properly injected through constructor, following good dependency injection practices.


366-372: LGTM - Well-structured reactive flow

The datasource creation properly handles the async nature of pool size configuration using reactive patterns.

Copy link

Failed server tests

  • com.appsmith.server.git.ServerSchemaMigrationEnforcerTest#saveGitRepo_ImportAndThenExport_diffOccurs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants