Hi,

I noticed that MERGE INTO is not atomically executed, and if multiple 
threads are merging using the same primary key chances are you get primary 
key violation:

org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: 
"PRIMARY_KEY_2 ON PUBLIC.TRAN(ID) VALUES (314159, 2948488)"; SQL statement:
MERGE INTO tran (id) values(?) [23505-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)
at org.h2.mvstore.db.MVSecondaryIndex.checkUnique(MVSecondaryIndex.java:231)
at org.h2.mvstore.db.MVSecondaryIndex.add(MVSecondaryIndex.java:190)
at org.h2.mvstore.db.MVTable.addRow(MVTable.java:705)
at org.h2.command.dml.Merge.merge(Merge.java:161)
at org.h2.command.dml.Merge.update(Merge.java:106)
at org.h2.command.CommandContainer.update(CommandContainer.java:101)
at org.h2.command.Command.executeUpdate(Command.java:260)
at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:207)
at Arte.call(Test.java:82)
at Arte.call(Test.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Is this the intended behaviour?

Thanks and kind regards,

--
Jonathan.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to