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

batching handleActionUpdates #38266

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

batching handleActionUpdates #38266

wants to merge 1 commit into from

Conversation

vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Dec 19, 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="@tag.All"

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12427297344
Commit: c0e1115
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/Apps/CommunityIssues_Spec.ts
  2. cypress/e2e/Regression/Apps/EchoApiCMS_spec.js
  3. cypress/e2e/Regression/Apps/ImportExportForkApplication_spec.js
  4. cypress/e2e/Regression/Apps/MongoDBShoppingCart_spec.ts
  5. cypress/e2e/Regression/Apps/PgAdmin_spec.js
  6. cypress/e2e/Regression/Apps/PromisesApp_spec.js
  7. cypress/e2e/Regression/ClientSide/ActionExecution/Bug33601_spec.ts
  8. cypress/e2e/Regression/ClientSide/Autocomplete/JS_AC1_spec.ts
  9. cypress/e2e/Regression/ClientSide/Binding/API_with_List_Widget_spec.js
  10. cypress/e2e/Regression/ClientSide/Binding/Api_withPageload_Input_spec.js
  11. cypress/e2e/Regression/ClientSide/Binding/JSObjectToListWidget_Spec.ts
  12. cypress/e2e/Regression/ClientSide/Binding/JSObject_Postgress_Table_spec.js
  13. cypress/e2e/Regression/ClientSide/Binding/TableTextPagination_spec.js
  14. cypress/e2e/Regression/ClientSide/Binding/TableV2TextPagination_spec.js
  15. cypress/e2e/Regression/ClientSide/Binding/TableV2_Api_spec.js
  16. cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Derived_Column_spec.js
  17. cypress/e2e/Regression/ClientSide/Binding/TableV2_Widget_API_Pagination_spec.js
  18. cypress/e2e/Regression/ClientSide/Binding/Table_Api_spec.js
  19. cypress/e2e/Regression/ClientSide/Binding/Table_Widget_API_Derived_Column_spec.js
  20. cypress/e2e/Regression/ClientSide/Binding/Widget_loading_spec.js
  21. cypress/e2e/Regression/ClientSide/BugTests/ApiBugs_Spec.ts
  22. cypress/e2e/Regression/ClientSide/BugTests/DS_Bug28985_spec.ts
  23. cypress/e2e/Regression/ClientSide/BugTests/ListWidgetOnPageLoad_Spec.ts
  24. cypress/e2e/Regression/ClientSide/BugTests/SelectWidget_Bug9334_Spec.ts
  25. cypress/e2e/Regression/ClientSide/Debugger/Widget_property_navigation_spec.ts
  26. cypress/e2e/Regression/ClientSide/Git/ExistingApps/v1.9.24/DSCrudAndBindings_Spec.ts
  27. cypress/e2e/Regression/ClientSide/Git/GitDiscardChange/DiscardChanges_spec.js
  28. cypress/e2e/Regression/ClientSide/Git/GitImport/GitImport_spec.js
  29. cypress/e2e/Regression/ClientSide/Git/GitSync/GitSyncedApps_spec.js
  30. cypress/e2e/Regression/ClientSide/MobileResponsiveTests/Snipping_mode_Basic_test.js
  31. cypress/e2e/Regression/ClientSide/MobileResponsiveTests/SuggestedWidgets_spec.js
  32. cypress/e2e/Regression/ClientSide/OneClickBinding/JSONFormWidget/ConnectToWidget_spec.ts
  33. cypress/e2e/Regression/ClientSide/OneClickBinding/JSONFormWidget/JSONForm_mongoDB_spec.ts
  34. cypress/e2e/Regression/ClientSide/OneClickBinding/JSONFormWidget/JSONForm_postgres_spec.ts
  35. cypress/e2e/Regression/ClientSide/OneClickBinding/MultiSelectWidget/MultiSelect_MongoDB_spec.ts
  36. cypress/e2e/Regression/ClientSide/OneClickBinding/MultiSelectWidget/MultiSelect_postgres_spec.ts
  37. cypress/e2e/Regression/ClientSide/OneClickBinding/SelectWidget/mongoDB_spec.ts
  38. cypress/e2e/Regression/ClientSide/OneClickBinding/SelectWidget/postgres_spec.ts
  39. cypress/e2e/Regression/ClientSide/OneClickBinding/TableWidget/OneClickBindingMysql_spec.ts
  40. cypress/e2e/Regression/ClientSide/OneClickBinding/TableWidget/Table_MongoDB_spec.ts
  41. cypress/e2e/Regression/ClientSide/OneClickBinding/TableWidget/Table_postgres_spec.ts
  42. cypress/e2e/Regression/ClientSide/OtherUIFeatures/PageOnLoad_spec.ts
  43. cypress/e2e/Regression/ClientSide/PartialImportExport/PartialImportRegularApp.ts
  44. cypress/e2e/Regression/ClientSide/PeekOverlay/PeekOverlay_Spec.ts
  45. cypress/e2e/Regression/ClientSide/Widgets/Button/Button2_spec.ts
  46. cypress/e2e/Regression/ClientSide/Widgets/Checkbox/CheckboxGroup_withQuery_spec.js
  47. cypress/e2e/Regression/ClientSide/Widgets/ListV2/DataIdentifier_spec.ts
  48. cypress/e2e/Regression/ClientSide/Widgets/ListV2/DefaultSelectItem_spec.ts
  49. cypress/e2e/Regression/ClientSide/Widgets/ListV2/ListV2_PageNo_PageSize_spec.js
  50. cypress/e2e/Regression/ClientSide/Widgets/ListV2/Listv2_BasicServerSideData_spec.js
  51. cypress/e2e/Regression/ClientSide/Widgets/ListV2/Listv2_Meta_Hydration_ServerSide_spec.js
  52. cypress/e2e/Regression/ClientSide/Widgets/Migration_Spec.js
  53. cypress/e2e/Regression/ClientSide/Widgets/Modal/Modal_spec.ts
  54. cypress/e2e/Regression/ClientSide/Widgets/Multiselect/MultiSelect4_spec.js
  55. cypress/e2e/Regression/ClientSide/Widgets/Others/StatboxDsl_spec.js
  56. cypress/e2e/Regression/ClientSide/Widgets/Radio/Radio2_spec.ts
  57. cypress/e2e/Regression/ClientSide/Widgets/Select/Select3_Spec.ts
  58. cypress/e2e/Regression/ClientSide/Widgets/Select/Select_spec.js
  59. cypress/e2e/Regression/ClientSide/Widgets/TableV1/TableFilter2_2_Spec.ts
  60. cypress/e2e/Regression/ClientSide/Widgets/TableV1/Table_Derived_Column_Data_validation_spec.js
  61. cypress/e2e/Regression/ClientSide/Widgets/TableV1/Table_Property_JsonUpdate_spec.js
  62. cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2Filter2_2_Spec.ts
  63. cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Derived_Column_Data_validation_spec.js
  64. cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Property_JsonUpdate_spec.js
  65. cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts
  66. cypress/e2e/Regression/ClientSide/Widgets/TableV2/server_side_filtering_spec_1.ts
  67. cypress/e2e/Regression/ClientSide/Widgets/TreeSelect/Tree_Select_2_spec.ts
  68. cypress/e2e/Regression/ServerSide/ApiTests/API_Bugs_Spec.js
  69. cypress/e2e/Regression/ServerSide/Datasources/Firestore_Basic_Spec.ts
  70. cypress/e2e/Regression/ServerSide/GenerateCRUD/MongoURI_Spec.ts
  71. cypress/e2e/Regression/ServerSide/GenerateCRUD/Mongo_Spec.ts
  72. cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL1_Spec.ts
  73. cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL2_Spec.ts
  74. cypress/e2e/Regression/ServerSide/GenerateCRUD/Postgres1_Spec.ts
  75. cypress/e2e/Regression/ServerSide/GenerateCRUD/Postgres2_Spec.ts
  76. cypress/e2e/Regression/ServerSide/MySQL_Datatypes/Basic_Spec.ts
  77. cypress/e2e/Regression/ServerSide/OnLoadTests/ExecuteAction_Spec.ts
  78. cypress/e2e/Regression/ServerSide/Params/ExecutionParams_spec.js
  79. cypress/e2e/Regression/ServerSide/Params/PassingParams_Spec.ts
  80. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/Array_Spec.ts
  81. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/Binary_Spec.ts
  82. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/BooleanEnum_Spec.ts
  83. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/Character_Spec.ts
  84. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/DateTime_Spec.ts
  85. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/Json_Spec.ts
  86. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/Numeric_Spec.ts
  87. cypress/e2e/Regression/ServerSide/Postgres_DataTypes/UUID_Spec.ts
  88. cypress/e2e/Regression/ServerSide/QueryPane/AddWidgetTableAndBind_spec.js
  89. cypress/e2e/Regression/ServerSide/QueryPane/AddWidget_spec.js
  90. cypress/e2e/Regression/ServerSide/QueryPane/Mongo1_spec.ts
  91. cypress/e2e/Regression/ServerSide/QueryPane/QueryPane_MySQL_Spec.ts
  92. cypress/e2e/Regression/ServerSide/QueryPane/QueryPane_Postgres_Spec.js
  93. cypress/e2e/Regression/ServerSide/QueryPane/Querypane_Mongo_Spec.js
  94. cypress/e2e/Regression/ServerSide/QueryPane/S3_1_spec.js
  95. cypress/e2e/Regression/ServerSide/QueryPane/S3_2_spec.ts
  96. cypress/e2e/Sanity/Datasources/SMTPDatasource_spec.js
