Skip to content

chore: added logs for connection pool in mysql#35255

Merged
sneha122 merged 3 commits intoreleasefrom
chore/memory-leak-logs-added
Jul 30, 2024
Merged

chore: added logs for connection pool in mysql#35255
sneha122 merged 3 commits intoreleasefrom
chore/memory-leak-logs-added

Conversation

@sneha122
Copy link
Contributor

@sneha122 sneha122 commented Jul 29, 2024

Description

This PR adds logs around connection pool metrics in order to debug memory leak issue #34028

Following metrics are logged for Get strcuture and Excute query calls:

  • Acquired - It indicates number of connections acquired from pool
  • Idle - Number of connections sitting idle in the connection pool
  • Allocated - Number of connections active / idle in the pool
  • Pending - Number of connections pending to be acquired.

This information can help us understand if connections are not being released from the pool leading to memory leak.

Fixes #35158
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.Datasource"

🔍 Cypress test results

Tip

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


Mon, 29 Jul 2024 17:38:32 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced logging capabilities for the MySqlPlugin connection pool metrics, improving observability during database operations.
  • Bug Fixes

    • Improved monitoring tools to help identify potential memory leak issues related to connection pool usage.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 29, 2024

Walkthrough

The recent changes to the MySqlPlugin enhance connection pool monitoring by integrating detailed logging of connection pool metrics. This upgrade aims to assist in diagnosing potential memory leak issues, providing insights into resource usage during database operations. The implementation includes logging key metrics such as acquired, pending, allocated, and idle connection counts, thereby improving the overall observability and maintainability of the plugin.

Changes

File Change Summary
.../MySqlPlugin.java Added logging for connection pool metrics to aid in identifying memory leaks. Metrics logged include acquired, pending, allocated, and idle connection counts.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MySqlPlugin
    participant ConnectionPool

    User->>MySqlPlugin: Execute Query
    MySqlPlugin->>ConnectionPool: Request Connection
    ConnectionPool-->>MySqlPlugin: Provide Connection
    MySqlPlugin->>ConnectionPool: Log Pool Metrics
    MySqlPlugin->>User: Return Query Result
Loading

Assessment against linked issues

Objective Addressed Explanation
Add logging mechanism for connection pool metrics ( #35158 )
Understand causes of memory leak issue ( #34028 )

The metrics now shine bright,
Guiding us through the night.
With each connection we log,
Memory leaks no longer a fog.
Cheers to insights, clear and keen,
In the code, magic is seen! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added Integrations Product Issues related to a specific integration MySQL Issues related to MySQL plugin Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Jul 29, 2024
@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@sneha122 sneha122 requested a review from NilanshBansal July 29, 2024 10:03
@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/10142214768.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 35255.
recreate: .

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58f0c0d and 723e502.

Files selected for processing (1)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (4 hunks)
Additional comments not posted (2)
app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (2)

372-384: Great addition! Logging connection pool metrics is crucial for debugging.

The added logging statements will help monitor the connection pool's status during query execution, which is essential for diagnosing memory leaks.


730-741: Well done! Logging connection pool metrics before retrieving the data source structure is a good practice.

These logs will provide valuable insights into the connection pool's status, aiding in diagnosing memory leaks.

@github-actions
Copy link

Deploy-Preview-URL: https://ce-35255.dp.appsmith.com

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.refactors.ce.RefactoringServiceTest#testIsNameAllowed_withRepeatedActionCollectionName_throwsError

@sneha122 sneha122 requested a review from NilanshBansal July 29, 2024 12:20
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 723e502 and 786e108.

Files selected for processing (1)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.solutions.ce.ActionExecutionSolutionCETest#testActionExecute

@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@sneha122 sneha122 added the ok-to-test Required label for CI label Jul 29, 2024
@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/10148654041.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 35255.
recreate: .

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 786e108 and 2588f79.

Files selected for processing (1)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java

@github-actions
Copy link

Deploy-Preview-URL: https://ce-35255.dp.appsmith.com

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.services.ce.ThemeImportableServiceCETest#importThemesToApplication_WhenBothImportedThemesAreCustom_NewThemesCreated
  • com.appsmith.server.solutions.AuthenticationServiceTest#testGetAuthorizationCodeURL_validDatasourceAndBranchName

Copy link
Contributor

@NilanshBansal NilanshBansal left a comment

Choose a reason for hiding this comment

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

Code LGTM.
@sneha122 is checking the failing server tests.

@sneha122
Copy link
Contributor Author

Both the failing tests are passing locally, triggering a re run

@sneha122
Copy link
Contributor Author

Merging this PR even though log.info are not visible on mezmo, started a thread here. Closing this PR, will take up this issue separately.

@sneha122 sneha122 merged commit 28c8c5a into release Jul 30, 2024
@sneha122 sneha122 deleted the chore/memory-leak-logs-added branch July 30, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integrations Product Issues related to a specific integration MySQL Issues related to MySQL plugin ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Add more logs for connection pool metrics in mysql plugin

2 participants