Skip to content

[BUG] Cannot update the references (UUIDs) of a relation between two entities on different backends #123

@benatspo

Description

@benatspo

Describe the bug
First test
I tried to update some relations between two entities on different backends. One is stored in a table in a relational database, and the other is in a collection in a document database. The relation between both entities has for cardinality [0..*]. The update failed with the exception:

authAll_1                   | PreEvent [slots=[], queryTime=Tue Feb 02 16:34:27 GMT 2021, dbUser=nemo, authenticated=true, id=19eb3a35-c33f-4be8-b171-9c6210784187, query={"query":"update Customers_migrated x where x.@id == ??UUID set {Orders +: [??UUID2]}","parameterNames":["UUID","UUID2"],"parameterTypes":["uuid","uuid"],"boundRows":[["00e9fdcf-2103-313a-8066-242d4a6b8cf8","69741b09-2414-3e44-baa5-ba473da679e3"]]}, invertedQuery=null, invertedNeeded=false]
typhon-polystore-service_1  | Got result from AUTH!!! 19eb3a35-c33f-4be8-b171-9c6210784187
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:34:28.355+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.18.0.2:39298","connectionId":411,"connectionCount":1}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:34:28.355+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn411","msg":"client metadata","attr":{"remote":"172.18.0.2:39298","client":"conn411","doc":{"driver":{"name":"mongo-java-driver|sync","version":"3.12.0"},"os":{"type":"Linux","name":"Linux","architecture":"amd64","version":"4.19.76-linuxkit"},"platform":"Java/AdoptOpenJDK/1.8.0_282-b08"}}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:34:28.358+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.18.0.2:39302","connectionId":412,"connectionCount":2}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:34:28.359+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn412","msg":"client metadata","attr":{"remote":"172.18.0.2:39302","client":"conn412","doc":{"driver":{"name":"mongo-java-driver|sync","version":"3.12.0"},"os":{"type":"Linux","name":"Linux","architecture":"amd64","version":"4.19.76-linuxkit"},"platform":"Java/AdoptOpenJDK/1.8.0_282-b08"}}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:34:28.398+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn412","msg":"Successful authentication","attr":{"mechanism":"SCRAM-SHA-256","principalName":"mongoUser","authenticationDatabase":"admin","client":"172.18.0.2:39302"}}
typhonql-server_1           | java.lang.IllegalArgumentException: Invalid BSON document for an update. The document may not be empty.
typhonql-server_1           | (internal error)
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:34:28.400+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn412","msg":"Connection ended","attr":{"remote":"172.18.0.2:39302","connectionId":412,"connectionCount":1}}
typhonql-server_1           |   at $typhonql$(|main://$typhonql$|)
typhonql-server_1           |
typhonql-server_1           | java.lang.IllegalArgumentException: Invalid BSON document for an update. The document may not be empty.

Query

{"query":"update Customers_migrated x where x.@id == ??UUID set {Orders +: [??UUID2]}","parameterNames":["UUID","UUID2"],"parameterTypes":["uuid","uuid"],"boundRows":[["00e9fdcf-2103-313a-8066-242d4a6b8cf8","69741b09-2414-3e44-baa5-ba473da679e3"]]}

Second test
We ran another test, using a relation having for cardinality [1]. The query is a bit different (using ":" and not "+:" for the "set" parameter.

Query

{"query":"update Order_Details_migrated x where x.@id == ??UUID set {Products: ??UUID2}","parameterNames":["UUID","UUID2"],"parameterTypes":["uuid","uuid"],"boundRows":[["249a9962-d7ae-3dc2-93b4-c95b96788f32","69ce2884-4280-31ba-8645-6d0ddb3f36fc"]]}

The second test returned the following exception:

authAll_1                   | PreEvent [slots=[], queryTime=Tue Feb 02 16:42:24 GMT 2021, dbUser=nemo, authenticated=true, id=6be80b84-d789-4def-b12a-67f0659e1c85, query={"query":"update Order_Details_migrated x where x.@id == ??UUID set {Products: ??UUID2}","parameterNames":["UUID","UUID2"],"parameterTypes":["uuid","uuid"],"boundRows":[["249a9962-d7ae-3dc2-93b4-c95b96788f32","69ce2884-4280-31ba-8645-6d0ddb3f36fc"]]}, invertedQuery=null, invertedNeeded=false]
typhon-polystore-service_1  | Got result from AUTH!!! 6be80b84-d789-4def-b12a-67f0659e1c85
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.877+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.18.0.2:39800","connectionId":419,"connectionCount":1}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.877+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn419","msg":"client metadata","attr":{"remote":"172.18.0.2:39800","client":"conn419","doc":{"driver":{"name":"mongo-java-driver|sync","version":"3.12.0"},"os":{"type":"Linux","name":"Linux","architecture":"amd64","version":"4.19.76-linuxkit"},"platform":"Java/AdoptOpenJDK/1.8.0_282-b08"}}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.880+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.18.0.2:39804","connectionId":420,"connectionCount":2}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.880+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn420","msg":"client metadata","attr":{"remote":"172.18.0.2:39804","client":"conn420","doc":{"driver":{"name":"mongo-java-driver|sync","version":"3.12.0"},"os":{"type":"Linux","name":"Linux","architecture":"amd64","version":"4.19.76-linuxkit"},"platform":"Java/AdoptOpenJDK/1.8.0_282-b08"}}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.914+00:00"},"s":"I",  "c":"ACCESS",   "id":20250,   "ctx":"conn420","msg":"Successful authentication","attr":{"mechanism":"SCRAM-SHA-256","principalName":"mongoUser","authenticationDatabase":"admin","client":"172.18.0.2:39804"}}
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.917+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn420","msg":"Connection ended","attr":{"remote":"172.18.0.2:39804","connectionId":420,"connectionCount":1}}
typhonql-server_1           | )
typhonql-server_1           | java.lang.RuntimeException: java.sql.BatchUpdateException: Error reading results 1
typhonql-server_1           | (internal error)
typhonql-server_1           |   at $typhonql$(|main://$typhonql$|)
typhonql-server_1           |
documentdatabase_1          | {"t":{"$date":"2021-02-02T16:42:24.917+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn419","msg":"Connection ended","attr":{"remote":"172.18.0.2:39800","connectionId":419,"connectionCount":0}}
typhonql-server_1           | java.lang.RuntimeException: java.sql.BatchUpdateException: Error reading results 1
typhonql-server_1           |   at nl.cwi.swat.typhonql.backend.mariadb.MariaDBEngine.lambda$2(MariaDBEngine.java:136)
typhonql-server_1           |   at java.util.ArrayList.forEach(ArrayList.java:1259)
typhonql-server_1           |   at nl.cwi.swat.typhonql.backend.rascal.TyphonSessionState.flush(TyphonSessionState.java:73)

NB
If we remember correctly, such an update worked in the past when both entities were stored in a relational database.

Thank you for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions