phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas D'Silva (JIRA)" <>
Subject [jira] [Created] (PHOENIX-3986) UngroupedAggregateRegionObserver.commitBatch() should set the index metadata as an attribute on every mutation
Date Fri, 30 Jun 2017 21:51:00 GMT
Thomas D'Silva created PHOENIX-3986:

             Summary: UngroupedAggregateRegionObserver.commitBatch() should set the index
metadata as an attribute on every mutation
                 Key: PHOENIX-3986
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 4.9.0
            Reporter: Thomas D'Silva
            Assignee: Thomas D'Silva
             Fix For: 4.12.0, 4.11.1

We are seeing "unable to find cached index metadata" exceptions  in production while running
UPSERT SELECT queries on a table that has mutable indexes. These exceptions should not happen
because PHOENIX-2935 changed the code to set the index metadata as an attribute. 

ERROR 2008 (INT10): ERROR 2008 (INT10): Unable to find cached index metadata.  key={} region={}.host={}
Index update failed
 		at org.apache.phoenix.util.ServerUtil.createIOException(
 		at org.apache.phoenix.util.ServerUtil.throwIOException(
 		at org.apache.phoenix.index.PhoenixIndexMetaData.getIndexMetaData(
 		at org.apache.phoenix.index.PhoenixIndexMetaData.<init>(
 		at org.apache.phoenix.index.PhoenixIndexBuilder.getIndexMetaData(
 		at org.apache.phoenix.hbase.index.builder.IndexBuildManager.getIndexUpdate(
 		at org.apache.phoenix.hbase.index.Indexer.preBatchMutateWithExceptions(
 		at org.apache.phoenix.hbase.index.Indexer.preBatchMutate(
 		at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost$
 		at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost$
 		at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.execOperation(
 		at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.execOperation(
 		at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.preBatchMutate(
 		at org.apache.hadoop.hbase.regionserver.HRegion.doMiniBatchMutation(
 		at org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(
 		at org.apache.hadoop.hbase.regionserver.HRegion.batchMutate(
 		at org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver.commitBatch(
 		at org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver.commit(
 		at org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver.doPostScannerOpen(
 		at org.apache.phoenix.coprocessor.BaseScannerRegionObserver$RegionScannerHolder.overrideDelegate(
 		at org.apache.phoenix.coprocessor.BaseScannerRegionObserver$RegionScannerHolder.nextRaw(
 		at org.apache.hadoop.hbase.regionserver.HRegionServer.scan(
 		at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$2.callBlockingMethod(
 		at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(
 		at org.apache.hadoop.hbase.ipc.RpcExecutor$

This is what I think is happening : 
In UngroupedAggregateRegionObserver.doPostScannerOpen we commit batches of mutations. 
In commitBatch() since the mutations are for the same region we only set the index maintainer
as an attribute on the first mutation of the batch. We then call HRegion.batchMutate() which
ends up calling HRegion.doMiniBatchMutation() in a loop. 
doMiniBatchMutation()  loops throught the mutations one at a time and tries to acquire the
each mutation's lock. If it cannot acquire a lock it processes the mutations for which it
has acquired locks so far and then calls coprocessorHost.preBatchMutate which eventually ends
up calling PhoenixIndexBuilder.getIndexMetaData() which set the index metadata using the attribute
map of the first mutation in the mini batch. 
It then processes the next set of mutations for which it has acquired locks. The index metadata
is not set as an attribute for this next mini batch, so we try and look it up in the cache
which fails 

In PhoenixIndexBuilder
    public IndexMetaData getIndexMetaData(MiniBatchOperationInProgress<Mutation> miniBatchOp)
throws IOException {
        return new PhoenixIndexMetaData(env, miniBatchOp.getOperation(0).getAttributesMap());
In MiniBatchOperationInProgress


   * @param index
   * @return The operation(Mutation) at the specified position.
  public T getOperation(int index) {
    return operations[getAbsoluteIndex(index)];

private int getAbsoluteIndex(int index) {
    if (index < 0 || this.firstIndex + index >= this.lastIndexExclusive) {
      throw new ArrayIndexOutOfBoundsException(index);
    return this.firstIndex + index;

[~ankit.singhal] [~jamestaylor] Does this make sense?

This message was sent by Atlassian JIRA

View raw message