From 9772de368a93f8d0846a538f9026a1be5f29c6c4 Mon Sep 17 00:00:00 2001 From: Abhay Kulkarni Date: Wed, 15 Dec 2021 21:18:56 -0800 Subject: [PATCH 1/2] RANGER-3554: [Intermittent] API call to fetch the list of policies for a particular service repo returns a deleted policy in the response --- .../common/db/RangerTransactionSynchronizationAdapter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java b/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java index 6c4902b484..ed84462840 100644 --- a/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java +++ b/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java @@ -120,9 +120,10 @@ public void afterCompletion(int status) { final boolean isParentTransactionCommitted = status == STATUS_COMMITTED; + List runnablesAfterCommit = RUNNABLES_AFTER_COMMIT.get(); + RUNNABLES_AFTER_COMMIT.remove(); + if (isParentTransactionCommitted) { - List runnablesAfterCommit = RUNNABLES_AFTER_COMMIT.get(); - RUNNABLES_AFTER_COMMIT.remove(); // Run tasks scheduled to run after transaction is successfully committed runRunnables(runnablesAfterCommit, true); } From 962ca2f84e6dc270c96f29ed871106e6fd11f525 Mon Sep 17 00:00:00 2001 From: Abhay Kulkarni Date: Sat, 18 Dec 2021 14:57:18 -0800 Subject: [PATCH 2/2] RANGER-3554: [Intermittent] API call to fetch the list of policies for a particular service repo returns a deleted policy in the response - Part 2" --- .../common/db/RangerTransactionSynchronizationAdapter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java b/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java index ed84462840..0f3f311a94 100644 --- a/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java +++ b/security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java @@ -123,13 +123,14 @@ public void afterCompletion(int status) { List runnablesAfterCommit = RUNNABLES_AFTER_COMMIT.get(); RUNNABLES_AFTER_COMMIT.remove(); + List runnables = RUNNABLES.get(); + RUNNABLES.remove(); + if (isParentTransactionCommitted) { // Run tasks scheduled to run after transaction is successfully committed runRunnables(runnablesAfterCommit, true); } - List runnables = RUNNABLES.get(); - RUNNABLES.remove(); // Run other tasks scheduled to run after transaction completes runRunnables(runnables, false);