Skip to content

Conversation

@ishaksebsib
Copy link
Contributor

@ishaksebsib ishaksebsib commented Oct 24, 2025

Description

This PR fixes a runtime error in DROP operations when attempting to drop non-existent nodes, ensuring graceful handling of empty traversals.

Problem

Queries like DROP N<NodeType>(id) on non-existent IDs failed with "Conversion error: Incorrect Type: Empty" because drop_traversal did not handle TraversalValue::Empty returned by collect_to_obj().

Solution

Added TraversalValue::Empty => Ok(()), in the match statement of drop_traversal. This treats empty traversals as successful no-ops.

Related Issues

None

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • Version number has been updated in helix-cli/Cargo.toml and helixdb/Cargo.toml

Additional Notes

curl -X POST http://localhost:6969/DeleteNode \
      -H "Content-Type: application/json" \
      -d '{
      "node_id": "550e8400-e29b-41d4-a716-446655440007"
      }'

Conversion error: Incorrect Type: Empty⏎

Greptile Overview

Updated On: 2025-10-24 19:24:02 UTC

Greptile Summary

Fixed runtime error when attempting to DROP non-existent nodes by adding TraversalValue::Empty => Ok(()) case to the match statement in drop_traversal().

  • Resolved "Conversion error: Incorrect Type: Empty" error when dropping nodes by ID that don't exist
  • Empty traversals now treated as successful no-ops, consistent with how other parts of the codebase handle TraversalValue::Empty
  • Minor formatting improvements applied to let-chain syntax for consistency

Important Files Changed

File Analysis

Filename Score Overview
helix-db/src/helix_engine/traversal_core/ops/util/drop.rs 5/5 Added handling for TraversalValue::Empty case in drop_traversal to gracefully handle dropping non-existent nodes; minor formatting fixes applied

Sequence Diagram

sequenceDiagram
    participant Client
    participant HQL
    participant drop_traversal
    participant collect_to_obj
    participant Storage

    Client->>HQL: DROP N<NodeType>(non_existent_id)
    HQL->>collect_to_obj: Query for node by ID
    collect_to_obj->>Storage: Fetch node
    Storage-->>collect_to_obj: No results found
    collect_to_obj-->>HQL: TraversalValue::Empty
    HQL->>drop_traversal: Process traversal items
    alt Empty traversal (after fix)
        drop_traversal-->>HQL: Ok(()) - no-op
        HQL-->>Client: Success
    else Empty traversal (before fix)
        drop_traversal-->>HQL: ConversionError
        HQL-->>Client: Error: "Incorrect Type: Empty"
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

xav-db added a commit that referenced this pull request Oct 29, 2025
This fix resolves runtime errors when attempting to DROP non-existent
nodes, edges, or vectors. Previously, empty traversals would throw
"Conversion error: Incorrect Type: Empty" errors.

Added TraversalValue::Empty => Ok(()) case to make DROP operations
idempotent - dropping non-existent items now succeeds silently.

Integrates PR #670 into the arena-implementation branch.

Co-Authored-By: ishaksebsib
xav-db added a commit that referenced this pull request Oct 29, 2025
## Summary

This PR integrates the fix from #670 into the `arena-implementation`
branch. It resolves runtime errors when attempting to DROP non-existent
nodes, edges, or vectors.

## Problem

Queries attempting to drop non-existent items failed with:
```
Conversion error: Incorrect Type: Empty
```

This occurred because `drop_traversal` did not handle
`TraversalValue::Empty` returned when querying for non-existent items.

## Solution

Added `TraversalValue::Empty => Ok(())` case in the match statement of
`drop_traversal` in
`helix-db/src/helix_engine/traversal_core/ops/util/drop.rs:51`.

This treats empty traversals as successful no-ops, making DROP
operations idempotent.

## Testing

- ✅ `cargo check` passes with no errors
- ✅ All 109 `helix_engine` tests pass, including all DROP-related tests

## Related

- Integrates fix from PR #670
- No changes needed to helixc generator - the fix automatically applies
to generated code

Co-Authored-By: ishaksebsib
@xav-db xav-db mentioned this pull request Oct 29, 2025
8 tasks
xav-db added a commit that referenced this pull request Nov 7, 2025
## Description
<!-- Provide a brief description of the changes in this PR -->

## Related Issues
<!-- Link to any related issues using #issue_number -->

Closes #670 #666 #667 #672  #668 #661 #655 #654 #652 #436 

## Checklist when merging to main
<!-- Mark items with "x" when completed -->

