About the number of transaction

mutation

(Calico Box) #1

If I make 10 mutations continuously and add 2 nodes for each mutation, but I don’t commit them. And then I commit all of them at last.

My question is : How many transactions are there for the DGraph at this point?


(Michel Conrado (Support Engineer)) #2

10 transactions, or maybe one. It depends how you did it. You can have many mutations creating many nodes using the same transaction.


(Calico Box) #4

When I do a mutation by rest api

{
  set {
    <0x1> <balance> "110" .
    <0x2> <balance> "60" .
  }
}

I’ll get 2 keys. What dose the keys means?
Will the number of ts such as ‘4’ not change as long as the ts remains unchanged?


(Michel Conrado (Support Engineer)) #5

Means represent the state of that transaction. You use those to commit or discard. If you do not, it will be discarded soon.

This number will remains as long there exists the transaction, this is the transaction (identification) number.


(Calico Box) #6

Thanks for your response. In fact, the reason why I ask the question is that I encountered a problem when I try to update some data by spark task.

The spark task blocked after running for some time. It seemed that transactions were stacked. (After I killed the spark task, I tried to do some queries. Nothing returned and the query couldn’t even be executed. But the alphas didn’t crash.)

So I want to address it by reducing the number of transactions.

Will it work? Any suggestions please.

There is how I update data:

  1. get the uid of one node. eg. { test( func:eq(name,"test1")) { uid }}
  2. delete one predicate of this node. eg. { delete { <0x01> <relation> * . }}
  3. create a new predicate for this node. eg. { set { <0x01> <relation> "xxxxx" . }}

(Michel Conrado (Support Engineer)) #7

I don’t see why not. But I never used any spark tasks myself.

You don’t need to delete, if you mutate in a filled predicate of an existing Node it will be overwritten.


(Calico Box) #8

For DGraph, do deletes cost more than adds?

If so, the way may change to :

  1. get the uids of one node and the nodes that can get through “prdicate_1” .
{
  test(func: eq(name, "test1")){
     uid
     predicate_1 {
       uid
     }
  }
}
  1. put a delete mark on all the edges of the node.
{
  set {
    <0x01> <predicate_1 > <0x02> (del="true") .
    <0x01> <predicate_1 > <0x03> (del="true") .
    <0x01> <predicate_1 > <0x04> (del="true") .
    ....
  }
}
  1. add new edges.
{
  set {
    <0x01> <predicate_1> <0x02> .
  }
}

It feels so strange… :frowning:


(Calico Box) #9

However, it is possible to have too many transactions, does the DGraph have any strategy for this situation?

The question is irrelevant to the topic, so I open a new one.