Sounds like auto-increment keys require a global lock in the case of a clustered DB.
On Mon, Jul 25, 2011 at 21:12, Thomas Mueller <[email protected]>wrote: > Hi, > > I think I understand what the problem is. This is what should happen: > > (1) conn1: insert into database A => sequence 1 > (2) conn1: insert into database B => sequence 1 > (3) conn2: insert into database A => sequence 2 > (4) conn2: insert into database B => sequence 2 > > And what sometimes happens is: > > (1) conn1: insert into database A => sequence 3 > (2) conn2: insert into database A => sequence 4 > (3) conn2: insert into database B => sequence 3 > (4) conn1: insert into database B => sequence 4 > > That means, connection 1 is "overtaking" connection 2 in this case. > I'm not sure what is the best way to solve this problem; one way of > course is disallow using auto-increment keys, or at least document the > problem. That would be a pity, because sequences are very useful, but > I'm afraid this is what I will have to do. > > I didn't test so far if using sequences manually works (first select > the next value from a sequence, and then, in a separate statement, use > that value to insert into the table). > > Regards, > Thomas > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/h2-database?hl=en. > > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
