dibyendumajumdar / simpledbm

SimpleDBM is an Open Source Multi-Threaded Embeddable Transactional Database Engine in Java.
55 stars 12 forks source link

Server Lock File Problem #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an instance of SimpleDBM Server
2. Use that instance by storing data
3. Stop the instance by stopping your JVM using tasks manager or another
way different that Server.shutdown.
4. Try to restart the same instance using the same properties as those used
at the server creation time.

What is the expected output? 
The server should recover from the crash and restart properly.

What do you see instead?
An error caused by the StorageException exception saying that an existing
file .../_internal/lock already exists.

Please use labels and text to provide additional information.

Original issue reported on code.google.com by kaba.abo...@gmail.com on 9 Jun 2009 at 9:40

GoogleCodeExporter commented 9 years ago
More details from the posting at the mailing list:

I am integrating SimpleDBM into our system. But I am facing some problems or
limitations during the usage of the system.

The first problem is the system restarting problem. During a crash
simulation testing, when I stopped the system without calling
Server.shutdown() and then tried to restart it in a new session, I got
StorageException saying that may be another instance of the server is
running. The error description is below:

Cause: StorageException

Message: SIMPLEDBM-EV0005: Error starting SimpleDBM RSS Server, another
instance may be running - error was: SIMPLEDBM-ES0017: Unable to create
StorageContainer
C:\eclipse\runtime-workbench-workspace\.metadata\.plugins\FileSystem\ProjectStor
eDbs\_internal\lock
because an object of the name already exists

Below is how I am starting an instance of the server:

*            if* (serverStarted) {

                  *throw* *new* RuntimeException("Server is already started");
//$NON-NLS-1$

            }

            server = *new* Server(*getServerProperties*());

            server.start();

            serverStarted = *true*;

getServerProperties() returns the same properties as those used when the
server is created.

I noticed that I am using transactions for all my operation on data and
indexes. Thus I believe that transactions committing will release all locks.

When I manually delete the lock file from _internal folder, everything is
ok. I don’t know if it a good practice to do so.

If somebody knows how to properly restart the server without loosing already
saved data and without manually deleting the lock file, that will be very
helpful. 

Original comment by d.majum...@gmail.com on 28 Jun 2009 at 3:05

GoogleCodeExporter commented 9 years ago
Finally got around to testing this. It is actually not a defect as SimpleDBM is 
behaving as it should. In order to 
detect whether multiple instances of SimpleDBM are executing concurrently, 
SimpleDBM uses a lock file that it 
creates atomically. This atomic creation only works if the file does not 
already exist. If the file exists, the 
creation fails and SimpleDBM concludes that some other instance is running.

Normally, a well behaved program is expected to do a database shutdown before 
terminating. If the database 
is not shutdown, the lock file is not deleted. In this case, the next time 
SimpleDBM is started, it will fail 
because it cannot create the lock file.

In this situation, if it is known that another instance is not running, then 
the lock file can be manually deleted. 

I will update the SimpleDBM user guide with this information, and then close 
this issue.

Original comment by d.majum...@gmail.com on 12 Sep 2009 at 7:08

GoogleCodeExporter commented 9 years ago
Updated the Database API document.

Original comment by d.majum...@gmail.com on 18 Oct 2009 at 3:24