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

make sure there's a record to emit #623

Merged
merged 1 commit into from Apr 11, 2024
Merged

make sure there's a record to emit #623

merged 1 commit into from Apr 11, 2024

Conversation

swilly22
Copy link
Contributor

Fixes #621

Copy link

coderabbitai bot commented Apr 11, 2024

Walkthrough

This update enhances the stability of the system by refining how operations handle and manipulate data structures, particularly focusing on record handling and memory management during CREATE operations in graphs. These changes are critical for preventing crashes and ensuring smoother operations.

Changes

File Change Summary
src/execution_plan/ops/op_create.c Enhanced safety checks and memory handling in record operations.
tests/flow/test_call_subquery.py Added a test for creating entities within CALL subqueries.

Assessment against linked issues

Objective Addressed Explanation
Crash when executing nested operations involving CREATE, DELETE, and relationships [#621]
Address crashes related to CREATE operations and subsequent node handling in RedisGraph
Ensure proper initialization and cleanup of data structures to prevent access violations

Possibly related issues

Poem

🐇✨
In the code where nodes do weave,
A rabbit hopped, fixes to achieve.
No more crashes, smooth runs the graph,
With each line, a safer path.
Hop, hop, hooray, let's celebrate,
For stable queries, we do create! 🌟
🐇💻


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b613a26 and 457edea.
Files selected for processing (2)
  • src/execution_plan/ops/op_create.c (3 hunks)
  • tests/flow/test_call_subquery.py (1 hunks)
Additional comments not posted (3)
src/execution_plan/ops/op_create.c (3)

136-137: The modification to check if op->records has elements before popping is a good safeguard against null dereferences.


136-137: Initializing op->records as an array instead of NULL is a prudent change that enhances the robustness of record handling.


211-211: Correcting the loop to start at index 0 in CreateFree ensures that all records are properly freed, preventing memory leaks.


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

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

@swilly22 swilly22 requested a review from AviAvni April 11, 2024 13:08
Copy link

@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

Comment on lines +2138 to +2153
def test34_create_within_call(self):
# The query will:
# 1. Create an entity within a CALL sub query
# 2. a Match outside the sub query will pull as many records as it can
# untill the sub query is depleted

q = """CALL {
CREATE ()
RETURN 0 AS X
}
MATCH ()--()
RETURN 0"""

res = self.graph.query(q)
self.env.assertEquals(res.nodes_created, 1)
self.env.assertEquals(len(res.result_set), 0)
Copy link

Choose a reason for hiding this comment

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

The test description does not accurately reflect the query's behavior.

- # 2. a Match outside the sub query will pull as many records as it can
- #    untill the sub query is depleted
+ # 2. Match the created node outside the sub query

The description suggests that the test will match the node created in the CALL subquery outside of it, but the actual query does not attempt to match this node. Please update the query or the description to align them correctly.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
def test34_create_within_call(self):
# The query will:
# 1. Create an entity within a CALL sub query
# 2. a Match outside the sub query will pull as many records as it can
# untill the sub query is depleted
q = """CALL {
CREATE ()
RETURN 0 AS X
}
MATCH ()--()
RETURN 0"""
res = self.graph.query(q)
self.env.assertEquals(res.nodes_created, 1)
self.env.assertEquals(len(res.result_set), 0)
def test34_create_within_call(self):
# The query will:
# 1. Create an entity within a CALL sub query
# 2. Match the created node outside the sub query
q = """CALL {
CREATE ()
RETURN 0 AS X
}
MATCH ()--()
RETURN 0"""
res = self.graph.query(q)
self.env.assertEquals(res.nodes_created, 1)
self.env.assertEquals(len(res.result_set), 0)

@swilly22 swilly22 merged commit 33e70f4 into master Apr 11, 2024
14 checks passed
@swilly22 swilly22 deleted the create-record-emit branch April 11, 2024 14:03
swilly22 added a commit that referenced this pull request Apr 16, 2024
* 600 add browser usage for the docker image (#601)

* add instructions to run browser UI

* set hostname to 0.0.0.0

* fix crash in rewrite call subquery (#604)

* fix crash in rewrite call subquery

* simplified test query

---------

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* use debug assert in rust (#606)

* fix merge init (#609)

* fix merge init

* remove unused function, simplified branch assignment logic

* clean

---------

Co-authored-by: Roi Lipman <roilipman@gmail.com>

* Unwind persist (#613)

* persist unwind record

* deep clone base record

* Disable jit (#612)

* persist unwind record

* disable GraphBLAS JIT

* Update module api (#617)

* update RediSearch submodule

* bump RediSearch version

* updated redis module api header file

* make sure there's a record to emit (#623)

* update RediSearch (#640)

* bump version

---------

Co-authored-by: Dudi <16744955+dudizimber@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>
swilly22 added a commit that referenced this pull request Apr 19, 2024
* 600 add browser usage for the docker image (#601)

* add instructions to run browser UI

* set hostname to 0.0.0.0

* fix crash in rewrite call subquery (#604)

* fix crash in rewrite call subquery

* simplified test query

---------

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* use debug assert in rust (#606)

* fix merge init (#609)

* fix merge init

* remove unused function, simplified branch assignment logic

* clean

---------

Co-authored-by: Roi Lipman <roilipman@gmail.com>

* Unwind persist (#613)

* persist unwind record

* deep clone base record

* Disable jit (#612)

* persist unwind record

* disable GraphBLAS JIT

* Update module api (#617)

* update RediSearch submodule

* bump RediSearch version

* updated redis module api header file

* make sure there's a record to emit (#623)

* update RediSearch (#640)

* Fix #634 Add Cloud link to README.md (#635)

* fix #645 Add objective to README (#646)

* Add objective to README

* Update wordlist.txt

---------

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* fix union validation with call subquery (#648)

* Seek by id runtime optimization (#643)

* wip runtime optimization

* fix leak

* fix node by label scan

* fix leak

* fix leak

* address review

* add tests

* address review

* review

* review

* review

* add memory hook to roaring bitmap

* introduce bitmap range

---------

Co-authored-by: Roi Lipman <roilipman@gmail.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* bump version

---------

Co-authored-by: Dudi <16744955+dudizimber@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>
Co-authored-by: Guy Korland <gkorland@gmail.com>
swilly22 added a commit that referenced this pull request May 13, 2024
* 600 add browser usage for the docker image (#601)

* add instructions to run browser UI

* set hostname to 0.0.0.0

* fix crash in rewrite call subquery (#604)

* fix crash in rewrite call subquery

* simplified test query

---------

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* use debug assert in rust (#606)

* fix merge init (#609)

* fix merge init

* remove unused function, simplified branch assignment logic

* clean

---------

Co-authored-by: Roi Lipman <roilipman@gmail.com>

* Unwind persist (#613)

* persist unwind record

* deep clone base record

* Disable jit (#612)

* persist unwind record

* disable GraphBLAS JIT

* Update module api (#617)

* update RediSearch submodule

* bump RediSearch version

* updated redis module api header file

* make sure there's a record to emit (#623)

* update RediSearch (#640)

* Fix #634 Add Cloud link to README.md (#635)

* fix #645 Add objective to README (#646)

* Add objective to README

* Update wordlist.txt

---------

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* fix union validation with call subquery (#648)

* Seek by id runtime optimization (#643)

* wip runtime optimization

* fix leak

* fix node by label scan

* fix leak

* fix leak

* address review

* add tests

* address review

* review

* review

* review

* add memory hook to roaring bitmap

* introduce bitmap range

---------

Co-authored-by: Roi Lipman <roilipman@gmail.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* zero dim vector save/load (#654)

* update redisearch, do not escape TAG field (#667)

* Code coverage (#674)

* add coverage build

* rename

* fix

* fix cache

* install redis in coverage

* ignore some path in code coverage (#678)

* Ref count record (#663)

* ref count record

* nullify record on deletion

* handle record ref count within execution plan return record

* address PR comments

* remove head & tail calls to persist

* trying to simplify and make value passing safer and simpler

* free aggregated group once yield

* removed Record_PersistScalars

* removed override flag

* remove extra persists

* group no longer holds a keys array

* only persists keys which are not graph entities

* allow for record cloning from different execution plans

---------

Co-authored-by: Dudi <16744955+dudizimber@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>
Co-authored-by: Guy Korland <gkorland@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash
2 participants