diff --git a/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql b/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql index b0bc5b1..3c20d1e 100644 --- a/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql +++ b/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql @@ -6,7 +6,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql b/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql index 2033bdc..fb52434 100644 --- a/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql +++ b/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql @@ -62,7 +62,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java index d9a5feb..efc0cfe 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hive.common.JavaUtils; +import org.apache.hadoop.hive.common.ValidWriteIdList; import org.apache.hadoop.hive.metastore.MetastoreTaskThread; import org.apache.hadoop.hive.metastore.api.AddDynamicPartitions; import org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsRequest; @@ -2335,4 +2336,86 @@ public void testFairness2() throws Exception { checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "T7", "p=2", locks); } + + @Test + public void testValidWriteIdListSnapshot() throws Exception { + // Create a transactional table + dropTable(new String[] {"temp.T7"}); + CommandProcessorResponse cpr = driver.run("create database if not exists temp"); + checkCmdOnDriver(cpr); + cpr = driver.run("create table if not exists temp.T7(a int, b int) clustered by(b) into 2 buckets stored as orc " + + "TBLPROPERTIES ('transactional'='true')"); + checkCmdOnDriver(cpr); + + // Open a base txn which allocates write ID and then committed. + long baseTxnId = txnMgr.openTxn(ctx, "u0"); + long baseWriteId = txnMgr.getTableWriteId("temp", "T7"); + Assert.assertEquals(1, baseWriteId); + txnMgr.commitTxn(); // committed baseTxnId + + // Open a txn with no writes. + HiveTxnManager txnMgr1 = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); + long underHwmOpenTxnId = txnMgr1.openTxn(ctx, "u1"); + Assert.assertTrue("Invalid txn ID", underHwmOpenTxnId > baseTxnId); + + // Open a txn to be tested for ValidWriteIdList. Get the ValidTxnList during open itself. + // Verify the ValidWriteIdList with no open/aborted write txns on this table. + // Write ID of committed txn should be valid. + HiveTxnManager txnMgr2 = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); + long testTxnId = txnMgr2.openTxn(ctx, "u2"); + Assert.assertTrue("Invalid txn ID", testTxnId > underHwmOpenTxnId); + String testValidTxns = txnMgr2.getValidTxns().toString(); + ValidWriteIdList testValidWriteIds = txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns) + .getTableValidWriteIdList("temp.t7"); + Assert.assertEquals(baseWriteId, testValidWriteIds.getHighWatermark()); + Assert.assertTrue("Invalid write ID list", testValidWriteIds.isWriteIdValid(baseWriteId)); + + // Open a txn which allocate write ID and remain open state. + HiveTxnManager txnMgr3 = TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf); + long aboveHwmOpenTxnId = txnMgr3.openTxn(ctx, "u3"); + Assert.assertTrue("Invalid txn ID", aboveHwmOpenTxnId > testTxnId); + long aboveHwmOpenWriteId = txnMgr3.getTableWriteId("temp", "T7"); + Assert.assertEquals(2, aboveHwmOpenWriteId); + + // Allocate writeId to txn under HWM. This will get Id greater than a txn > HWM. + long underHwmOpenWriteId = txnMgr1.getTableWriteId("temp", "T7"); + Assert.assertEquals(3, underHwmOpenWriteId); + + // Verify the ValidWriteIdList with one open txn on this table. Write ID of open txn should be invalid. + testValidWriteIds = txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns) + .getTableValidWriteIdList("temp.t7"); + Assert.assertEquals(underHwmOpenWriteId, testValidWriteIds.getHighWatermark()); + Assert.assertTrue("Invalid write ID list", testValidWriteIds.isWriteIdValid(baseWriteId)); + Assert.assertFalse("Invalid write ID list", testValidWriteIds.isWriteIdValid(underHwmOpenWriteId)); + Assert.assertFalse("Invalid write ID list", testValidWriteIds.isWriteIdValid(aboveHwmOpenWriteId)); + + // Commit the txn under HWM. + // Verify the writeId of this committed txn should be invalid for test txn. + txnMgr1.commitTxn(); + testValidWriteIds = txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns) + .getTableValidWriteIdList("temp.t7"); + Assert.assertEquals(underHwmOpenWriteId, testValidWriteIds.getHighWatermark()); + Assert.assertTrue("Invalid write ID list", testValidWriteIds.isWriteIdValid(baseWriteId)); + Assert.assertFalse("Invalid write ID list", testValidWriteIds.isWriteIdValid(underHwmOpenWriteId)); + Assert.assertFalse("Invalid write ID list", testValidWriteIds.isWriteIdValid(aboveHwmOpenWriteId)); + + // Allocate writeId from test txn and then verify ValidWriteIdList. + // Write Ids of committed and self test txn should be valid but writeId of open txn should be invalid. + // WriteId of recently committed txn which was open when get ValidTxnList snapshot should be invalid as well. + long testWriteId = txnMgr2.getTableWriteId("temp", "T7"); + Assert.assertEquals(4, testWriteId); + + testValidWriteIds = txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns) + .getTableValidWriteIdList("temp.t7"); + Assert.assertEquals(testWriteId, testValidWriteIds.getHighWatermark()); + Assert.assertTrue("Invalid write ID list", testValidWriteIds.isWriteIdValid(baseWriteId)); + Assert.assertTrue("Invalid write ID list", testValidWriteIds.isWriteIdValid(testWriteId)); + Assert.assertFalse("Invalid write ID list", testValidWriteIds.isWriteIdValid(underHwmOpenWriteId)); + Assert.assertFalse("Invalid write ID list", testValidWriteIds.isWriteIdValid(aboveHwmOpenWriteId)); + txnMgr2.commitTxn(); + txnMgr3.commitTxn(); + + cpr = driver.run("drop database if exists temp cascade"); + checkCmdOnDriver(cpr); + } } diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index 6a74594..cb5b853 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -932,40 +932,54 @@ private TableValidWriteIds getValidWriteIdsForTable(Statement stmt, String fullT String[] names = TxnUtils.getDbTableName(fullTableName); try { // Need to initialize to 0 to make sure if nobody modified this table, then current txn - // shouldn't read any data + // shouldn't read any data. + // If there is a conversion from non-acid to acid table, then by default 0 would be assigned as + // writeId for data from non-acid table and so writeIdHwm=0 would ensure those data are readable by any txns. long writeIdHwm = 0; List invalidWriteIdList = new ArrayList<>(); + long minOpenWriteId = Long.MAX_VALUE; + BitSet abortedBits = new BitSet(); long txnHwm = validTxnList.getHighWatermark(); - // The output includes all the txns which are under the high water mark. It includes - // the committed transactions as well. The results should be sorted in ascending order based - // on write id. The sorting is needed as exceptions list in ValidWriteIdList would be looked-up - // using binary search. - String s = "select t2w_txnid, t2w_writeid from TXN_TO_WRITE_ID where t2w_txnid <= " + txnHwm + // Find the writeId high water mark based upon txnId high water mark. If found, then, need to + // traverse through all write Ids less than writeId HWM to make exceptions list. + String s = "select max(t2w_writeid) from TXN_TO_WRITE_ID where t2w_txnid <= " + txnHwm + " and t2w_database = " + quoteString(names[0]) - + " and t2w_table = " + quoteString(names[1]) - + " order by t2w_writeid asc"; + + " and t2w_table = " + quoteString(names[1]); LOG.debug("Going to execute query<" + s + ">"); rs = stmt.executeQuery(s); - long minOpenWriteId = Long.MAX_VALUE; - BitSet abortedBits = new BitSet(); - while (rs.next()) { - long txnId = rs.getLong(1); - long writeId = rs.getLong(2); - writeIdHwm = Math.max(writeIdHwm, writeId); - if (validTxnList.isTxnValid(txnId)) { - // Skip if the transaction under evaluation is already committed. - continue; - } + if (rs.next()) { + writeIdHwm = rs.getLong(1); + + // As writeIdHwm is known, query all writeIds under the writeId HWM. + // If any writeId under HWM is allocated by txn > txnId HWM, then will be added to invalid list. + // The output of this query includes all the txns which are under the high water mark. It includes + // the committed transactions as well. The results should be sorted in ascending order based + // on write id. The sorting is needed as exceptions list in ValidWriteIdList would be looked-up + // using binary search. + s = "select t2w_txnid, t2w_writeid from TXN_TO_WRITE_ID where t2w_writeid <= " + writeIdHwm + + " and t2w_database = " + quoteString(names[0]) + + " and t2w_table = " + quoteString(names[1]) + + " order by t2w_writeid asc"; - // The current txn is either in open or aborted state. - // Mark the write ids state as per the txn state. - if (validTxnList.isTxnAborted(txnId)) { - invalidWriteIdList.add(writeId); - abortedBits.set(invalidWriteIdList.size() - 1); - } else { + LOG.debug("Going to execute query<" + s + ">"); + rs = stmt.executeQuery(s); + while (rs.next()) { + long txnId = rs.getLong(1); + long writeId = rs.getLong(2); + if (validTxnList.isTxnValid(txnId)) { + // Skip if the transaction under evaluation is already committed. + continue; + } + + // The current txn is either in open or aborted state. + // Mark the write ids state as per the txn state. invalidWriteIdList.add(writeId); - minOpenWriteId = Math.min(minOpenWriteId, writeId); + if (validTxnList.isTxnAborted(txnId)) { + abortedBits.set(invalidWriteIdList.size() - 1); + } else { + minOpenWriteId = Math.min(minOpenWriteId, writeId); + } } } diff --git a/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql b/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql index 86ef6b1..b0cdd1a 100644 --- a/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql +++ b/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql @@ -534,7 +534,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql b/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql index 1fc34bc..150dc87 100644 --- a/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql +++ b/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql @@ -103,7 +103,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql b/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql index e0bb25b..25a9684 100644 --- a/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql +++ b/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql @@ -1139,7 +1139,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE nvarchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql b/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql index 52107b3..59e978c 100644 --- a/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql +++ b/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql @@ -157,7 +157,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE nvarchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql b/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql index 566badf..0213495 100644 --- a/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql +++ b/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql @@ -1074,7 +1074,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql b/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql index 35f08dc..4e53831 100644 --- a/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql +++ b/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql @@ -142,7 +142,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql b/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql index 82811ee..e702562 100644 --- a/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql +++ b/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql @@ -1047,7 +1047,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID number(19) NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql b/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql index edf14d9..4131d06 100644 --- a/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql +++ b/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql @@ -166,7 +166,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID number(19) NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql b/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql index 543a358..cd2a807 100644 --- a/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql +++ b/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql @@ -1739,7 +1739,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL, diff --git a/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql b/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql index ed4ce22..b468f64 100644 --- a/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql +++ b/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql @@ -181,7 +181,8 @@ CREATE TABLE TXN_TO_WRITE_ID ( T2W_WRITEID bigint NOT NULL ); -CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID); +CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_WRITEID); CREATE TABLE NEXT_WRITE_ID ( NWI_DATABASE varchar(128) NOT NULL,