Hello,
I’m testing the transaction in tigergraph(v3.1.6), but I found that I can’t read the newest data written in the same transaction. Is it a bug? Or why we design it like this, which is different from other database, like mysql.
Here is my query:
create vertex MyNode (primary_id id UINT, id1 UINT) WITH primary_id_as_attribute="true"
create directed edge MyEdge(from MyNode, to MyNode)
create graph twitter(MyNode, MyEdge)
USE GRAPH twitter
CREATE OR REPLACE QUERY read_and_update(UINT id, UINT id1, INT maxLoop) for graph twitter{
Nodes = {MyNode.*};
ori = SELECT v FROM Nodes:v where v.id == id;
UPDATE v FROM Nodes:v SET v.id1 = id1 where v.id == id;
final = SELECT v FROM Nodes:v where v.id == id;
PRINT ori, final;
}
install query read_and_update
Here is the original data:
$ gsql -g twitter "select * from MyNode where id == 12"
[{
"v_id": "12",
"attributes": {
"id1": 12,
"id": 12
},
"v_type": "MyNode"
}]
Call query read_and_update:
$ gsql -g twitter "run query read_and_update(12,13,1)"
{
"error": false,
"message": "",
"version": {
"schema": 0,
"edition": "enterprise",
"api": "v2"
},
"results": [{
"ori": [{
"v_id": "12",
"attributes": {
"id1": 12,
"id": 12
},
"v_type": "MyNode"
}],
"final": [{
"v_id": "12",
"attributes": {
"id1": 12,
"id": 12
},
"v_type": "MyNode"
}]
}]
}
When we call query read_and_update, the output shows that we didn’t get the updated data during the transaction.(We expect that the id1 is 13 in final)
Get the vertex again:
$ gsql -g twitter "select * from MyNode where id == 12"
[{
"v_id": "12",
"attributes": {
"id1": 13,
"id": 12
},
"v_type": "MyNode"
}]
Now we can get the updated data.
Can anyone explain why we can’t read the newest data written in the same transaction and why tigergraph designs transaction like this?
Thanks.