List of identified flaky tests.
Fri, 20 Dec 2024 10:21:10 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced handling of evaluation actions, allowing for better management of action data updates.
    • Introduced a mechanism to collect and process updates alongside evaluation actions.
  • Bug Fixes

    • Streamlined the control flow for processing action data updates, reducing potential errors in handling.
  • Refactor

    • Simplified saga responsibilities by removing outdated functions and updating the action flow.

Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces modifications to the PluginActionSaga.ts and EvaluationsSaga.ts files, focusing on simplifying action data update handling. The changes remove the handleUpdateActionData function from the plugin action saga and enhance the evaluation saga's action buffering mechanism. The modifications streamline the process of managing action updates and evaluation actions, potentially reducing complexity in action data processing.

Changes

File Change Summary
app/client/src/sagas/ActionExecution/PluginActionSaga.ts - Removed handleUpdateActionData function
- Removed UPDATE_ACTION_DATA saga watcher
app/client/src/sagas/EvaluationsSaga.ts - Added collectedHandleUpdates variable
- Updated evalQueueBuffer to handle action updates
- Modified evaluationChangeListenerSaga to include UPDATE_ACTION_DATA

Sequence Diagram

sequenceDiagram
    participant Saga as Evaluation Saga
    participant Worker as Evaluation Worker
    participant Actions as Redux Actions

    Saga->>Actions: Listen for evaluation actions
    Actions-->>Saga: Receive action updates
    Saga->>Saga: Buffer action updates
    Saga->>Worker: Dispatch buffered actions
