SystemStackError when saving relation with guacamole

14 views
Skip to first unread message

Jens Hausherr

unread,
Mar 16, 2015, 12:10:04 PM3/16/15
to ashi...@googlegroups.com
Hi,

I am struggling a little how to work with the guacamole relationship modeling.

I have a user model that can have 0..n environments.

When I try to add an environment to my User I get a SystemStackError (stack level too deep).

The log suggests that the graph bounces between writing outgoing and incoming graph edge directions.


Any tips on where I went wrong are welcome.

Thanks,
Jens
 

Jens Hausherr

unread,
Mar 17, 2015, 3:01:09 AM3/17/15
to ashi...@googlegroups.com
Here is the log snippet that keeps repeating over and over again:

  | bind_parameters: {:graph=>"core_api_graph", :model_key=>"870885761", :edge_collection=>"ownerships", :direction=>:inbound}
[AQL]          FOR n IN GRAPH_NEIGHBORS(@graph,
                        { _key: @model_key },
                        { direction: @direction, edgeCollectionRestriction: @edge_collection })
          RETURN n.vertex
  | bind_parameters: {:graph=>"core_api_graph", :model_key=>"407808385", :edge_collection=>"ownerships", :direction=>:outbound}
[AQL]          FOR n IN GRAPH_NEIGHBORS(@graph,
                        { _key: @model_key },
                        { direction: @direction, edgeCollectionRestriction: @edge_collection })
          RETURN n.vertex

Is there any way to break the cycle?

Dirk Breuer

unread,
Mar 17, 2015, 12:01:54 PM3/17/15
to ashi...@googlegroups.com
Hi Jens,

you need to specify `coerce: false` at the `owner` attribute as well. I saw you
did this with the `environments` attribute as well. This should fix your problem.

We know the documentation isn't very clear with this and it will be fixed soon.

Sorry for the invoncience.

Regards
Dirk
> --
> You received this message because you are subscribed to the Google Groups "Ashikawa ArangoDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ashikawa+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jens Hausherr

unread,
Mar 18, 2015, 3:39:44 AM3/18/15
to ashi...@googlegroups.com
Hi Dirk, 

thanks for the response. I found out that for me it only works if I leave out the "coerce:false" on both sides of the relation (I guess it defaults to true then). 

With "coerce:false" I do not get an Array after loading the model from the database but an AQL query that does not respond to the Array methods like "<<".
This basically leaves me with a relation that I cannot update or which I could only update by bypassing guacamole(?), which is not really desirable.

I haven't dug through the code in enough detail, but I guess that coerce:false also serves as some kind of lazy loading function, right? (which would be nice for larger graphs)
You received this message because you are subscribed to a topic in the Google Groups "Ashikawa ArangoDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ashikawa/nWoHv_WZCl8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ashikawa+u...@googlegroups.com.

Jens Hausherr

unread,
Mar 18, 2015, 5:25:36 AM3/18/15
to ashi...@googlegroups.com
Sorry to reply again.

When I leave out the coerce:false I can add an environment to a loaded user and save him w/o problems. 

When I do the same inside the started rails server, I get the infinite loop of AQL queries on the edge collection.

If I add coerce:false I am at a loss how to save the connection between the models b/c the loaded user model 'environments' does not provide array semantics.

How are external relations supposed to work right now?

Regards,
Jens

Dirk Breuer

unread,
Mar 20, 2015, 10:18:52 AM3/20/15
to ashi...@googlegroups.com
Hi Jens,

> thanks for the response. I found out that for me it only works if I leave
> out the "coerce:false" on both sides of the relation (I guess it defaults
> to true then).
Yes, in that case Guacamole will try to coerce the assignment into the correct
type. And currently this results under certain circumstances in an endless loop.

> With "coerce:false" I do not get an Array after loading the model from the
> database but an AQL query that does not respond to the Array methods like
> "<<".
> This basically leaves me with a relation that I cannot update or which I
> could only update by bypassing guacamole(?), which is not really desirable.

You could use this as a work around:

```
user.environments = (user.environments << new_env)
```

I'm well aware that this is not desired and needs another solution. But it doesn't
bypass Guacamole and you could at least work for now. Sorry for the inconvience :/

> I haven't dug through the code in enough detail, but I guess that
> coerce:false also serves as some kind of lazy loading function, right?
> (which would be nice for larger graphs)
The ideal solution would be the user doesn't need to add `coerce: false` to any attribute.
Only if she really wants this. For relations this should just work. Currently there
is lazy loading mechanism in place (technically even with `coerce: true`). One problem is
the query should just forward array methods correctly to the underlying result set. This
is currently not the case.

I hope I could help you out in someway. Overall Guacamole is still a little rough around the edges
and we need reports of uses in the wild. Thanks for that.

Kind regards,
Dirk

>
>
> Regards,
> Jens
>
> [image: Jens Hausherr on about.me]
>
> Jens Hausherr
> about.me/jens.hausherr
> <http://about.me/jens.hausherr>

Jens Hausherr

unread,
Mar 25, 2015, 8:57:21 AM3/25/15
to ashi...@googlegroups.com
Hi Dirk,

thanks for the help. I got it working now. Guacamole is indeed a little rough around the edges.

Is guacamole already able to handle Hashes as relations? (e.g. attribute :foo, Hash[String =>VertexType])

From what I have read in the code right now, it does not look likely that it works.

I think that the most natural way would be to define a "key" property on the Edge model definition. At least from the ArangoDB side it works. (Generally speaking, support for arbitrary properties on edges would be nice, but not essential).

How would one implement a Hash via relation (and where to start)?

Cheers,
Jens
Reply all
Reply to author
Forward
0 new messages