[ https://issues.apache.org/jira/browse/HIVE-24946?focusedWorklogId=632166&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-632166 ]
ASF GitHub Bot logged work on HIVE-24946: ----------------------------------------- Author: ASF GitHub Bot Created on: 02/Aug/21 06:48 Start Date: 02/Aug/21 06:48 Worklog Time Spent: 10m Work Description: pkumarsinha commented on a change in pull request #2529: URL: https://github.com/apache/hive/pull/2529#discussion_r680692744 ########## File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java ########## @@ -723,6 +734,75 @@ public void testFailoverFailureInReverseReplication() throws Throwable { assertTrue(fs.exists(new Path(dumpPath, LOAD_ACKNOWLEDGEMENT.toString()))); } + @Test + public void testFailoverFailoverAndRollback() throws Throwable { Review comment: typo in name? ########## File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java ########## @@ -723,6 +734,75 @@ public void testFailoverFailureInReverseReplication() throws Throwable { assertTrue(fs.exists(new Path(dumpPath, LOAD_ACKNOWLEDGEMENT.toString()))); } + @Test + public void testFailoverFailoverAndRollback() throws Throwable { + List<String> failoverConfigs = Arrays.asList("'" + HiveConf.ConfVars.HIVE_REPL_FAILOVER_START + "'='true'", + "'" + HiveConf.ConfVars.REPL_RETAIN_PREV_DUMP_DIR + "'='true'", + "'" + HiveConf.ConfVars.REPL_RETAIN_PREV_DUMP_DIR_COUNT + "'='1'"); + WarehouseInstance.Tuple dumpData = primary.run("use " + primaryDbName) + .run("create table t1 (id int) clustered by(id) into 3 buckets stored as orc " + + "tblproperties (\"transactional\"=\"true\")") + .run("create table t2 (rank int) partitioned by (name string) tblproperties(\"transactional\"=\"true\", " + + "\"transactional_properties\"=\"insert_only\")") + .dump(primaryDbName, failoverConfigs); + + //This dump is not failover ready as target db can be used for replication only after first incremental load. + FileSystem fs = new Path(dumpData.dumpLocation).getFileSystem(conf); + Path dumpPath = new Path(dumpData.dumpLocation, ReplUtils.REPL_HIVE_BASE_DIR); + assertFalse(fs.exists(new Path(dumpPath, FailoverMetaData.FAILOVER_METADATA))); + assertFalse(fs.exists(new Path(dumpPath, ReplAck.FAILOVER_READY_MARKER.toString()))); + assertFalse(MetaStoreUtils.isDbBeingFailedOver(primary.getDatabase(primaryDbName))); + + replica.load(replicatedDbName, primaryDbName) + .run("use " + replicatedDbName) + .run("show tables") + .verifyResults(new String[]{"t1", "t2"}) + .run("repl status " + replicatedDbName) + .verifyResult(dumpData.lastReplicationId); + + assertTrue(MetaStoreUtils.isTargetOfReplication(replica.getDatabase(replicatedDbName))); + dumpData = primary.run("use " + primaryDbName) + .run("insert into t1 values(1)") + .run("insert into t2 partition(name='Bob') values(11)") + .dump(primaryDbName, failoverConfigs); + + dumpPath = new Path(dumpData.dumpLocation, ReplUtils.REPL_HIVE_BASE_DIR); + Path dumpAckFile = new Path(dumpPath, DUMP_ACKNOWLEDGEMENT.toString()); + assertTrue(fs.exists(dumpAckFile)); + assertTrue(fs.exists(new Path(dumpPath, FailoverMetaData.FAILOVER_METADATA))); + assertTrue(fs.exists(new Path(dumpPath, ReplAck.FAILOVER_READY_MARKER.toString()))); + assertTrue(MetaStoreUtils.isDbBeingFailedOverAtEndpoint(primary.getDatabase(primaryDbName), + MetaStoreUtils.FailoverEndpoint.SOURCE)); + + fs.delete(dumpAckFile, false); + + dumpData = primary.run("use " + primaryDbName) + .run("insert into t2 partition(name='Carl') values(10)") + .run("create table t3 (id int)") + .run("insert into t3 values (2)") + .dump(primaryDbName); + + dumpPath = new Path(dumpData.dumpLocation, ReplUtils.REPL_HIVE_BASE_DIR); + assertTrue(fs.exists(new Path(dumpPath, FailoverMetaData.FAILOVER_METADATA))); + assertFalse(fs.exists(new Path(dumpPath, ReplAck.FAILOVER_READY_MARKER.toString()))); + assertTrue(fs.exists(new Path(dumpPath, DUMP_ACKNOWLEDGEMENT.toString()))); + assertFalse(MetaStoreUtils.isDbBeingFailedOver(primary.getDatabase(primaryDbName))); + + replica.load(replicatedDbName, primaryDbName) + .run("use " + replicatedDbName) + .run("show tables") + .verifyResults(new String[]{"t1", "t2", "t3"}) + .run("repl status " + replicatedDbName) + .verifyResult(dumpData.lastReplicationId) + .run("select id from t1") + .verifyResults(new String[]{"1"}) + .run("select rank from t2 order by rank") + .verifyResults(new String[]{"11", "10"}) + .run("select id from t3") + .verifyResults(new String[]{"2"}); + assertTrue(fs.exists(new Path(dumpPath, LOAD_ACKNOWLEDGEMENT.toString()))); Review comment: assert for isDbBeingFailedOver -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 632166) Time Spent: 2h 50m (was: 2h 40m) > Handle failover case during Repl Load > ------------------------------------- > > Key: HIVE-24946 > URL: https://issues.apache.org/jira/browse/HIVE-24946 > Project: Hive > Issue Type: New Feature > Reporter: Haymant Mangla > Assignee: Haymant Mangla > Priority: Major > Labels: pull-request-available > Time Spent: 2h 50m > Remaining Estimate: 0h > > To handle: > # Introduce two states of failover db property to denote nature of database > at the time failover was initiated. > # If failover start config is enabled and dump directory contains failover > marker file, then in incremental load as a preAckTask, we should > ## Remove repl.target.for from target db. > ## Set repl.failover.endpoint = "TARGET" > ## Updated the replication metrics saying that target cluster is failover > ready > # In the first dump operation in reverse direction, presence of failover > ready marker and repl.failover.endpoint = "TARGET" will be used as indicator > for bootstrap iteration. > # In any dump operation except the first dump operation in reverse dxn, if > repl.failover.endpoint is set for db and failover start config is set to > false, then remove this property. > # In incremental load, if the failover start config is disabled, then add > repl.target.for and remove repl.failover.endpoint if present. -- This message was sent by Atlassian Jira (v8.3.4#803005)