Removed entity is blocking creating another entity with the same id

Open
#3,670 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust, typescript
Domain
backend, databases

Research direction

Start with the reproduction in src/ethereum.mapping.ts, especially handleCreateSplitCall, User.load, store.remove, and Split.save. Reproduce the shared-interface case and trace how the entity removal and replacement are handled; done means a removed User no longer blocks creating the Split with the same ID, with coverage for this sequence.

Written by the indexing model from the issue text.

Description

bug

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
I have two entity types with a shared interface, Split and User. When I go to create a new Split entity, I check to see if a User entity exists with the same id, and if yes I remove it first. I then create the split entity with that id. However, I am getting the following error:

Subgraph writer failed, error: tried to set entity of type 'Split' with ID "0xf8843981e7846945960f53243ca2fd42a579f719" but an entity of type 'User', which has an interface in common with 'Split', exists with the same ID

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
The error is occurring on this subgraph: https://thegraph.com/hosted-service/subgraph/0xsplits/splits-subgraph-kovan?version=pending

You can view the code here: https://github.com/0xSplits/splits-subgraph/blob/master/src/ethereum.mapping.ts#L99

A condensed version of it looks like:

export function handleCreateSplitCall(call: CreateSplitCall): void {
  let splitId = call.outputs.split.toHexString();

  let splitUserId = User.load(splitId);
  if (splitUserId) store.remove("User", splitId)
  
  let split = new Split(splitId);
  split.save();

What is the expected behavior?
I would expect the split to be successfully created since the user entity with the same id was removed before the split was saved.

Dominant language
Rust
Stars
3.2k
Forks
1.1k
Avg merge
4d 1h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from graphprotocol/graph-node

All issues in graphprotocol/graph-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.