You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Tim Dudgeon <td...@informaticsmatters.com> on 2006/09/28 17:14:59 UTC

db.lck and dbex.lck files


I'm wanting to provide some feedback in my application when a derby 
database is opened and it was not shutdown properly last time it was used.

2 files seem to be created, db.lck and dbex.lck and are not deleted when 
the db is not shutdown cleanly.

Is there a way of distinguishing between the presence of these files 
being the result of a current process holding a lock on an open database 
(in which case the database cannot be opened) and it being the result of 
a bad shutdown, in which case the database can be opened, but there may 
be a delay whilst it is opened.

thanks

Tim


Re: db.lck and dbex.lck files

Posted by Tim Dudgeon <td...@informaticsmatters.com>.
Stanley Bradbury wrote:
> Tim Dudgeon wrote:
>>
>>
>> I'm wanting to provide some feedback in my application when a derby 
>> database is opened and it was not shutdown properly last time it was 
>> used.
>>
>> 2 files seem to be created, db.lck and dbex.lck and are not deleted 
>> when the db is not shutdown cleanly.
>>
>> Is there a way of distinguishing between the presence of these files 
>> being the result of a current process holding a lock on an open 
>> database (in which case the database cannot be opened) and it being 
>> the result of a bad shutdown, in which case the database can be 
>> opened, but there may be a delay whilst it is opened.
>>
>> thanks
>>
>> Tim
>>
>>
> Hi Tim -
> As you indicate, check if the files are locked by a process - if they 
> are then the database is most likely in use by a Derby process.  If they 
> are not locked 

So how best to do this? Is File.canWrite() sufficient?

then they are probably orphan files and then you can
> check for the number and size of the files in the 'log' subdirectory 

Any files in particular? There always seems to be files in here.

> to 
> see if there might be a delay due to recovery running when the DB is 
> next booted.  And I know you wouldn't do this but I feel compelled to 
> mention that  you should never directly manipulate these files in any way.

Of course :-)

Thanks

Tim


Re: db.lck and dbex.lck files

Posted by Stanley Bradbury <St...@gmail.com>.
Tim Dudgeon wrote:
>
>
> I'm wanting to provide some feedback in my application when a derby 
> database is opened and it was not shutdown properly last time it was 
> used.
>
> 2 files seem to be created, db.lck and dbex.lck and are not deleted 
> when the db is not shutdown cleanly.
>
> Is there a way of distinguishing between the presence of these files 
> being the result of a current process holding a lock on an open 
> database (in which case the database cannot be opened) and it being 
> the result of a bad shutdown, in which case the database can be 
> opened, but there may be a delay whilst it is opened.
>
> thanks
>
> Tim
>
>
Hi Tim -
As you indicate, check if the files are locked by a process - if they 
are then the database is most likely in use by a Derby process.  If they 
are not locked then they are probably orphan files and then you can 
check for the number and size of the files in the 'log' subdirectory to 
see if there might be a delay due to recovery running when the DB is 
next booted.  And I know you wouldn't do this but I feel compelled to 
mention that  you should never directly manipulate these files in any way.