Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE EDGE with compare-and-swap (CAS). #4637

Closed
newcworld opened this issue Sep 11, 2022 · 4 comments
Closed

UPDATE EDGE with compare-and-swap (CAS). #4637

newcworld opened this issue Sep 11, 2022 · 4 comments
Labels
type/question Type: question about the product

Comments

@newcworld
Copy link

General Question

I notice that https://docs.nebula-graph.io/3.2.0/3.ngql-guide/13.edge-statements/2.update-edge/ say that

In Nebula Graph, UPDATE EDGE supports compare-and-swap (CAS).

But I cannot find any extra info about this, How can I update a edge with CAS

@wey-gu
Copy link
Contributor

wey-gu commented Sep 12, 2022

General Question

I notice that https://docs.nebula-graph.io/3.2.0/3.ngql-guide/13.edge-statements/2.update-edge/ say that


In Nebula Graph, UPDATE EDGE supports compare-and-swap (CAS).

But I cannot find any extra info about this, How can I update a edge with CAS

By adding when clause in update:
WHEN <condition>.

@newcworld
Copy link
Author

But when I use this like

UPDATE EDGE ON like "n:1:1:1" -> "n:1:1:2"
SET modify_time = timestamp(), version = version + 1
WHEN version == 1

When the version has been changed by other thread. such as it become 2.
it will not return any response about whether this update is succeed

@newcworld
Copy link
Author

I find that I can do this

UPDATE EDGE ON like "n:1:1:1" -> "n:1:1:2"
SET modify_time = timestamp(), version = version + 1
WHEN version == 1
YIELD version

@wey-gu
Copy link
Contributor

wey-gu commented Sep 13, 2022

I find that I can do this

UPDATE EDGE ON like "n:1:1:1" -> "n:1:1:2"
SET modify_time = timestamp(), version = version + 1
WHEN version == 1
YIELD version

Sorry for not checking your follow-up questions on time, yes, we could yield any fields and yield version will do the job 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Type: question about the product
Projects
None yet
Development

No branches or pull requests

4 participants