Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72BF611225 for ; Wed, 6 Aug 2014 13:31:13 +0000 (UTC) Received: (qmail 42032 invoked by uid 500); 6 Aug 2014 13:31:13 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 42007 invoked by uid 500); 6 Aug 2014 13:31:13 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 41902 invoked by uid 99); 6 Aug 2014 13:31:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2014 13:31:13 +0000 Date: Wed, 6 Aug 2014 13:31:13 +0000 (UTC) From: "Rick Hillegas (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DERBY-6692) Self-deadlock when inserting row with identity column in soft-upgraded database MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-6692?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rick Hillegas updated DERBY-6692: --------------------------------- Attachment: derby-6692-01-aa-handleSelfDeadlock.diff Attaching derby-6692-01-aa-handleSelfDeadlock.diff. This patch fixes the bug. This situation is exactly the self-deadlock scenario addressed by the machinery which derby-6554 introduced. In 10.10, a lock-timeout exception is thrown in this case. That exception is caught by InsertResultSet, which then escalates the identity-bumping into the parent transaction. The fix is to make InsertResultSet check for self-deadlock as well as lock-timeout. Touches the following file: M java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java > Self-deadlock when inserting row with identity column in soft-upgraded database > ------------------------------------------------------------------------------- > > Key: DERBY-6692 > URL: https://issues.apache.org/jira/browse/DERBY-6692 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.11.1.1 > Reporter: Knut Anders Hatlen > Assignee: Rick Hillegas > Attachments: derby-6692-01-aa-handleSelfDeadlock.diff > > > Create a database called "wombat" with Derby 10.10.2.0. > Then, in the same directory, execute the following code using the 10.11.1.0 release candidate: > {code} > Connection c = DriverManager.getConnection("jdbc:derby:wombat"); > c.setAutoCommit(false); > Statement s = c.createStatement(); > s.execute("create table t(i int generated always as identity)"); > s.execute("insert into t values (default)"); > c.rollback(); > {code} > The INSERT statement will fail with a self-deadlock: > {noformat} > Exception in thread "main" java.sql.SQLTransactionRollbackException: Self-deadlock. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) > at Kladd.main(Kladd.java:12) > Caused by: ERROR 40XL2: Self-deadlock. > at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) > at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) > at org.apache.derby.impl.services.locks.ConcurrentLockSet.lockObject(Unknown Source) > at org.apache.derby.impl.services.locks.AbstractPool.lockObject(Unknown Source) > at org.apache.derby.impl.services.locks.ConcurrentPool.lockObject(Unknown Source) > at org.apache.derby.impl.store.raw.xact.RowLocking3.lockRecordForWrite(Unknown Source) > at org.apache.derby.impl.store.access.conglomerate.OpenConglomerate.lockPositionForWrite(Unknown Source) > at org.apache.derby.impl.store.access.conglomerate.GenericConglomerateController.fetch(Unknown Source) > at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSetAutoincrementValue(Unknown Source) > at org.apache.derby.impl.sql.execute.InsertResultSet.getOldStyleIdentityValue(Unknown Source) > at org.apache.derby.impl.sql.execute.InsertResultSet.getSetAutoincrementValue(Unknown Source) > at org.apache.derby.impl.sql.execute.BaseActivation.getSetAutoincrementValue(Unknown Source) > at org.apache.derby.exe.acaaeec04ex0147xab31x1ccax000007dedc900.e0(Unknown Source) > at org.apache.derby.impl.services.reflect.DirectCall.invoke(Unknown Source) > at org.apache.derby.impl.sql.execute.RowResultSet.getNextRowCore(Unknown Source) > at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(Unknown Source) > at org.apache.derby.impl.sql.execute.InsertResultSet.getNextRowCore(Unknown Source) > at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source) > at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source) > at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source) > ... 4 more > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)