sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [1/2] sentry git commit: SENTRY-1534: Oracle supports serializable instead of repeatable-read (Alexander Kolbasov, Reviewed by: Hao Hao)
Date Tue, 10 Jan 2017 00:11:20 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 6125ac9bd -> b34a736a6


SENTRY-1534: Oracle supports serializable instead of repeatable-read (Alexander Kolbasov,
Reviewed by: Hao Hao)

Change-Id: Id74d6e809fc0055b016b70ddb705506fee0cf8ba


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

Branch: refs/heads/sentry-ha-redesign
Commit: 5e6da0cabb968160d41425a6808bcab37b27c368
Parents: 6125ac9
Author: hahao <hao.hao@cloudera.com>
Authored: Mon Jan 9 15:20:18 2017 -0800
Committer: hahao <hao.hao@cloudera.com>
Committed: Mon Jan 9 15:20:18 2017 -0800

----------------------------------------------------------------------
 .../db/service/persistent/SentryStore.java      | 25 ++++++++++++++++++++
 .../sentry/service/thrift/ServiceConstants.java |  5 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/5e6da0ca/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index 3f3afb7..8789a48 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -145,6 +145,31 @@ public class SentryStore {
     prop.setProperty(ServerConfig.JAVAX_JDO_USER, user);
     prop.setProperty(ServerConfig.JAVAX_JDO_PASS, pass);
     prop.setProperty(ServerConfig.JAVAX_JDO_DRIVER_NAME, driverName);
+
+    /*
+     * Oracle doesn't support "repeatable-read" isolation level, so we use
+	   * "serializable" instead. This should be handled by Datanucleus, but it
+	   * incorrectly states that "repeatable-read" is supported and Oracle barks
+	   * at run-time. This code is a hack, but until it is fixed in Datanucleus
+	   * we can't do much.
+	   *
+	   * JDBC URL always looks like jdbc:oracle:<drivertype>:@<database>
+	   *  we look at the second component.
+	   *
+	   * The isolation property can be overwritten via configuration property.
+	   */
+    final String oracleDb = "oracle";
+    if (prop.getProperty(ServerConfig.DATANUCLEUS_ISOLATION_LEVEL, "").
+            equals(ServerConfig.DATANUCLEUS_REPEATABLE_READ) &&
+                    jdbcUrl.contains(oracleDb)) {
+      String parts[] = jdbcUrl.split(":");
+      if (parts.length > 1 && parts[1].equals(oracleDb)) {
+        // For Oracle JDBC driver, replace "repeatable-read" with "serializable"
+        prop.setProperty(ServerConfig.DATANUCLEUS_ISOLATION_LEVEL,
+                "serializable");
+      }
+    }
+
     for (Map.Entry<String, String> entry : conf) {
       String key = entry.getKey();
       if (key.startsWith(ServerConfig.SENTRY_JAVAX_JDO_PROPERTY_PREFIX) ||

http://git-wip-us.apache.org/repos/asf/sentry/blob/5e6da0ca/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
index c4fdf1d..139d038 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
@@ -100,6 +100,9 @@ public class ServiceConstants {
     public static final String JAVAX_JDO_PASS = "javax.jdo.option.ConnectionPassword";
     public static final String JAVAX_JDO_DRIVER_NAME = "javax.jdo.option.ConnectionDriverName";
 
+    public static final String DATANUCLEUS_ISOLATION_LEVEL = "datanucleus.transactionIsolation";
+    public static final String DATANUCLEUS_REPEATABLE_READ = "repeatable-read";
+
     public static final String SENTRY_DB_PROPERTY_PREFIX = "sentry.";
     public static final String SENTRY_JAVAX_JDO_PROPERTY_PREFIX = SENTRY_DB_PROPERTY_PREFIX
+ "javax.jdo";
     public static final String SENTRY_DATANUCLEUS_PROPERTY_PREFIX = SENTRY_DB_PROPERTY_PREFIX
+ "datanucleus";
@@ -147,7 +150,7 @@ public class ServiceConstants {
         .put("datanucleus.autoCreateSchema", "false")
         .put("datanucleus.fixedDatastore", "true")
         .put("datanucleus.autoStartMechanismMode", "checked")
-        .put("datanucleus.transactionIsolation", "repeatable-read")
+        .put(DATANUCLEUS_ISOLATION_LEVEL, DATANUCLEUS_REPEATABLE_READ)
         .put("datanucleus.cache.level2", "false")
         .put("datanucleus.cache.level2.type", "none")
         .put("datanucleus.query.sql.allowAll", "true")


Mime
View raw message