Repository: hive Updated Branches: refs/heads/master 1fc122153 -> f01269123
HIVE-17840: HiveMetaStore eats exception if transactionalListeners.notifyEvent fail (Sankar Hariappan, reviewed by Mahesh Kumar Behera, Daniel Dai) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/f0126912 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/f0126912 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/f0126912 Branch: refs/heads/master Commit: f01269123652d977e93dba656a847f800eeb2c61 Parents: 1fc1221 Author: Sankar Hariappan <sank...@apache.org> Authored: Tue Jul 3 10:08:57 2018 +0530 Committer: Sankar Hariappan <sank...@apache.org> Committed: Tue Jul 3 10:08:57 2018 +0530 ---------------------------------------------------------------------- .../hive/hcatalog/listener/DummyRawStoreFailEvent.java | 2 +- .../java/org/apache/hadoop/hive/metastore/ObjectStore.java | 7 ++++--- .../main/java/org/apache/hadoop/hive/metastore/RawStore.java | 3 ++- .../org/apache/hadoop/hive/metastore/cache/CachedStore.java | 2 +- .../hadoop/hive/metastore/DummyRawStoreControlledCommit.java | 2 +- .../hadoop/hive/metastore/DummyRawStoreForJdoConnection.java | 2 +- .../org/apache/hadoop/hive/metastore/TestObjectStore.java | 8 ++++---- 7 files changed, 14 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java ---------------------------------------------------------------------- diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java index 3c334fa..abf67a8 100644 --- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java +++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/DummyRawStoreFailEvent.java @@ -866,7 +866,7 @@ public class DummyRawStoreFailEvent implements RawStore, Configurable { } @Override - public void addNotificationEvent(NotificationEvent event) { + public void addNotificationEvent(NotificationEvent event) throws MetaException { objectStore.addNotificationEvent(event); } http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index 0d2da7a..7490243 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -9697,7 +9697,7 @@ public class ObjectStore implements RawStore, Configurable { } @Override - public void addNotificationEvent(NotificationEvent entry) { + public void addNotificationEvent(NotificationEvent entry) throws MetaException { boolean commited = false; Query query = null; try { @@ -9721,8 +9721,9 @@ public class ObjectStore implements RawStore, Configurable { } pm.makePersistent(translateThriftToDb(entry)); commited = commitTransaction(); - } catch (Exception e) { - LOG.error("couldnot get lock for update", e); + } catch (MetaException e) { + LOG.error("Couldn't get lock for update", e); + throw e; } finally { rollbackAndCleanup(commited, query); } http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java index c8905c8..d019941 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RawStore.java @@ -1195,8 +1195,9 @@ public interface RawStore extends Configurable { /** * Add a notification entry. This should only be called from inside the metastore * @param event the notification to add + * @throws MetaException error accessing RDBMS */ - void addNotificationEvent(NotificationEvent event); + void addNotificationEvent(NotificationEvent event) throws MetaException; /** * Remove older notification events. http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java index 1da9798..a526019 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java @@ -2026,7 +2026,7 @@ public class CachedStore implements RawStore, Configurable { } @Override - public void addNotificationEvent(NotificationEvent event) { + public void addNotificationEvent(NotificationEvent event) throws MetaException { rawStore.addNotificationEvent(event); } http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java index 8e195d0..c482d28 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java @@ -818,7 +818,7 @@ public class DummyRawStoreControlledCommit implements RawStore, Configurable { } @Override - public void addNotificationEvent(NotificationEvent event) { + public void addNotificationEvent(NotificationEvent event) throws MetaException { objectStore.addNotificationEvent(event); } http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java index 85eb6d5..d253005 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java @@ -823,7 +823,7 @@ public class DummyRawStoreForJdoConnection implements RawStore { } @Override - public void addNotificationEvent(NotificationEvent event) { + public void addNotificationEvent(NotificationEvent event) throws MetaException { } http://git-wip-us.apache.org/repos/asf/hive/blob/f0126912/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java index 5d5bc76..833e2bd 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java @@ -765,7 +765,7 @@ public class TestObjectStore { */ // TODO MS-SPLIT uncomment once we move EventMessage over @Test - public void testNotificationOps() throws InterruptedException { + public void testNotificationOps() throws InterruptedException, MetaException { final int NO_EVENT_ID = 0; final int FIRST_EVENT_ID = 1; final int SECOND_EVENT_ID = 2; @@ -817,7 +817,7 @@ public class TestObjectStore { + " https://db.apache.org/derby/docs/10.10/devguide/cdevconcepts842385.html" ) @Test - public void testConcurrentAddNotifications() throws ExecutionException, InterruptedException { + public void testConcurrentAddNotifications() throws ExecutionException, InterruptedException, MetaException { final int NUM_THREADS = 10; CyclicBarrier cyclicBarrier = new CyclicBarrier(NUM_THREADS, @@ -866,10 +866,10 @@ public class TestObjectStore { try { cyclicBarrier.await(); - } catch (InterruptedException | BrokenBarrierException e) { + store.addNotificationEvent(dbEvent); + } catch (InterruptedException | BrokenBarrierException | MetaException e) { throw new RuntimeException(e); } - store.addNotificationEvent(dbEvent); System.out.println("FINISH NOTIFICATION"); }); }