ashutosh-bapat commented on a change in pull request #684: HIVE-21880 : Enable 
flaky test 
TestReplicationScenariosAcidTablesBootstrap.testBootstrapAcidTablesDuringIncrementalWithConcurrentWrites.
URL: https://github.com/apache/hive/pull/684#discussion_r299064763
 
 

 ##########
 File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
 ##########
 @@ -10000,17 +10000,25 @@ private void prepareQuotes() throws SQLException {
     }
   }
 
-  private void lockForUpdate() throws MetaException {
-    String selectQuery = "select \"NEXT_EVENT_ID\" from 
\"NOTIFICATION_SEQUENCE\"";
-    String selectForUpdateQuery = sqlGenerator.addForUpdateClause(selectQuery);
-    new RetryingExecutor(conf, () -> {
-      prepareQuotes();
-      Query query = pm.newQuery("javax.jdo.query.SQL", selectForUpdateQuery);
-      query.setUnique(true);
-      // only need to execute it to get db Lock
-      query.execute();
-      query.closeAll();
-    }).run();
+  private void lockNotificationSequenceForUpdate() throws MetaException {
+    if (sqlGenerator.getDbProduct() == DatabaseProduct.DERBY && directSql != 
null) {
+      // Derby doesn't allow FOR UPDATE to lock the row being selected (See 
https://db.apache
+      // .org/derby/docs/10.1/ref/rrefsqlj31783.html) . So lock the whole 
table. Since there's
+      // only one row in the table, this shouldn't cause any performance 
degradation. Also we not
+      // suggest Derby to be used in production so that's fine.
+      directSql.lockDbTable("NOTIFICATION_SEQUENCE");
 
 Review comment:
   LOCK table is more restrictive than SELECT FOR UPDATE. E.g. LOCK table in 
exclusive mode will block any SELECTs as well, but SELECT FOR UPDATE will allow 
SELECT. So, it's better to restrict this method only to Derby where SELECT FOR 
UPDATE is not possible.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to