phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: Tighten check for transaction provider
Date Sat, 16 Jun 2018 10:18:23 GMT
Repository: phoenix
Updated Branches:
  refs/heads/omid2 e9842bcd2 -> 851b1266d


Tighten check for transaction provider


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/851b1266
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/851b1266
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/851b1266

Branch: refs/heads/omid2
Commit: 851b1266d285c8c9bf58965ca941300dee678f2d
Parents: e9842bc
Author: James Taylor <jamestaylor@apache.org>
Authored: Sat Jun 16 12:18:11 2018 +0200
Committer: James Taylor <jamestaylor@apache.org>
Committed: Sat Jun 16 12:18:11 2018 +0200

----------------------------------------------------------------------
 .../phoenix/end2end/index/MutableIndexIT.java   |  8 +++----
 .../phoenix/exception/SQLExceptionCode.java     |  1 +
 .../query/ConnectionQueryServicesImpl.java      | 25 +++++++++++++++-----
 pom.xml                                         |  2 +-
 4 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/851b1266/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
index 4dbb7d3..85afd66 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
@@ -108,14 +108,14 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     
 	@Parameters(name="MutableIndexIT_localIndex={0},transactionProvider={1},columnEncoded={2}")
// name is used by failsafe as file name in reports
     public static Collection<Object[]> data() {
-        return Arrays.asList(new Object[][] { 
+        return TestUtil.filterTxParamData(Arrays.asList(new Object[][] { 
                 { false, null, false }, { false, null, true },
                 { false, "TEPHRA", false }, { false, "TEPHRA", true },
-                { false, "OMID", false }, { false, "OMID", true },
+                { false, "OMID", false },
                 { true, null, false }, { true, null, true },
                 { true, "TEPHRA", false }, { true, "TEPHRA", true },
-                { true, "OMID", false }, { true, "OMID", true },
-                });
+                { true, "OMID", false },
+                }),1);
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/phoenix/blob/851b1266/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index 767385a..6a384c6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -300,6 +300,7 @@ public enum SQLExceptionCode {
     CANNOT_ALTER_TABLE_FROM_NON_TXN_TO_TXNL(1093, "44A24", "Cannot alter table from non transactional
to transactional for"),
     UNSUPPORTED_COLUMN_ENCODING_FOR_TXN_PROVIDER(1094, "44A25", "Column encoding is not supported
for"),
     UNSUPPORTED_STORAGE_FORMAT_FOR_TXN_PROVIDER(1095, "44A26", "Only ONE_CELL_PER_COLUMN
storage scheme is supported for"),
+    CANNOT_SWITCH_TXN_PROVIDERS(1096, "44A27", "Cannot switch transaction providers."),
 
     /** Sequence related */
     SEQUENCE_ALREADY_EXIST(1200, "42Z00", "Sequence already exists.", new Factory() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/851b1266/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index cc0ead0..1cc9108 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1180,13 +1180,21 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
                 // If mapping an existing table as transactional, set property so that existing
                 // data is correctly read.
                 if (willBeTx) {
-                    if (provider.getTransactionProvider().isUnsupported(PhoenixTransactionProvider.Feature.ALTER_NONTX_TO_TX))
{
-                        throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_ALTER_TABLE_FROM_NON_TXN_TO_TXNL)
-                        .setMessage(provider.name())
-                        .setSchemaName(SchemaUtil.getSchemaNameFromFullName(physicalTableName))
-                        .setTableName(SchemaUtil.getTableNameFromFullName(physicalTableName)).build().buildException();
+                    if (!equalTxCoprocessor(provider, existingDesc, newDesc)) {
+                        // Cannot switch between different providers
+                        if (hasTxCoprocessor(existingDesc)) {
+                            throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_SWITCH_TXN_PROVIDERS)
+                            .setSchemaName(SchemaUtil.getSchemaNameFromFullName(physicalTableName))
+                            .setTableName(SchemaUtil.getTableNameFromFullName(physicalTableName)).build().buildException();
+                        }
+                        if (provider.getTransactionProvider().isUnsupported(PhoenixTransactionProvider.Feature.ALTER_NONTX_TO_TX))
{
+                            throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_ALTER_TABLE_FROM_NON_TXN_TO_TXNL)
+                            .setMessage(provider.name())
+                            .setSchemaName(SchemaUtil.getSchemaNameFromFullName(physicalTableName))
+                            .setTableName(SchemaUtil.getTableNameFromFullName(physicalTableName)).build().buildException();
+                        }
+                        newDesc.setValue(PhoenixTransactionContext.READ_NON_TX_DATA, Boolean.TRUE.toString());
                     }
-                    newDesc.setValue(PhoenixTransactionContext.READ_NON_TX_DATA, Boolean.TRUE.toString());
                 } else {
                     // If we think we're creating a non transactional table when it's already
                     // transactional, don't allow.
@@ -1234,6 +1242,11 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
         return false;
     }
 
+    private static boolean equalTxCoprocessor(TransactionFactory.Provider provider, HTableDescriptor
existingDesc, HTableDescriptor newDesc) {
+        Class<? extends RegionObserver> coprocessorClass = provider.getTransactionProvider().getCoprocessor();
+        return (coprocessorClass != null && existingDesc.hasCoprocessor(coprocessorClass.getName())
&& newDesc.hasCoprocessor(coprocessorClass.getName()));
+}
+
     private void modifyTable(byte[] tableName, HTableDescriptor newDesc, boolean shouldPoll)
throws IOException,
     InterruptedException, TimeoutException, SQLException {
         try (HBaseAdmin admin = getAdmin()) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/851b1266/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3e3511a..14dd94f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -122,7 +122,7 @@
     <maven.assembly.version>2.5.2</maven.assembly.version>
 
     <!-- Plugin options -->
-    <numForkedUT>8</numForkedUT>
+    <numForkedUT>4</numForkedUT>
     <numForkedIT>4</numForkedIT>
     <it.failIfNoSpecifiedTests>false</it.failIfNoSpecifiedTests>
     <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests>


Mime
View raw message