Skip to content
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

Sequence used multiple times in single transaction block is not incremented #7547

Closed
fixundfertig123 opened this issue Jul 13, 2017 · 12 comments
Assignees
Labels
Milestone

Comments

@fixundfertig123
Copy link

OrientDB Version: 2.2.22

Java Version: 1.8.0_92

OS: Windows 7

Expected behavior

A sequence used as a default value in multiple vertex classes (as uniqueID) in same transaction block should increment by one within each created vertex.

Actual behavior

If run in transaction block, sequence is not updated, and all vertices get the same "uniqueID" and due to an index an exception is thrown:

com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #19:162: found duplicated key '516' in index 'idx_V_Vertex1_uniqueID' previously assigned to the record #16:175
	DB name="XXX"
	DB name="XXX" INDEX=idx_V_Vertex1_uniqueID RID=#16:175

Steps to reproduce

  • I am using the API not SQL
  • Create two vertex classed having each the property "uniqueID", which should be automatically created from the same sequence "seqCounter". The uniqueID property is defined in a superclass via the SQL command: "ALTER PROPERTY V_XXXXX.uniqueID DEFAULT 'sequence("seqCounter").next()'"
  • require remote connection via OrientGraphFactory.getTx (variable named "graph")
  • Create the two vertices instances and an edge between them.
  • Only after all operations (addVertex, ...) I run "graph.shutdown". The above exception is thrown.

Debugging the "OTransaction" in method "public List commit(final OTransaction iTx, final Runnable callback)" shows the follwing entries in OTransaction object (I assume as ORecordOperation):

#-1:-3=ORecordOperation [record=V_Vertex2#-1:-3{uniqueID:516,createdOn:Thu Jul 13 13:42:59 CEST 2017,updatedOn:Thu Jul 13 13:42:59 CEST 2017,email:mf1@localhost,lastName:asd,firstName:asd,in_E_Edge1:[#-1:-4]} v0, type=CREATE]

#7:0=ORecordOperation [record=OSequence#7:0{type:ORDERED,start:1,incr:1,value:516,name:seqCounter} v515, type=UPDATE]

#-1:-4=ORecordOperation [record=E_Edge1#-1:-4{updatedOn:Thu Jul 13 13:40:02 CEST 2017,createdOn:Thu Jul 13 13:40:02 CEST 2017,out:#-1:-2,in:#-1:-3} v0, type=CREATE]

#-1:-2=ORecordOperation [record=V_Vertex1#-1:-2{uniqueID:516,createdOn:Thu Jul 13 13:42:59 CEST 2017,updatedOn:Thu Jul 13 13:42:59 CEST 2017,email:mf1@localhost,lastName:asd,firstName:asd,out_E_Edge1:[#-1:-4]} v0, type=CREATE]

In my opinion the uniqueID values 516 of both vertices should not be set, since the are to be generated upon commit??? I did not insert the uniqueID property value via the API. This has been done somewhere in the orientDB.

Reloading the sequence in the middle of the transaction between both vertex creations via:

graph.getRawGraph.getMetadata.getSequenceLibrary.getSequence("seqCounter").getDocument.reload()

