db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Sitsky (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6975) ERROR 40XL1: A lock could not be obtained within the time requested
Date Wed, 01 Nov 2017 01:19:00 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16233547#comment-16233547
] 

David Sitsky commented on DERBY-6975:
-------------------------------------

Hi Rick - many thanks for your reply.

I haven't tried changing derby.language.sequence.preallocator, what should I change it to?
 

For 2) - only a single thread is accessing the DB.

We are using calls such as below:
{code}
        try (PreparedStatement ps = connection.prepareStatement("INSERT INTO table (col1,
col2, name) VALUES (?, ?, ?)",
                                                                Statement.RETURN_GENERATED_KEYS))
{code}
and then retrieving the ID of the row using this sort of code:
{code}
    public static int getGeneratedIntKey(Statement statement) throws SQLException
    {
        try (ResultSet rs = statement.getGeneratedKeys())
        {
            if (rs == null)
            {
                throw new IllegalStateException("Caller forgot to pass Statement.RETURN_GENERATED_KEYS");
            }

            if (rs.next())
            {
                return rs.getInt(1);
            }
            else
            {
                throw new IllegalStateException("Caller did not perform an update");
            }
        }
    }
{code}
For the tables, we use an id field as follows:
{noformat}
                              " id          INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
NOT NULL," +
{noformat}
For 4) - yes as you can see in the code above.  For 5) no code calls SYS.SYSSEQUENCES.

> ERROR 40XL1: A lock could not be obtained within the time requested 
> --------------------------------------------------------------------
>
>                 Key: DERBY-6975
>                 URL: https://issues.apache.org/jira/browse/DERBY-6975
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.14.1.0
>            Reporter: David Sitsky
>            Priority: Major
>
> I have an application that when run on a certain dataset, every 5 runs I might see this
error happening.  The code is creating a lot of rows using a sequence generator.
> {noformat}
> Caused by: ERROR 40XL1: A lock could not be obtained within the time requested 
>         at org.apache.derby.iapi.error.StandardException.newException(StandardException.java)

>         at org.apache.derby.iapi.error.StandardException.newException(StandardException.java)

>         at org.apache.derby.impl.sql.catalog.SequenceUpdater.tooMuchContentionException(SequenceUpdater.java)

>         at org.apache.derby.impl.sql.catalog.SequenceUpdater.getCurrentValueAndAdvance(SequenceUpdater.java)

>         at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getCurrentValueAndAdvance(DataDictionaryImpl.java)

>         at org.apache.derby.impl.sql.execute.BaseActivation.getCurrentValueAndAdvance(BaseActivation.java)

>         at org.apache.derby.impl.sql.execute.InsertResultSet.getSetAutoincrementValue(InsertResultSet.java)

>         at org.apache.derby.impl.sql.execute.BaseActivation.getSetAutoincrementValue(BaseActivation.java)

>         at org.apache.derby.exe.ac560740aax015fx6bc1x68cax000002339e626a.e0(ac560740aax015fx6bc1x68cax000002339e626a.java)

>         at org.apache.derby.impl.services.reflect.DirectCall.invoke(DirectCall.java)

>         at org.apache.derby.impl.sql.execute.RowResultSet.getNextRowCore(RowResultSet.java)

>         at org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(NormalizeResultSet.java)

>         at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(DMLWriteResultSet.java)

>         at org.apache.derby.impl.sql.execute.InsertResultSet.getNextRowCore(InsertResultSet.java)

>         at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java)

>         at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java)

>         at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java)

>         ... 25 more 
> {noformat}
> It is not clear to me why when looking at the code this should be happening.  



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message