You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "virajjasani (via GitHub)" <gi...@apache.org> on 2025/10/06 23:16:17 UTC

[PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

virajjasani opened a new pull request, #2297:
URL: https://github.com/apache/phoenix/pull/2297

   Jira: PHOENIX-7709
   
   In case of the mutable covered index, the sequence of mutations that takes place synchronously are
   
   1. Unverified index row mutations
   2. Data table row updates
   3. Verified index row mutations
   
   Phoenix provides config "org.apache.hadoop.hbase.index.lazy.post_batch.write" to enable async or lazy mode for the last phase i.e. verified index row mutations.
   
   If the config is enabled, it uses LazyParallelWriterIndexCommitter implementation which prepares the batch of mutations per table and prepares the TaskBatch objects. However, it does not submit the mutations to the thread-pool as of today. As a result, if the lazy mode is enabled, every read on the index table will end up performing read-repair.
   
   The purpose of this Jira is to submit the post writer tasks to the respective thread-pool without getting blocked on it, to be able to make the third phase asynchronous. When the number of indexes are higher, this mode can help reduce the write latencies of the data table updates and improve the overall throughput.
   
   User can enable this mode for the given table by using DDL statements.
   
   e.g.
   - `ALTER TABLE T1 SET "org.apache.hadoop.hbase.index.lazy.post_batch.write"=true`
   - `CREATE TABLE T1 (PK1 VARCHAR NOT NULL, C1 VARCHAR) "org.apache.hadoop.hbase.index.lazy.post_batch.write"=true`


-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on PR #2297:
URL: https://github.com/apache/phoenix/pull/2297#issuecomment-3379367083

   Implementors of `AbstractParallelWriterIndexCommitter` have concurrency bug. Only `TrackingParallelWriterIndexCommitter` was submitting the tasks properly as it creates it's own copy of list of tasks to submit to the pool. Whereas other implementors were re-using the object level copy of list of tasks and therefore running into concurrency bug.
   
   Fixed with the latest commits @tkhurana @kadirozde 


-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "tkhurana (via GitHub)" <gi...@apache.org>.
tkhurana commented on code in PR #2297:
URL: https://github.com/apache/phoenix/pull/2297#discussion_r2415149393


##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/write/AbstractParallelWriterIndexCommitter.java:
##########
@@ -128,7 +149,6 @@ public void write(Multimap<HTableInterfaceReference, Mutation> toWrite,
      */
 
     Set<Entry<HTableInterfaceReference, Collection<Mutation>>> entries = toWrite.asMap().entrySet();
-    tasks = new TaskBatch<Void>(entries.size());

Review Comment:
   Another option could have been to create a new local tasks object and introduce a new abstract API on the AbstractParallelWriterIndexCommiter submitTasks(tasks) which the two derived classes ParallelWriter and LazyParallelWriter can implement since that is where there is a difference.



##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/write/LazyParallelWriterIndexCommitter.java:
##########
@@ -17,17 +17,40 @@
  */
 package org.apache.phoenix.hbase.index.write;
 
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.phoenix.hbase.index.exception.SingleIndexWriteFailureException;
+import org.apache.phoenix.hbase.index.parallel.TaskBatch;
+import org.apache.phoenix.hbase.index.table.HTableInterfaceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.phoenix.thirdparty.com.google.common.collect.Multimap;
+
 /**
  * Like the {@link ParallelWriterIndexCommitter}, but does not block
  */
 public class LazyParallelWriterIndexCommitter extends AbstractParallelWriterIndexCommitter {
 
-  // for testing
-  public LazyParallelWriterIndexCommitter(String hbaseVersion) {
-    super(hbaseVersion);
-  }
+  private static final Logger LOGGER =
+    LoggerFactory.getLogger(LazyParallelWriterIndexCommitter.class);
 
   public LazyParallelWriterIndexCommitter() {
     super();
   }
+
+  @Override
+  public void write(Multimap<HTableInterfaceReference, Mutation> toWrite,
+    final boolean allowLocalUpdates, final int clientVersion)
+    throws SingleIndexWriteFailureException {
+
+    TaskBatch<Void> tasks = new TaskBatch<>(toWrite.asMap().size());
+    super.addTasks(toWrite, allowLocalUpdates, clientVersion, tasks);
+    try {
+      pool.submitOnly(tasks);
+    } catch (Exception e) {
+      LOGGER.error("Error while submitting the task.", e);
+      propagateFailure(e.getCause());
+    }

Review Comment:
   Basically move this logic into an abstract submitTasks(tasks) method with the derived classes implementing it differently. 



-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "tkhurana (via GitHub)" <gi...@apache.org>.
tkhurana commented on PR #2297:
URL: https://github.com/apache/phoenix/pull/2297#issuecomment-3376666694

   Looks good. Can you add some tests which do concurrent modifications with lazy updates.


-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani merged PR #2297:
URL: https://github.com/apache/phoenix/pull/2297


-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on PR #2297:
URL: https://github.com/apache/phoenix/pull/2297#issuecomment-3383501617

   How about the recent commit?


-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "tkhurana (via GitHub)" <gi...@apache.org>.
tkhurana commented on code in PR #2297:
URL: https://github.com/apache/phoenix/pull/2297#discussion_r2415288960


##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/write/AbstractParallelWriterIndexCommitter.java:
##########
@@ -116,6 +115,40 @@ public void setup(HTableFactory factory, ExecutorService pool, Stoppable stop,
   public void write(Multimap<HTableInterfaceReference, Mutation> toWrite,
     final boolean allowLocalUpdates, final int clientVersion)
     throws SingleIndexWriteFailureException {
+    TaskBatch<Void> tasks = new TaskBatch<>(toWrite.asMap().size());
+    addTasks(toWrite, allowLocalUpdates, clientVersion, tasks);
+    submitTasks(tasks);
+  }
+
+  /**
+   * Submits the provided task batch for execution. This method defines the task submission strategy
+   * and must be implemented by concrete subclasses to specify whether tasks should be executed
+   * synchronously (blocking until completion) or asynchronously (fire-and-forget).
+   * @param tasks the batch of index write tasks to submit for execution
+   * @throws SingleIndexWriteFailureException if there is an error during task submission or
+   *                                          execution (implementation-dependent)
+   */
+  protected abstract void submitTasks(TaskBatch<Void> tasks)
+    throws SingleIndexWriteFailureException;
+
+  /**
+   * Adds parallel index write tasks to the provided task batch for execution across multiple index
+   * tables. Each index table gets its own task that will be executed in parallel to optimize write
+   * performance. It is recommended that implementations of AbstractParallelWriterIndexCommitter
+   * class use this method rather than calling super.write() to use their own copy of tasks.

Review Comment:
   Looks good overall. Just a minor nit to fix this comment. Other than that looks great.



-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PHOENIX-7709 Index committer post writer lazy mode - Async RPC call for verified index mutations [phoenix]

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on code in PR #2297:
URL: https://github.com/apache/phoenix/pull/2297#discussion_r2415202176


##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/write/AbstractParallelWriterIndexCommitter.java:
##########
@@ -128,7 +149,6 @@ public void write(Multimap<HTableInterfaceReference, Mutation> toWrite,
      */
 
     Set<Entry<HTableInterfaceReference, Collection<Mutation>>> entries = toWrite.asMap().entrySet();
-    tasks = new TaskBatch<Void>(entries.size());

Review Comment:
   `addTasks()` gives the same abstraction but having submitTasks() might make it tricky to debug because writers already implement `write()`.
   
   But let me enforce that child classes must implement write() by making `write()` abstract



-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org