0
votes

I am trying to insert data into a SQL server datbase by using an Odata batch request changeset with Teiid. Surprisingly the inserts doesn't seem to be atomic. I am using Teeid 13.0.2 and mssql-jdbc-7.4.1.jre8.jar.

To demonstrate the problem. I created a TestTable with one column 'Id' which is the primary key. The table already contains the number 1. By using the following batch request I try inserting 41 and 1 in an atomic operation. The batch fails with status code 400, which I am expecting due to the primary key constraint. But the 41 is still inserted into the SQL server database, which as I understand shouldn't happen.

--batch_a
Content-Type: multipart/mixed; boundary=changeset_a

--changeset_a
Content-Type: application/http
Content-ID: 1
Content-Transfer-Encoding: binary

POST TestTable HTTP/1.1
Content-Type: application/json

{"Id":41}
--changeset_a
Content-Type: application/http
Content-ID: 2
Content-Transfer-Encoding: binary

POST TestTable HTTP/1.1
Content-Type: application/json

{"Id":1}
--changeset_a-- 
--batch_a--  

Any ideas of what I am doing wrong? I created a teeid trace to see what is going on and it seems to be that there are 2 transactions and not 1. The trace is available at https://gist.github.com/mbankdmt/ec1465e22f71c00dab6db13483da66c1.

1

1 Answers

0
votes

I'm using teiid 17.0.0 and onlingo 4.8.0. And I encountered the same issue as you. After debugging, I figured out there are some bugs inside class TeiidServiceHandler. Nested transactions cause this issue.