Loading

Possibly related PRs

Suggested labels

Bug, Task, ok-to-test

Suggested reviewers

  • dvj1988
  • ayushpahwa
  • ApekshaBhosale

Poem

🧩 Sagas dancing, actions light,
Code refactored, complexity takes flight
Buffers clean, updates so neat
Evaluation's rhythm now complete!
Simplicity wins the coding fight 🚀


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.

@vsvamsi1 vsvamsi1 marked this pull request as draft December 19, 2024 19:16
@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Dec 19, 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: 1

🧹 Nitpick comments (2)
app/client/src/sagas/EvaluationsSaga.ts (2)

545-546: Consider adding type definition for collectedHandleUpdates

The variable should have a more specific type than any to ensure type safety.

-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  let collectedHandleUpdates: any = [];
+  let collectedHandleUpdates: Array<ActionDataPayload> = [];

787-787: Review the delay duration

The 500ms delay might be too long for action processing. Consider making this configurable or reducing it based on performance metrics.

- yield delay(500);
+ const ACTION_PROCESSING_DELAY = process.env.ACTION_PROCESSING_DELAY || 200;
+ yield delay(ACTION_PROCESSING_DELAY);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e22dbd1 and 1878641.

📒 Files selected for processing (2)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts (0 hunks)
  • app/client/src/sagas/EvaluationsSaga.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts
🔇 Additional comments (1)
app/client/src/sagas/EvaluationsSaga.ts (1)

Line range hint 551-593: Verify the buffer clearing logic

The buffer clearing logic in the take function looks correct, but we should ensure that all buffered updates are processed before clearing.

✅ Verification successful

Buffer clearing logic is properly synchronized with action processing

The implementation is safe because:

  • The buffer (collectedHandleUpdates) is only cleared in take() after its contents are saved to respCollectedHandleUpdates
  • New updates are only collected when UPDATE_ACTION_DATA actions arrive with payload
  • The canTake flag ensures atomic buffer operations
  • The evaluation channel processes actions sequentially in the saga loop
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any potential race conditions in action processing
rg -A 5 "UPDATE_ACTION_DATA.*actionDataPayload" 

Length of output: 49


Script:

#!/bin/bash
# Let's search for the action type and buffer processing logic
rg -A 10 "ReduxActionTypes\.UPDATE_ACTION_DATA" app/

# Check for any other places where collectedHandleUpdates is modified
rg -A 5 "collectedHandleUpdates" app/

# Look for the shouldProcessAction implementation
ast-grep --pattern 'function shouldProcessAction($_) {
  $$$
}'

Length of output: 4303

Comment on lines 771 to 786
[...EVAL_AND_LINT_REDUX_ACTIONS, ReduxActionTypes.UPDATE_ACTION_DATA],
evalQueueBuffer(),
);

while (true) {
const action: EvaluationReduxAction<unknown | unknown[]> =
yield take(evtActionChannel);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const action: any = yield take(evtActionChannel);

if (action?.actionDataPayload?.length) {
yield call(
evalWorker.request,
EVAL_WORKER_ACTIONS.UPDATE_ACTION_DATA,
action.actionDataPayload,
);
}

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

Consider adding error handling for evalWorker requests

The worker request for updating action data should include error handling to prevent silent failures.

  if (action?.actionDataPayload?.length) {
+   try {
      yield call(
        evalWorker.request,
        EVAL_WORKER_ACTIONS.UPDATE_ACTION_DATA,
        action.actionDataPayload,
      );
+   } catch (error) {
+     console.error('Failed to update action data:', error);
+     // Consider dispatching an error action here
+   }
  }

Committable suggestion skipped: line range outside the PR's diff.

@vsvamsi1 vsvamsi1 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Dec 19, 2024
@vsvamsi1
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant