Issue Details (XML | Word | Printable)

Key: JCR-2057
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Sébastien Launay
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jackrabbit Content Repository

When creating multiple repository instances pointing to the same home, opening a second session will remove the .lock file

Created: 07/Apr/09 08:46 AM   Updated: 29/Apr/09 07:50 AM
Return to search
Component/s: jackrabbit-core
Affects Version/s: core 1.4.7, 1.5.3
Fix Version/s: 1.5.5

Time Tracking:
Not Specified

File Attachments:
  Size
Zip Archive Licensed for inclusion in ASF works JCR-2057-2009-04-07.zip 2009-04-07 08:56 AM Sébastien Launay 3 kB
Environment: Ubuntu Intrepid
Issue Links:
Reference
 

Resolution Date: 09/Apr/09 12:14 PM


 Description  « Hide
The following test case can be used to reproduce the bug:
Repository repo1 = new TransientRepository(repoConfig);
Session session1_1 = repo1.login(...);
Session session2_2 = repo1.login(...);
Repository repo2 = new TransientRepository(repoConfig); // Will not fail (expected)
Session session2_1 = repo2.login(...); // Will fail with javax.jcr.RepositoryException: The repository home /tmp/_repository appears to be already locked by the current process (expected)
Session session2_2 = repo2.login(...); // Will work!
Repository repo3 = new TransientRepository(repoConfig); // Will not fail either (expected)
Session session3_1 = repo3.login(...); // Will fail with javax.jcr.RepositoryException: The repository home /tmp/_repository appears to be already locked by the current process (expected)
Session session3_2 = repo3.login(...); // Will fail with javax.jcr.RepositoryException: Directory was previously created with a different LockFactory instance

Open the first session in repo2 will fails but will also remove the .lock file, thus the second
session will succeed and may corrupt the repository because there are multiple session
opened from multiple repository.
The same behaviour occurs for repo3, the .lock file is removed but it is a slightly different case
as a new exception will be thrown while creating the Lucene index.

This is a clearly a twisted case as repositories pointing to the same home must not be created
simultaneously but i think that it must be more robust to prevent data corruption.

I reproduce the bug on JR 1.4.7 and 1.5.3 but i think it affects at least all versions of JR < 1.5.3.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Sébastien Launay added a comment - 07/Apr/09 08:56 AM
Test for reproducing this bug, dependencies are described in dependencies.txt.

Marcel Reutegger added a comment - 09/Apr/09 09:11 AM
As indicated in the environment field, this only happens on a *nix box.

The RepositoryLock handling in the RepositoryImpl constructor is incorrect. The lock is acquired in a try/catch block with the rest of the initialization code. If anything goes wrong then the shutdown method is called, which also includes releasing the RepositoryLock. This also happens when the initialization fails due to an unsuccessful attempt to acquire the repository lock :-/

Marcel Reutegger added a comment - 09/Apr/09 12:14 PM
Fixed in revision: 763617

Jukka Zitting added a comment - 21/Apr/09 08:35 AM
Merged to the 1.5 branch in revision 767069.