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: postgres plugin blocking call #36046

Merged

Conversation

NilanshBansal
Copy link
Contributor

@NilanshBansal NilanshBansal commented Sep 2, 2024

Description

This PR resolves the blockhound callout Blocking call! java.io.FileInputStream#readBytes in the /v1/actions/execute (POST) API call when used with Postgres Plugin.
This blocking call was present in the PostgresPlugin.java

Fixes #36008

Automation

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

🔍 Cypress test results

Tip

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


Mon, 02 Sep 2024 11:40:16 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Chores
    • Improved the readability and conciseness of the connection pool creation logic in the Postgres plugin, enhancing maintainability without affecting functionality.
    • Updated logging level from debug to info for better clarity on log messages.

@NilanshBansal NilanshBansal self-assigned this Sep 2, 2024
Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Walkthrough

The changes involve a modification in the datasourceCreate method of the PostgresPlugin class, specifically optimizing the connection pool creation process. The code has been refactored to improve readability and conciseness while maintaining the same functionality. Additionally, the logging level has been adjusted to reflect a change in the importance of the log message.

Changes

Files Change Summary
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/... Refactored datasourceCreate method for connection pool creation, simplifying the structure with a more concise lambda expression and changing logging level from debug to info.

Assessment against linked issues

Objective Addressed Explanation
Debugging Initial Blockhound Errors on /actions/execute API (#36008) The changes do not address the Blockhound error issue directly.

In the code where connections flow,
A simpler path begins to show.
With concise lines, the logic's clear,
A cleaner dance, we hold so dear.
Refactored code, a sight to see,
In harmony, it runs so free! 🎉


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 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 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.
Early access features: disabled

We are currently testing the following features in early access:

  • Anthropic claude-3-5-sonnet for code reviews: Anthropic claims that the new Claude model has stronger code understanding and code generation capabilities than their previous models. Note: Our default code review model was also updated late last week. Please compare the quality of the reviews between the two models by toggling the early access feature.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues on the discussion post.

@github-actions github-actions bot added Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Pod Integrations Product Issues related to a specific integration Query & JS Pod Issues related to the query & JS Pod Task A simple Todo Bug Something isn't working labels Sep 2, 2024
@NilanshBansal NilanshBansal added ok-to-test Required label for CI and removed Bug Something isn't working labels Sep 2, 2024
@github-actions github-actions bot added the Bug Something isn't working label Sep 2, 2024
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 e501413 and 1213163.

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

657-657: Good catch! The change to use flatMap is correct.

Since the lambda passed to flatMap returns a Mono, using flatMap instead of map is the right choice. This change is approved.


658-661: Excellent refactoring! The condensed lambda expression improves readability.

The updated version condenses the verbose structure into a single line using a streamlined lambda expression. This enhances code readability without altering the underlying functionality. The control flow of retrieving the maximum pool size and creating the connection pool accordingly remains intact.

This refactoring is a nice improvement. The changes are approved.

@NilanshBansal NilanshBansal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Sep 2, 2024
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 1213163 and 9224297.

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

657-661: Excellent work! The code changes look great.

The changes enhance the datasourceCreate method by:

  • Using flatMap to elegantly chain the Mono for max pool size with pool creation logic
  • Deferring pool creation until subscription using Mono.fromCallable
  • Bumping logging level to info which is more suitable

Keep up the good work!

@NilanshBansal NilanshBansal enabled auto-merge (squash) September 2, 2024 11:21
@NilanshBansal NilanshBansal merged commit 4516129 into release Sep 2, 2024
51 of 58 checks passed
@NilanshBansal NilanshBansal deleted the fix/issue-36008/blocking-call-postgres-plugin branch September 2, 2024 11:45
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
## Description
This PR resolves the blockhound callout `Blocking call!
java.io.FileInputStream#readBytes` in the /v1/actions/execute (POST) API
call when used with Postgres Plugin.
This blocking call was present in the PostgresPlugin.java

Fixes appsmithorg#36008   

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/10666128697>
> Commit: 9224297
> Workflow: `PR Automation test suite`
> Tags: `@tag.Sanity`
> Spec: ``
> <hr>Mon, 02 Sep 2024 11:19:10 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Chores**
- Improved the readability and conciseness of the connection pool
creation logic in the Postgres plugin, enhancing maintainability without
affecting functionality.
- Updated logging level from debug to info for better clarity on log
messages.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Pod Integrations Product Issues related to a specific integration ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Debugging Initial Blockhound Errors on /actions/execute API
2 participants