typedb-driver
typedb-driver copied to clipboard
TypeDB Python Driver oblivious to errors until commited
Description
- If I try to send an invalid query with Python Driver it will send the query with no errors, even if TypeDB terminal window shows an error. Then, when I will commit the transaction the Driver will show an error.
10:19:26.908 [typedb-service::0] ERROR com.vaticle.typedb.core.server.TransactionService - [TQL03] TypeQL Error: There is a syntax error at line 1:
insert person isa entity, has name 1, has join-date 2023-06-07T10:19:26;
^
mismatched input 'person' expecting {'==', '!=', '>', '>=', '<', '<=', 'like', 'contains', '=', '+', '-', '(', BOOLEAN_, STRING_, LONG_, DOUBLE_, DATE_, DATETIME_, VAR_CONCEPT_}
- The same applies if the transaction duration timeout runs out. I get the error message in TypeDB terminal window, but Driver proceeds sending queries as usual for infinite time. Only committing the transaction will reveal the timeout error.
10:56:53.033 [typedb-scheduled::0] ERROR com.vaticle.typedb.core.server.TransactionService - [SRV29] Invalid Server Operation: Transaction exceeded maximum configured duration of '300' seconds.
Environment
- OS (where TypeDB server runs): 12.6.6
- TypeDB version (and platform): 2.18.0
- TypeDB client-python version: 2.18.0
- Python version: 3.9
- Other environment details:
Reproducible Steps
Steps to create the smallest reproducible scenario:
- Define a schema
tql_schema_insert = "define"
tql_schema_insert += " person sub entity, owns name, owns join-date;"
tql_schema_insert += " name sub attribute, value string;"
tql_schema_insert += " join-date sub attribute, value datetime;"
- Try inserting some valid data
tql_data_insert = "insert"
tql_data_insert += " $p isa person,"
tql_data_insert += " has name '" + str(counter) + "',"
timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
tql_data_insert += " has join-date " + timestamp + ";"
transaction.query().insert(tql_data_insert)
transaction.commit()
- Try inserting invalid data, repeating if for a while:
while counter < 7:
counter += 1
print("Initiating wait cycle #", counter)
time.sleep(1 * 60)
# timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
# print(counter, "Wait cycle over:", timestamp)
tql_data_insert = "insert"
tql_data_insert += " person isa entity,"
tql_data_insert += " has name '" + str(counter) + "',"
timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
tql_data_insert += " has join-date " + timestamp + ";"
transaction.query().insert(tql_data_insert)
print(counter, "Data insertion complete successfully: ", timestamp)
transaction.commit()
Expected Output
Error/Exception upon the first query of the while cycle.
In more general way: an error/exception as soon as TypeDB found a problem, or at least as soon as we send a query into a transaction that already experienced a fatal error.
Actual Output
The program goes on through all queries and finishes with commit attempt. Exception as follows:
10:19:26.908 [typedb-service::0] ERROR com.vaticle.typedb.core.server.TransactionService - [TQL03] TypeQL Error: There is a syntax error at line 1:
insert person isa entity, has name 1, has join-date 2023-06-07T10:19:26;
^
mismatched input 'person' expecting {'==', '!=', '>', '>=', '<', '<=', 'like', 'contains', '=', '+', '-', '(', BOOLEAN_, STRING_, LONG_, DOUBLE_, DATE_, DATETIME_, VAR_CONCEPT_}
Even if we go with the queries longer, then the transaction duration timeout - we will not get the transaction timeout error. Only syntax error upon commit.
Additional information
Full script - transaction_timeout.py.zip
If we fix the query error:
while counter < 7:
counter += 1
print("Initiating wait cycle #", counter)
time.sleep(1 * 60)
# timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
# print(counter, "Wait cycle over:", timestamp)
tql_data_insert = "insert"
tql_data_insert += " $p isa person,"
tql_data_insert += " has name '" + str(counter) + "',"
timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
tql_data_insert += " has join-date " + timestamp + ";"
transaction.query().insert(tql_data_insert)
print(counter, "Data insertion complete successfully: ", timestamp)
transaction.commit()
It will still go through all the cycles and attempt to commit, even tho we will get a Transaction exceeded maximum configured duration error in TypeDB terminal window after fifth iteration:
12:02:23.454 [typedb-scheduled::0] ERROR com.vaticle.typedb.core.server.TransactionService - [SRV29] Invalid Server Operation: Transaction exceeded maximum configured duration of '300' seconds.
We'll get the error upon commit only. Effectively that creates an opportunity to create an infinite transaction client-side that will fail upon commit.