caused exception (basing on the same reason than in issue #7046):

WARNING: Found record in transaction with the same RID #7:0 but different instance. Probably the record has been loaded from another transaction and reused on the current one: reload it from current transaction before to update or delete it
Jul 13, 2017 9:38:20 PM com.orientechnologies.common.log.OLogManager log
SCHWERWIEGEND(German Severe / Fatal): Exception during commit of active transaction
com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #19:162: found duplicated key '516' in index 'idx_V_Vertex1_uniqueID' previously assigned to the record #16:175
	DB name="XXX"
	DB name="XXX" INDEX=idx_V_Vertex1_uniqueID RID=#16:175

I cannot provide you code yet, but I try to reduce the code to an standalone example.

@fixundfertig123 fixundfertig123 changed the title Sequence used multiple times in single transaction blocks is not incremented Sequence used multiple times in single transaction block is not incremented Jul 13, 2017
@careerscale
Copy link

careerscale commented Jul 13, 2017

Interesting, saw this behavior in 3.0 in the beginning (couple of months ago) and it is fixed in 3.0 snapshots already. we are able to use in our product (in development) that used orientDB 3.0.

@lvca lvca added this to the 2.2.x (next hotfix) milestone Jul 14, 2017
@lvca lvca added the bug label Jul 14, 2017
@fixundfertig123
Copy link
Author

fixundfertig123 commented Jul 18, 2017

@lvca @tglman

Hi, I finally isolated the bug and it seems to be related to remote connections. I created a repository for it located under https://github.com/fixundfertig123/7547/commits/master

When running in memory or plocal it is working (Checkout https://github.com/fixundfertig123/7547/tree/93abef43ee20d565375bcd6862336be7b299e36f)

When changing to remote connection (checkout https://github.com/fixundfertig123/7547/tree/b9eecee009901167b59d754322b3e3fd0ed3899d) neither the index nor the sequence is correct. Prior to that you have to create an according orientDB yourself (I do not know how to do that in automatically). My output looks like:

Start!
{1=b, 2=a, 3=c, testID=1, uniqueID=1} / {1=b, 2=a, 3=c, testID=1, uniqueID=1}
Ended!
Finished!

which is nonsense as you can see from the code.

If you have any questions, just let me know.

@fixundfertig123
Copy link
Author

fixundfertig123 commented Jul 18, 2017

I commited a change adding ODatabaseRecordThreadLocal.INSTANCE in the beginning to run it from the shell, not just Eclipse

@tglman
Copy link
Member

tglman commented Jul 19, 2017

hi @fixundfertig123,

I could reproduce it and fix it, I added also a test case in our java suite, it will be released with 2.2.24 and 3.0.0-m2.

Regards.

@fixundfertig123
Copy link
Author

Hi @tglman,

great. Thanks! I assume you mean 2.2.24 ;-) Do you roughly know, when it will be available. I will test it as soon as available.

Regards

@tglman
Copy link
Member

tglman commented Jul 19, 2017

hi @fixundfertig123,

Yep sure changed, is going to be this week or at most next.

Regards

@santo-it
Copy link

Hi,

We are releasing 2.2.24. I am closing this issue now.
If you have any further problems related to this, please feel free to comment here and we will reopen the issue.

Many thanks,

@fixundfertig123
Copy link
Author

fixundfertig123 commented Aug 1, 2017

Hi @santo-it, @tglman, @lvca,

I just run into a strange issue with the in memory database and testsuites. It looks like a similar issue than the one above, but also strange. I wrote a TestClass and added it via a project: https://github.com/fixundfertig123/7547/releases/tag/InMemoryErrorFlatSpec (via sbt: clean / compile / test)

As you will see, although the graphs are fetched from for every test from the pool, they are somehow not handled correctly. If you enable "graph.getRawGraph.reload" in line 76 it works.

Thanks & Cheers

@santo-it santo-it reopened this Aug 2, 2017
@careerscale
Copy link

@santo-it pls make sure if anything is updated for good, pls get that to 3.0 develop branch too.

@lvca lvca modified the milestones: 2.2.x (next hotfix), 2.2.24 Aug 2, 2017
@fixundfertig123
Copy link
Author

Hi @lvca, @tglman: A short question. Could you work with my repo and can you reproduce the error?

@fixundfertig123
Copy link
Author

@tglman Sorry for bothering you, but this issue is blocking our testsuite and migration to a current 2.2.x. Could you please give me an indication, whether you can confirm my bug. Kind regards

@tglman
Copy link
Member

tglman commented Aug 10, 2017

hi @fixundfertig123,

We tried to run the project and we got some problem I opened a different issue on that problem, here it is: #7641, I'm closing this one again, regards.

@luigidellaquila luigidellaquila removed this from the 2.2.x (next hotfix) milestone Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

6 participants