db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suresh Thalamati <suresh.thalam...@gmail.com>
Subject Re: Database shutdown
Date Fri, 13 May 2005 01:48:48 GMT
If  the database is being properly shutdown , one case I can think, 
which might make Derby system spend
more time in recovery code  is rollback of the incomplete transactions; 
this can happen if you are crashing with
lot of  uncommitted long transactions.  Just curious
-   how much time is it spending in Logtofile.recover() code ?
-  are there lot of log files of large size in  the <database name>/ 
log  directory  ?

shutdown with the database name also should work.  Option without the 
database name shuts down the whole
cloudscape system not just one database.  Shutdown in derby throws 
exception,  you  may want to check
the error codes to make sure the system is being properly shutdown.

ij> connect 'jdbc:derby:wombat;shutdown=true';
ERROR 08006: Database 'wombat' shutdown.
ij> connect 'jdbc:derby:;shutdown=true';
ERROR XJ015: Derby system shutdown.


Thanks
-suresht
 
Piet Blok wrote:

> Andrew,
>
> Incidentally yesterday, when reading the new pdf manuals, I found out 
> about database shutdown, so I tried to implement it. From a shutdown 
> hook I call the following method:
>
>    protected void shutdown() {
>        Properties shutdownProperties = new Properties();
>        shutdownProperties.put("shutdown", "true");
>        try {
>            driver.connect("jdbc:derby:", shutdownProperties);
>        } catch (SQLException e) {
>            if (e.getErrorCode() == 50000) {
>                System.out.println(e.getLocalizedMessage());
>            } else {
>                e.printStackTrace();
>            }
>        }
>
>    }
>
> This works (up to now) perfectly. I believe the mistake you make is 
> adding the database name to the connection URL. In the above code 
> "driver" refers to an EmbeddedDriver instance, created like this:
>
>    private EmbeddedDriver driver = new EmbeddedDriver();
>
>> From this driver I obtained connections using, ofcourse, a database 
>> name.
>
>
> Kind regards,
>
> Piet Blok
>
> ----- Original Message ----- From: "Andrew Shuttlewood" 
> <andrew.shuttlewood@futureroute.co.uk>
> To: <derby-user@db.apache.org>
> Sent: Thursday, May 12, 2005 4:29 PM
> Subject: Database shutdown
>
>
>> We have a shutdown hook registered to close down our derby databases,
>> but every so often, even when the shutdown hook triggers, we find that
>> it spends a lot of time in LogToFile.recover
>>
>> Our shutdown hook looks something like
>>
>>        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable(){
>>            public void run() {
>>                try {
>>                    Log.log(Level.INFO, "Attempting shutdown of Embedded
>> Core Driver.");
>>                    DriverManager.getConnection("jdbc:derby:" +
>> Foo.this.databaseName + ";shutdown=true");
>>                } catch (SQLException e) {
>>                    System.out.println("Shutdown: " +
>> Foo.this.databaseName);
>>                    Log.log(Level.INFO, "Embedded Core Driver Shut
>> Down", e);
>>                }
>>            }
>>        }));
>>
>> This seems to do the right thing (sort of), but it doesn't always seem
>> to work. Am I missing something? Is a shutdown hook the absolutely wrong
>> place to do this? Am I perhaps making a obvious mistake?
>>
>> I can't really see the problem which is very frustrating!
>>
>> Also, in terms of memory usage, is it possible to reduce the amount of
>> memory used by all instances to some degree as we may wish to use a
>> number of instances at any one time. I was planning on potentially using
>> SoftReferences to manage a database pointer and then "shutting down" as
>> necessary, but I would quite like it if there was a way of setting a
>> global max number of pages or some such. Is this possible?
>>
>>
>
>
>



Mime
View raw message