-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
failed INSERT from inside transaction returns illegal RID #7202
Comments
Hi @rdelangh Did you try to add a COMMIT to the script? Thanks Luigi |
@luigidellaquila |
the complete script (sent via REST API):
The reply:
|
Hi @rdelangh I think the problem is this one:
Technically speaking you are returning a projection, this is why you are having a cluster ID like You can try to change it as follows:
It should work fine Thanks Luigi |
hi Luigi, I do not agree, please see my initial post where the error occurs already at the very first INSERT which is failing as expected because the INSERTed record exists already in the class and is blocked by a unique index, but it returns a @Rid equal to #358:-2 instead of aborting with an error :
|
@luigidellaquila |
referring to #7198 , there is no possibility to catch a failing INSERT inside a script. The script is supposed to fail with an error if trying to insert a record for which an entry exists already in the UNIQUE index. When I try to perform exactly the same INSERT as used above in my SQL script, but now without a script, then we see the expected failure because that same record exists already in the class:
|
Hi @rdelangh mmm... got it, it must be a problem with the script itself. I'm checking it Thanks Luigi |
Hi @rdelangh I just tried it, the problem here is that the return is calculated before the commit operation, that happens only when you close the db. If you add a commit, everything works as expected.
Thanks Luigi |
@luigidellaquila However, the whole goal of this transaction-concept is just to avoid having to do a COMMIT after the INSERT, because I want extra actions to happen after that INSERT. If these extra actions fail, then the INSERT also should not have been commited. Otherwise this is not one single transaction that fails or succeeds, but two separate transactions which might fail or succeed independently. |
Hi @rdelangh The index constraints (together with other validation) are checked at commit time, so there is no way for the INSERT to fail before it. Thanks Luigi |
hi @luigidellaquila The script is like this:
The very first INSERT seems to return a RID in all cases. The next "if($aggrSet.size() > 0)" evaluates to TRUE, hence that UPDATE is launched using the RID (with a negative cluster-nr "-2") from the very first INSERT. It is there that the error occurs:
|
Hi @rdelangh I still couldn't figure out how to isolate the problem. I tried with this script
but it works fine, as expected... am I missing something? Thanks Luigi |
@luigidellaquila |
Ok, I tried with the linkset, the UPDATE ADD and the IF, just to make sure none of them is the reason for the problem:
Still the same result, the script fails as espected... Thanks Luigi |
I found the error: This one works ok:
The error seems that the SELECT is returning a set of RIDs, but I did not return it as a set. :-) |
Good :) so the collision was on the Thanks Luigi |
The very first INSERT fails, as expected. No prob so far, that is as expected. The SELECT from myclass2 is returning a record. No prob so far, that is as expected. But then the next "UPDATE $aggrSet" does get executed anyhow despite that the very initial INSERT was failing. And "$aggrSet" is not a single RID, but it is a set of RIDs. Hence the error about the negative (-2) cluster. Difficult to understand that the script is executing that "UPDATE $aggrSet" in all cases... |
OrientDB Version: 2.2.18
Java Version: N/A
OS: Ubuntu 16
Expected behavior
So a value gets returned unexpectedly : in that script, I wanted to have it kick out with a similar "ORecordDuplicatedException" error, or at least not return any value for a new @Rid so that any next steps in that script would NOT be executed.
If I put extra steps after that INSERT which are using the new @Rid , surrounded with a test if the INSERT succeeded, then these extra steps are failing:
They DO get executed now, because the "if ($newRid.size() > 0)" evaluates to TRUE, apparently. When the $newRid is used, that the "-2" in $newRid seems to cause that error. Irrelevant, because the "if" should never be reached.
The text was updated successfully, but these errors were encountered: