You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/06/13 12:38:43 UTC

jena git commit: Add the local process id to the exception message.

Repository: jena
Updated Branches:
  refs/heads/master 874ad4edc -> dc2218657


Add the local process id to the exception message.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/dc221865
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/dc221865
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/dc221865

Branch: refs/heads/master
Commit: dc2218657bcdf98d25b8e7c30211d42490ab3d25
Parents: 874ad4e
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Jun 13 13:38:31 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Jun 13 13:38:31 2018 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/jena/tdb/StoreConnection.java  | 12 +++++++++---
 .../org/apache/jena/tdb/base/file/LocationLock.java     |  6 +++---
 2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/dc221865/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
index f645442..978ee78 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
@@ -32,6 +32,7 @@ import org.apache.jena.tdb.base.file.LocationLock ;
 import org.apache.jena.tdb.setup.DatasetBuilderStd ;
 import org.apache.jena.tdb.setup.StoreParams ;
 import org.apache.jena.tdb.store.DatasetGraphTDB ;
+import org.apache.jena.tdb.sys.ProcessUtils;
 import org.apache.jena.tdb.sys.SystemTDB ;
 import org.apache.jena.tdb.transaction.* ;
 
@@ -256,15 +257,20 @@ public class StoreConnection
                 // Obtain the lock ASAP
                 LocationLock lock = location.getLock();
                 if (lock.canLock()) {
-                    if (!lock.canObtain()) 
-                        throw new TDBException("Can't open database at location " + location.getDirectoryPath() + " as it is already locked by the process with PID " + lock.getOwner() + ".  TDB databases do not permit concurrent usage across JVMs so in order to prevent possible data corruption you cannot open this location from the JVM that does not own the lock for the dataset");
+                    if (!lock.canObtain()) {
+                        int here = ProcessUtils.getPid(0);
+                        throw new TDBException("Process ID "+here+" can't open database at location " + location.getDirectoryPath() + " because it is already locked by the process with PID " + lock.getOwner() + ". "+
+                            "TDB databases do not permit concurrent usage across JVMs so in order to prevent possible data corruption you cannot open this location from the JVM that does not own the lock for the dataset");
+                    }
 
                     lock.obtain();
                     // There's an interesting race condition here that two JVMs might write out the lock file one after another without
                     // colliding and causing an IO error in either.  The best way to check for this is simply to check we now own the lock
                     // and if not error
                     if (!lock.isOwned()) {
-                        throw new TDBException("Can't open database at location " + location.getDirectoryPath() + " as it is alread locked by the process with PID " + lock.getOwner() + ".  TDB databases do not permit concurrent usage across JVMs so in order to prevent possible data corruption you cannot open this location from the JVM that does not own the lock for the dataset");
+                        int here = ProcessUtils.getPid(0);
+                        throw new TDBException("Process ID "+here+" failed to open database at location " + location.getDirectoryPath() + " because it is already locked by the process with PID " + lock.getOwner() + ". "+
+                            "TDB databases do not permit concurrent usage across JVMs so in order to prevent possible data corruption you cannot open this location from the JVM that does not own the lock for the dataset");
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/jena/blob/dc221865/jena-tdb/src/main/java/org/apache/jena/tdb/base/file/LocationLock.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/base/file/LocationLock.java b/jena-tdb/src/main/java/org/apache/jena/tdb/base/file/LocationLock.java
index aabc5b6..c42bc41 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/base/file/LocationLock.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/base/file/LocationLock.java
@@ -161,10 +161,10 @@ public class LocationLock {
         if (owner == NO_OWNER) {
             // No owner currently so try to obtain the lock
             if (pid == NO_OWNER) {
-                // In the case where we cannot obtain our PID then we cannot
-                // obtain a lock
+                // In the case where we cannot obtain our PID then we cannot obtain a lock
                 SystemTDB.errlog.warn("Location " + location.getDirectoryPath()
-                        + " cannot be locked as unable to obtain PID of current process, if another JVM accessed this location while this process is accessing it then data corruption may occur");
+                        + " cannot be locked as unable to obtain PID of current process."
+                        + " If another JVM accessed this location while this process is accessing it then data corruption may occur");
                 return;
             }