From 8b1ea3500085bbaa5497b7370effd41d4ad207a4 Mon Sep 17 00:00:00 2001 From: Thomas Beckmann Date: Fri, 8 Dec 2023 09:48:52 +0100 Subject: [PATCH] when storing job with replace check update count returned -- This is to detect non-durable job suddenly disappearing when concurrently completing. On MariaDB/MySQL the fall-through code path select-update-insert can be taken due to consistent nonblocking read and multi-version concurrency control. Signed-off-by: Thomas Beckmann --- .../org/quartz/impl/jdbcjobstore/JobStoreSupport.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreSupport.java b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreSupport.java index 1897d4604..4ba8de22e 100644 --- a/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreSupport.java +++ b/quartz/src/main/java/org/quartz/impl/jdbcjobstore/JobStoreSupport.java @@ -1112,9 +1112,12 @@ protected void storeJob(Connection conn, if (!replaceExisting) { throw new ObjectAlreadyExistsException(newJob); } - getDelegate().updateJobDetail(conn, newJob); - } else { - getDelegate().insertJobDetail(conn, newJob); + if (getDelegate().updateJobDetail(conn, newJob) > 0) { + return; + } + } + if (getDelegate().insertJobDetail(conn, newJob) < 1) { + throw new JobPersistenceException("Couldn't store job. Insert failed."); } } catch (IOException e) { throw new JobPersistenceException("Couldn't store job: "