From f11164bde7cbf7c266710a9555da47c79470c204 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 10 Jul 2024 21:11:38 +0200 Subject: [PATCH 1/7] Fix #164: - store the storage lock in class LockEntry rather than in class SingleLock, - as a consequence: obtain only one storage lock when mutliple shared locks are requested on the same dataset, - release the storage lock when the lock count drops to zero, e.g. when the last lock on the dataset is closed. --- .../java/org/icatproject/ids/LockManager.java | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/icatproject/ids/LockManager.java b/src/main/java/org/icatproject/ids/LockManager.java index 86225ea1..0d74095a 100644 --- a/src/main/java/org/icatproject/ids/LockManager.java +++ b/src/main/java/org/icatproject/ids/LockManager.java @@ -38,11 +38,13 @@ public class LockInfo { private class LockEntry { final Long id; final LockType type; + final AutoCloseable storageLock; int count; - LockEntry(Long id, LockType type) { + LockEntry(Long id, LockType type, AutoCloseable storageLock) { this.id = id; this.type = type; + this.storageLock = storageLock; this.count = 0; lockMap.put(id, this); } @@ -56,6 +58,13 @@ void dec() { count -= 1; if (count == 0) { lockMap.remove(id); + if (storageLock != null) { + try { + storageLock.close(); + } catch (Exception e) { + logger.error("Error while closing lock on {} in the storage plugin: {}.", id, e.getMessage()); + } + } } } } @@ -74,12 +83,10 @@ public void close() { private class SingleLock extends Lock { private final Long id; private boolean isValid; - private AutoCloseable storageLock; - SingleLock(Long id, AutoCloseable storageLock) { + SingleLock(Long id) { this.id = id; this.isValid = true; - this.storageLock = storageLock; } public void release() { @@ -87,13 +94,6 @@ public void release() { if (isValid) { lockMap.get(id).dec(); isValid = false; - if (storageLock != null) { - try { - storageLock.close(); - } catch (Exception e) { - logger.error("Error while closing lock on {} in the storage plugin: {}.", id, e.getMessage()); - } - } logger.debug("Released a lock on {}.", id); } } @@ -136,22 +136,17 @@ public Lock lock(DsInfo ds, LockType type) throws AlreadyLockedException, IOExce synchronized (lockMap) { LockEntry le = lockMap.get(id); if (le == null) { - le = new LockEntry(id, type); + AutoCloseable storageLock; + storageLock = mainStorage.lock(ds, type == LockType.SHARED); + le = new LockEntry(id, type, storageLock); } else { if (type == LockType.EXCLUSIVE || le.type == LockType.EXCLUSIVE) { throw new AlreadyLockedException(); } } le.inc(); - AutoCloseable storageLock; - try { - storageLock = mainStorage.lock(ds, type == LockType.SHARED); - } catch (AlreadyLockedException | IOException e) { - le.dec(); - throw e; - } logger.debug("Acquired a {} lock on {}.", type, id); - return new SingleLock(id, storageLock); + return new SingleLock(id); } } From 4cd009eb945b32eeb1e017d7d56f9fd1a6973101 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 10 Jul 2024 22:10:49 +0200 Subject: [PATCH 2/7] Update release notes --- src/site/xhtml/release-notes.xhtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/site/xhtml/release-notes.xhtml b/src/site/xhtml/release-notes.xhtml index b475ebcf..7cbd1b8c 100644 --- a/src/site/xhtml/release-notes.xhtml +++ b/src/site/xhtml/release-notes.xhtml @@ -7,7 +7,9 @@

IDS Server Release Notes

2.1.1 (not yet released)

+

Bug fix release