- [ ] No compiler warnings (if applicable)
- [ ] Code is formatted with `rustfmt`
- [ ] No useless or dead code (if applicable)
- [ ] Code is easy to understand
- [ ] Doc comments are used for all functions, enums, structs, and
fields (where appropriate)
- [ ] All tests pass
- [ ] Performance has not regressed (assuming change was not to fix a
bug)
- [ ] Version number has been updated in `helix-cli/Cargo.toml` and
`helixdb/Cargo.toml`

## Additional Notes
<!-- Add any additional information that would be helpful for reviewers
-->

<!-- greptile_comment -->

<h2>Greptile Overview</h2>

Updated On: 2025-11-07 00:19:04 UTC

<h3>Greptile Summary</h3>


This PR implements arena-based memory allocation for graph traversals
and refactors the worker pool's channel selection mechanism.

**Key Changes:**
- **Arena Implementation**: Introduced `'arena` lifetime parameter
throughout traversal operations (`in_e.rs`), replacing owned data with
arena-allocated references for improved memory efficiency
- **Worker Pool Refactor**: Replaced `flume::Selector` with a
parity-based `try_recv()`/`recv()` pattern to handle two channels
(`cont_rx` and `rx`) across multiple worker threads
- **Badge Addition**: Added Manta Graph badge to README

**Issues Found:**
- **Worker Pool Channel Handling**: The new parity-based approach
requires an even number of workers (≥2) and uses non-blocking
`try_recv()` followed by blocking `recv()` on alternating channels.
While this avoids a true busy-wait (since one `recv()` always blocks),
the asymmetry means channels are polled at different frequencies,
potentially causing channel starvation or unfair scheduling compared to
the previous `Selector::wait()` approach.

The arena implementation appears solid and follows Rust lifetime best
practices. The worker pool change seems to be addressing a specific
issue with core affinity (per commit `7437cf0f`), but the trade-off in
channel fairness should be monitored.

<details><summary><h3>Important Files Changed</h3></summary>



File Analysis



| Filename | Score | Overview |
|----------|-------|----------|
| README.md | 5/5 | Added Manta Graph badge to README - cosmetic
documentation change with no functional impact |
| helix-db/src/helix_engine/traversal_core/ops/in_/in_e.rs | 5/5 |
Refactored to use arena-based lifetimes ('arena) instead of owned data,
replacing separate InEdgesIterator struct with inline closures for
better memory management |
| helix-db/src/helix_gateway/worker_pool/mod.rs | 3/5 | Replaced flume
Selector with parity-based try_recv/recv pattern requiring even worker
count, but implementation has potential busy-wait issues that could
cause high CPU usage |

</details>


</details>


<details><summary><h3>Sequence Diagram</h3></summary>

```mermaid
sequenceDiagram
    participant Client
    participant WorkerPool
    participant Worker1 as Worker (parity=true)
    participant Worker2 as Worker (parity=false)
    participant Router
    participant Storage

    Client->>WorkerPool: process(request)
    WorkerPool->>WorkerPool: Send request to req_rx channel
    
    par Worker1 Loop (parity=true)
        loop Every iteration
            Worker1->>Worker1: try_recv(cont_rx) - non-blocking
            alt Continuation available
                Worker1->>Worker1: Execute continuation function
            else Empty
                Worker1->>Worker1: Skip (no busy wait here)
            end
            Worker1->>Worker1: recv(rx) - BLOCKS until request
            alt Request received
                Worker1->>Router: Route request to handler
                Router->>Storage: Execute graph operation
                Storage-->>Router: Return result
                Router-->>Worker1: Response
                Worker1->>WorkerPool: Send response via ret_chan
            end
        end
    end
    
    par Worker2 Loop (parity=false)
        loop Every iteration
            Worker2->>Worker2: try_recv(rx) - non-blocking
            alt Request available
                Worker2->>Router: Route request to handler
                Router->>Storage: Execute graph operation
                Storage-->>Router: Return result
                Router-->>Worker2: Response
                Worker2->>WorkerPool: Send response via ret_chan
            else Empty
                Worker2->>Worker2: Skip (no busy wait here)
            end
            Worker2->>Worker2: recv(cont_rx) - BLOCKS until continuation
            alt Continuation received
                Worker2->>Worker2: Execute continuation function
            end
        end
    end

    WorkerPool-->>Client: Response
```
</details>


<!-- greptile_other_comments_section -->

<!-- /greptile_comment -->
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.

1 participant