users@glassfish.java.net

Re: A lock could not be obtained within the time requested

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Wed, 05 Oct 2011 16:35:14 -0700

Why would an application being restarted?

There can be an unfinished XA transaction that needs to be recovered to
remove the locks on the database, or there might be another thread
trying to access the same instance (and by default, it's an embedded
derby server, so no 2 VMs can access it at the same time).

-marina

forums_at_java.net wrote:
> Hello, I have a Problem with glassfish 3.1.1 and the
> ejb-timer-service. First
> when I deployed my application everything worked fine, but after some
> days,
> logging of the server immediatly stopped. I investigated the logs and
> saw,
> that there are error messages when trying to restart the application.
> [font=Courier] Internal Exception:
> java.sql.SQLTransactionRollbackException:
> A lock could not be obtained within the time requested Error Code: 30000
> Call: SELECT "TIMERID", "APPLICATIONID", "BLOB", "CONTAINERID",
> "CREATIONTIMERAW", "INITIALEXPIRATIONRAW", "INTERVALDURATION",
> "LASTEXPIRATIONRAW", "OWNERID", "PKHASHCODE", "SCHEDULE", "STATE" FROM
> "EJB__TIMER__TBL" WHERE (("OWNERID" = ?) AND ("STATE" = ?)) bind => [2
> parameters bound] Query: ReadAllQuery(name="findTimersByOwnerAndState"
> referenceClass=TimerState sql="SELECT "TIMERID", "APPLICATIONID", "BLOB",
> "CONTAINERID", "CREATIONTIMERAW", "INITIALEXPIRATIONRAW",
> "INTERVALDURATION",
> "LASTEXPIRATIONRAW", "OWNERID", "PKHASHCODE", "SCHEDULE", "STATE" FROM
> "EJB__TIMER__TBL" WHERE (("OWNERID" = ?) AND ("STATE" = ?))") [/font]
> So I
> undeployed my application and redeployed it with the result
> [font=Courier]
> Exception while loading the app. EJB Timer Service is not available
> Please
> see server logs for more details. [/font] My thaughts were, that it has
> something to do with the built in jdbc__TimerPool and the derby
> database, so
> I stopped the Glassfish-3.1.1 Instance. because I found this article
> http://www.lyonlabs.org/howto/howdoi-glassfish.html „Problems with
> Persistent Timers“ and tried to access the interal derby database, to
> delete the persitent timers, because I use persistent timers in my
> application and sometimes they are not deleted and attempts to redeliever
> expired timers are made at server startup. [font=Courier]
> /opt/glassfish3/javadb/bin/ij ij> connect
> 'jdbc:derby:/opt/glassfish3/glassfish/domains/domain1/lib/databases/ejbtimer';
>
> ij> show tables; TABLE_SCHEM |TABLE_NAME |REMARKS
> ------------------------------------------------------------------------
> SYS
> |SYSALIASES | SYS |SYSCHECKS | SYS |SYSCOLPERMS | SYS |SYSCOLUMNS | SYS
> |SYSCONGLOMERATES | SYS |SYSCONSTRAINTS | SYS |SYSDEPENDS | SYS
> |SYSFILES |
> SYS |SYSFOREIGNKEYS | SYS |SYSKEYS | SYS |SYSPERMS | SYS |SYSROLES | SYS
> |SYSROUTINEPERMS | SYS |SYSSCHEMAS | SYS |SYSSEQUENCES | SYS
> |SYSSTATEMENTS |
> SYS |SYSSTATISTICS | SYS |SYSTABLEPERMS | SYS |SYSTABLES | SYS
> |SYSTRIGGERS |
> SYS |SYSVIEWS | SYSIBM |SYSDUMMY1 | APP |EJB__TIMER__TBL | 23 rows
> selected
> ij> select * from EJB__TIMER__TBL; TIMERID |APPLICATIONID |BLOB
> |CONTAINERID
> |CREATIONTIMERAW |INITIALEXPIRATIONRAW|INTERVALDURATION
> |LASTEXPIRATIONRAW
> |OWNERID |PKHASHCODE |SCHEDULE |STATE
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> ERROR 40XL1: A lock could not be obtained within the time requested ij>
> [/font] So obviously the problem is, that there are locks on the
> javaDB that
> prevent accessing and using it for the timer-service, but despite
> serveral
> reboots the locks remain. EJB__TIMER__TBL obviously exist, there is no
> glassfish instance running, because if glassfish is running connection
> attempts to the javaDB are refused. Just to be sure a call to
> http://xxx.xxx.xxx.xxx:8080/ejb-timer-service-app/timer delivers HTTP
> Status
> 404 – so there is no timer service running. Altough this is a non
> clustered
> Environment, I tried to use the jdbc/__default for the server config
> with no
> success. So there is no ejb-timer-service running and can't be
> reactivated.
> The only thing I can do from this point is to reinstall whole
> glassfish-3.1.1
> and everything will be fine again for the next few days. I had this issue
> couple of times and we are looking for a way out of this problem,
> because we
> can't cope with this issue in our live environment. Any help would be
> apreciated, thanks regards j.
>
> --
>
> [Message sent by forum member 'jcite']
>
> View Post: http://forums.java.net/node/850201
>
>
>