Failed to find all structural indices for stage 1

Report a Dgraph Bug

What version of Dgraph are you using?

21.03.0

What is the hardware spec (RAM, OS)?

Linux Debian Stable, 16Go

Steps to reproduce the issue (command/config used to run Dgraph).

Run set mutations like :

[{"uid":"0x331df8","feat_grades":[1]},{"uid":"0x331df8","feat_bonuses":[103]},{"uid":"0x331df8","feat_rules":[100]}]

Schema extract is:

type Feature {
	feat_bonuses
	feat_actions
	feat_rules
	feat_infos
	feat_grades
}

feat_bonuses:			[int]									.
feat_actions:			[int]									.
feat_rules:				[int]									.
feat_infos:				[int]									.
feat_grades:			[int]									.

Expected behaviour and actual result.

I run my integration tests, and as soon as I do such mutations, I get those errors:

rpc error: code = Unknown desc = Failed to find all structural indices for stage 1

My tests run fine with 20.11.2.

2 Likes

Hello the team,
Do you have you any clue about what’s happening with dgraph and my mutations?

@ibrahim this looks funny. I’ve never seen these before. Could you walk us thru?

@myo the error doesn’t seem to be coming from dgraph. I can’t find it in the dgraph codebase

❯ git status             
HEAD detached at v21.03.0
nothing to commit, working tree clean 
❯ grep -ri "Failed to find all structural indices" * | wc -l
0

Can you check your code? Maybe the error is from your application?

It seems to come from your new json parser:
line 84: simdjson-go/parse_json_amd64.go at master · minio/simdjson-go · GitHub

Hello, any progress on this?

having the same issue with the same error

—update

@myo please check whether your json request to db not marshalled 2 times in a row

my issue was it that thing

image

@fletcherist I checked what you suggested and finally understood my problem, which is different from yours.

My api.Mutation.DeleteJson was set to the string null instead of the nil value, which seemed to be ignored in dgraph <= v20 but fails with dgraph >= v21.

The problem is I am wrapping my set and delete json values in interfaces (due to function arguments), and thus when my delModel is nil, testing delModel == nil fails and then I marshal the value to "null":

	if delModel != nil {
		delData, err = jsoniter.Marshal(delModel)
		if err != nil {
			return nil, err
		}
	}
	mutation := &api.Mutation{
		SetJson:    setData,
		DeleteJson: delData,
	}

Here delData is "null".

I fixed it with reflection:

	if !IsNil(delModel) {
		delData, err = jsoniter.Marshal(delModel)
		if err != nil {
			return nil, err
		}
	}

[...]

func IsNil(i interface{}) bool {
	if i == nil {
		return true
	}
	switch reflect.TypeOf(i).Kind() {
	case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice:
		return reflect.ValueOf(i).IsNil()
	}
	return false
}

Now delData is nil.

This might be a breaking change worth a mention in the changelog.

@docs this is pretty interesting an edge case. Anywhere to slot this in?