From be829488ec26c8525da804cdd8bf5219a2ca5213 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Fri, 12 Jul 2024 15:07:10 +0200 Subject: [PATCH 3/7] Fix white space --- src/main/java/org/icatproject/ids/LockManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/icatproject/ids/LockManager.java b/src/main/java/org/icatproject/ids/LockManager.java index 0d74095a..c75f9ea5 100644 --- a/src/main/java/org/icatproject/ids/LockManager.java +++ b/src/main/java/org/icatproject/ids/LockManager.java @@ -41,7 +41,7 @@ private class LockEntry { final AutoCloseable storageLock; int count; - LockEntry(Long id, LockType type, AutoCloseable storageLock) { + LockEntry(Long id, LockType type, AutoCloseable storageLock) { this.id = id; this.type = type; this.storageLock = storageLock; From df38e61eb0005477d1fa73bd990d8838ca811fd4 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Fri, 12 Jul 2024 15:21:11 +0200 Subject: [PATCH 4/7] Update release notes for release 2.1.1 --- src/site/xhtml/release-notes.xhtml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/site/xhtml/release-notes.xhtml b/src/site/xhtml/release-notes.xhtml index 7cbd1b8c..3ec28376 100644 --- a/src/site/xhtml/release-notes.xhtml +++ b/src/site/xhtml/release-notes.xhtml @@ -6,7 +6,7 @@

IDS Server Release Notes

-

2.1.1 (not yet released)

+

2.1.1

Bug fix release

  • #164, #166: Fix duplicate calls of mainStorage.lock() in LockManager.
  • @@ -30,6 +30,12 @@
+

1.12.2

+

Bug fix release

+
    +
  • #164, #165: Fix duplicate calls of mainStorage.lock() in LockManager.
  • +
+

1.12.1

  • #122: Bump dependency on logback-classic to version 1.2.0.
  • From 861335c0a3f65d8c5de6c3d428a29f6b2442ceec Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Fri, 12 Jul 2024 16:28:46 +0200 Subject: [PATCH 5/7] Deprecate putAsPost --- src/main/java/org/icatproject/ids/IdsService.java | 1 + src/site/xhtml/release-notes.xhtml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/org/icatproject/ids/IdsService.java b/src/main/java/org/icatproject/ids/IdsService.java index 7afe1d3e..daf957bc 100644 --- a/src/main/java/org/icatproject/ids/IdsService.java +++ b/src/main/java/org/icatproject/ids/IdsService.java @@ -544,6 +544,7 @@ public Response put(@Context HttpServletRequest request, InputStream body, @Path("put") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) + @Deprecated public Response putAsPost(@Context HttpServletRequest request) throws BadRequestException, NotFoundException, InternalException, InsufficientPrivilegesException, NotImplementedException, DataNotOnlineException { try { diff --git a/src/site/xhtml/release-notes.xhtml b/src/site/xhtml/release-notes.xhtml index 3ec28376..78a10185 100644 --- a/src/site/xhtml/release-notes.xhtml +++ b/src/site/xhtml/release-notes.xhtml @@ -11,6 +11,7 @@
    • #164, #166: Fix duplicate calls of mainStorage.lock() in LockManager.
    • #140, #158: Fix miredot build.
    • +
    • Deprecate the putAsPost call.

    2.1.0

    From c0efc12fe2b027c8d1c1aaab4186a73dfe7ae11b Mon Sep 17 00:00:00 2001 From: Build user Date: Fri, 12 Jul 2024 17:01:09 +0200 Subject: [PATCH 6/7] [maven-release-plugin] prepare release v2.1.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6be052fa..269c3d0a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.icatproject ids.server war - 2.1.1-SNAPSHOT + 2.1.1 IDS Server @@ -33,7 +33,7 @@ scm:git:https://github.com/icatproject/ids.server.git scm:git:git@github.com:icatproject/ids.server.git https://github.com/icatproject/ids.server - HEAD + v2.1.1 From 94a7dbc797b0b33924fd1e5d6c91fd3ed97ce2cb Mon Sep 17 00:00:00 2001 From: Build user Date: Fri, 12 Jul 2024 17:01:13 +0200 Subject: [PATCH 7/7] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 269c3d0a..06cb4835 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.icatproject ids.server war - 2.1.1 + 2.1.2-SNAPSHOT IDS Server @@ -33,7 +33,7 @@ scm:git:https://github.com/icatproject/ids.server.git scm:git:git@github.com:icatproject/ids.server.git https://github.com/icatproject/ids.server - v2.1.1 + HEAD