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: Clear all session for Spring upgrade #36695

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

nidhi-nair
Copy link
Contributor

@nidhi-nair nidhi-nair commented Oct 4, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
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=""

🔍 Cypress test results

Warning

Tests have not run on the HEAD 42bc1fc yet


Fri, 04 Oct 2024 07:56:44 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Chores
    • Updated the migration process to enhance Redis database management.
    • Improved method signatures for better clarity and functionality.

Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Walkthrough

The changes in this pull request involve significant modifications to the Migration063CacheBustSpringBoot3_3 class within the Appsmith server's migration package. The ReactiveRedisOperations dependency has been replaced with ReactiveRedisTemplate, and the method signature of execute has been updated to include a ReactiveRedisTemplate parameter. The implementation of the execute method now directly flushes the Redis database, while the rollbackExecution method remains unchanged.

Changes

File Change Summary
.../Migration063CacheBustSpringBoot3_3.java Replaced ReactiveRedisOperations with ReactiveRedisTemplate, updated execute method signature, and changed implementation to flush Redis directly.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test, Test

Suggested reviewers

  • sharat87
  • abhvsn
  • mohanarpit

🎉 In the land of code where changes bloom,
A migration class sheds its old costume.
With Redis now fresh, it flushes with glee,
A template so reactive, as swift as can be!
So let’s cheer for the updates, both bold and bright,
In the realm of Appsmith, all feels just right! 🎊


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 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.

@github-actions github-actions bot added the Bug Something isn't working label Oct 4, 2024

This comment was marked as off-topic.

This comment was marked as off-topic.

@nidhi-nair
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 7, 2024

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

Copy link

github-actions bot commented Oct 7, 2024

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

@nidhi-nair nidhi-nair marked this pull request as ready for review October 7, 2024 04:31
@nidhi-nair nidhi-nair requested a review from mohanarpit October 7, 2024 04:33
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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d1e788b and 42bc1fc.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration063CacheBustSpringBoot3_3.java (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration063CacheBustSpringBoot3_3.java (2)

7-8: Great job updating the imports appropriately

By importing ReactiveRedisTemplate and @Qualifier, you've set up the class to correctly inject the necessary Redis template. This ensures that the correct bean is used for Redis operations, which is essential for maintaining the application's stability.


18-25: Verify that flushing the Redis database is safe in all environments

Flushing the entire Redis database will remove all data stored in Redis. It's crucial to ensure that this action won't inadvertently affect other parts of the system, especially if Redis is used for more than just session management.

Would you like assistance in verifying that Redis is exclusively used for session data across the codebase? This can prevent unexpected data loss in other components.

Comment on lines +18 to +25
public void execute(
@Qualifier("reactiveRedisTemplate") final ReactiveRedisTemplate<String, Object> reactiveRedisTemplate) {
reactiveRedisTemplate
.getConnectionFactory()
.getReactiveConnection()
.serverCommands()
.flushDb()
.block();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure proper error handling for the Redis flush operation

It's important to handle potential exceptions when performing critical operations like flushing the Redis database. Without proper error handling, any failures during this operation could lead to unhandled exceptions and impact the application's stability.

Consider enhancing your code to gracefully handle any errors:

reactiveRedisTemplate
        .getConnectionFactory()
        .getReactiveConnection()
        .serverCommands()
        .flushDb()
        .doOnError(error -> log.error("Failed to flush Redis database during migration", error))
        .block();

This way, you log any exceptions, allowing for easier debugging and ensuring the migration process can handle failures appropriately.


🛠️ Refactor suggestion

Avoid blocking calls in reactive streams

Remember, using block() in reactive programming can negate the benefits of non-blocking, asynchronous execution. It can lead to thread blocking and reduce application performance.

Consider refactoring the code to use non-blocking alternatives. For example:

reactiveRedisTemplate
        .getConnectionFactory()
        .getReactiveConnection()
        .serverCommands()
        .flushDb()
        .subscribe(
            unused -> log.info("Redis database flushed successfully during migration"),
            error -> log.error("Failed to flush Redis database during migration", error)
        );

This approach allows the operation to proceed asynchronously, handling success and error cases without blocking the thread.

@nidhi-nair nidhi-nair merged commit 67c9ae2 into release Oct 7, 2024
20 checks passed
@nidhi-nair nidhi-nair deleted the fix/alt-oauth-spring-3-3-migration branch October 7, 2024 05:01
Copy link
Contributor

@abhvsn abhvsn left a comment

Choose a reason for hiding this comment

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

@nidhi-nair Sorry for being late here but why can't current custom JSON (de)serialiser handle this issue?

Also this may affect pg as well, and Flyway migrations run before any beans are initialised so we may have to look into that as well.

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

Successfully merging this pull request may close these issues.

2 participants