db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <kristian.waa...@oracle.com>
Subject Re: Shutting down in-memory Derby gracefully
Date Tue, 17 Jan 2012 09:09:46 GMT
On 17.01.12 03:14, Pavel Bortnovskiy wrote:
> Hello, all
>
> can someone please also shed light on the following:
>
> In addition to the problems described in the previous email (below), I also get intermittent
" Database 'memory:test' not found" errors while shutting down Derby:

Hi Pavel,

I don't know what's causing this intermittent error. The first thing 
that comes to mind is concurrent attempts to boot and/or drop the 
database. I don't know if this could be happening in you application?

Regarding the errors you are seeing when dropping the database, I think 
that's what you have to expect from Derby at this time when you have 
active connections at the time of the drop/shutdown. I don't think this 
is limited to the in-memory back end.
The only way to avoid these errors popping up is to coordinate the 
shutdown/drop from the application layer.

As a side note, I did some work on a mechanism that you may find useful. 
You can read the description of it under DERBY-4447 [1].


Regards,
-- 
Kristian

[1] https://issues.apache.org/jira/browse/DERBY-4447

>
> Error while shutting down:
> java.sql.SQLException: Database 'memory:test' not found.
>          at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
>          at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
>          at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)    
                                                                  at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
>          at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
>          at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
>          at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
>          at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
>          at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
>          at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
>          at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
>          at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
>          at java.sql.DriverManager.getConnection(DriverManager.java:582)
>          at java.sql.DriverManager.getConnection(DriverManager.java:207)
> Caused by: java.sql.SQLException: Database 'memory:test' not found.
>          at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>          at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
>          ... 21 more
>
> This error doesn't happen all the time, it's intermittent and I suspect that it might
have be somehow connected to other problems I've been having trying to shutdown in-memory
Derby DB gracefully.
>
> Can someone please help me understand what's causing this particular problem?
>
> My code that's shutting down Derby is quite simple, and oddly it works most of the times,
but sometimes it throws this " Database 'memory:test' not found " error!
>
> Here is the excerpt of my shutdown code:
>
>      private static final String DB_DROP_URL = "jdbc:derby:memory:%DB_NAME%;drop=true";
>      private static final String DB_SHUTDOWN_URL = "jdbc:derby:;shutdown=true";
>
>      private static class ShutdownAction {
>          final private String m_url;
>          final private int m_errorCode;
>          final private String m_sqlState;
>
>          private ShutdownAction(final String url, final int errorCode, final String sqlState)
{
>              m_url = url;
>              m_errorCode = errorCode;
>              m_sqlState = sqlState;
>          }
>
>          private void doAction(final String dbName) {
>              final String url = m_url.replace("%DB_NAME%", dbName);
>              logger.info("Executing Derby Shutdown Command: " + url);
>              try {
>                  DriverManager.getConnection(url);
>              } catch (SQLException e) {
>                  if ((e.getErrorCode() != m_errorCode) || (!m_sqlState.equals(e.getSQLState())))
{
>                      logger.error("Error while shutting down:", e);
>                  }
>              }
>          }
>      }
>
>      private static final ShutdownAction[] ACTIONS = {
>              new ShutdownAction(DB_DROP_URL, 45000, "08006"),
>              new ShutdownAction(DB_SHUTDOWN_URL, 50000, "XJ015")
>      };
>
>      private String m_dbName;
>      private String m_dbCreateURL;
>
>      private NetworkServerControlPinger m_derbyServerControl;
>
>      @Override
>      final public void shutdown() {
>          for (final ShutdownAction action : ACTIONS) {
>              action.doAction(m_dbName);
>          }
>
>          m_derbyServerControl.shutdown();
>      }
>
>
>
> -----Original Message-----
> From: Pavel Bortnovskiy [mailto:pbortnovskiy@jefferies.com]
> Sent: Friday, January 13, 2012 10:01 AM
> To: Derby Discussion
> Subject: RE: Shutting down in-memory Derby gracefully
>
> Hello, Bryan:
>
> Thank you for your prompt response. I will report it as per guidelines.
>
> Would you be able to suggest anything that I could do in the meantime?
> We have watchdog processes monitoring error files and when the error files get populated
with these messages, the watchdog raises all kinds of alarms.
> This is more than just a nuisance, as it's causing havoc in some cases.
>
> Thank you,
> Pavel.
>
> -----Original Message-----
> From: Bryan Pendleton [mailto:bpendleton.derby@gmail.com]
> Sent: Friday, January 13, 2012 9:58 AM
> To: Derby Discussion
> Subject: Re: Shutting down in-memory Derby gracefully
>
>> While our application is shutting down, it is possible that some of
>> its components may continue execution or even begin execution of the
>> queries on the in-memory Derby DB. In such situation, Derby starts throwing all kinds
of exceptions, including a Null Pointer Exception (pls see excerpt from our log below).
>
> That looks like a bug to me, and worthy of reporting to the Derby developers.
>
> http://db.apache.org/derby/DerbyBugGuidelines.html
>
> thanks,
>
> bryan
>
>
> Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email,
including any attachments, are confidential to the ordinary user of the email address to which
it was addressed. If you are not the addressee of this email you may not copy, forward, disclose
or otherwise use it or any part of it in any form whatsoever. This email may be produced at
the request of regulators or in connection with civil litigation. Jefferies accepts no liability
for any errors or omissions arising as a result of transmission. Use by other than intended
recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International
Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames
Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the
Financial Services Authority.
> Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email,
including any attachments, are confidential to the ordinary user of the email address to which
it was addressed. If you are not the addressee of this email you may not copy, forward, disclose
or otherwise use it or any part of it in any form whatsoever. This email may be produced at
the request of regulators or in connection with civil litigation. Jefferies accepts no liability
for any errors or omissions arising as a result of transmission. Use by other than intended
recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International
Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames
Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the
Financial Services Authority.


Mime
View raw message