upsert not working properly in specific cases

Hello, We have a upsert utility function in Gremlin that gets a name and a label, then either fetches it if it exists or creates it, then sets it with specific values. The query looks like this:
g.V().hasLabel(label).has('name', name).fold().coalesce(__unfold(), __addV(label).property(single, 'name', name))
.property(...).property(...).iterate()
g.V().hasLabel(label).has('name', name).fold().coalesce(__unfold(), __addV(label).property(single, 'name', name))
.property(...).property(...).iterate()
It usually works just fine, however in some cases it seems to not find existing vertices that have this label and name combo. It then creates a new vertex which is identical, minus the ID which is generated. We're only seeing this happen in Neptune - no such occurrences in Tinkerpop's local server/client. We have an old version of Neptune (1.0.3.0) and are in the process of upgrading it to the latest version - could this be the cause? Please advise.
Solution:
There were a number of improvements to the upsert pattern between versions 1.0.3.0 and 1.0.5.0. FWIW, 1.0.3.0 is now deprecated as of Jan 30th of this year.
Jump to solution
8 Replies
spmallette
spmallette•2y ago
I'm not sure what might be going on there offhand - anyone else in @neptune have any ideas?
Shush
ShushOP•2y ago
At least the syntax looks right, right? The fold() and unfold() are used correctly here?
spmallette
spmallette•2y ago
yes, i'm not sure why that wouldn't work.
triggan
triggan•2y ago
Could these be two concurrent writes and do you have ReadWriteConflictDetection disabled?
Shush
ShushOP•2y ago
No, I doubt it - we're iterating an array of predefined services to check if they exist, and create them if not. This happens only once a day (or unless manually triggered)
Solution
triggan
triggan•2y ago
There were a number of improvements to the upsert pattern between versions 1.0.3.0 and 1.0.5.0. FWIW, 1.0.3.0 is now deprecated as of Jan 30th of this year.
triggan
triggan•2y ago
Not sure what is happening in this particular case. I'd have to see the actual query against the live data, to be certain. You can always open a case and we can have an engineer take a look.
Shush
ShushOP•2y ago
That's why we're in the upgrade process 😄 I will first see if the upgrade fixes it. The version, as you said, is deprecated. If not, I'll ask our DevOps to open an official case to AWS Neptune. Thanks!
Want results from more Discord servers?
Add your server