How can I obtain start and commit timestamps of transactions in Dgraph from operation messages or database logs? I need to issue multiple transactions in each client session.
I use this Docker image:
docker pull dgraph/dgraph:latest # version:v23.1.0
And pydgraph-23.0.1 driver with Python v3.8.18. I use simple.py and changed localhost on line 10 to 175.27.241.31. 175.27.241.31 is publicly available (you can use it directly without pulling the Docker image). I added print(response) after line 78 but there is only start_ts for the transaction. I do not find commit_ts:
txn {
start_ts: 260380056
keys: ...
...
preds: ...
...
}
latency {
...
}
metrics {
...
}
uids {
...
}
- How to obtain
commit_tsfor transactions using pydgraph? Is there any official documentation or source code for this? - Does following code from simple.py mean client is issuing multiple transactions one by one?
- Are there other ways of obtaining start and commit timestamps than using pydgraph? Code examples are appreciated.
def main():
client_stub = create_client_stub()
client = create_client(client_stub)
drop_all(client)
set_schema(client)
create_data(client)
query_alice(client) # query for Alice
query_bob(client) # query for Bob
delete_data(client) # delete Bob
query_alice(client) # query for Alice
query_bob(client) # query for Bob
# Close the client stub.
client_stub.close()
Answer from Ruohao Zhang @ discuss.dgraph.io:
I want to get the
commit_tsby using pydgraph. However, the functioncommit()doesn't return the commit_ts. By modifying line 238 intxn.py, I return the result of the functionself._dc.commit_or_abort.Like this, I could get the
commit_tsfrom the functioncommit().The result is following: start_ts: 260380200 commit_ts: 260380201
I have raised an issue on github.
Updated: The corresponding PR has been accepted.