Hi, all :

 

I use phoenix 3.0 and here is what I found: 

Create a table T, then metadata cache has T

Create an index I on T, then metadata cache has I, but will trigger to
update T by following code in PMetadataImpl.addTable

{{{

      ….

if (parentTable != null) {

                List<PTable> oldIndexes = parentTable.getIndexes();

                List<PTable> newIndexes =
Lists.newArrayListWithExpectedSize(oldIndexes.size() + 1);

                newIndexes.addAll(oldIndexes);

                if (oldTable != null) {

                    newIndexes.remove(oldTable);

                }

                newIndexes.add(table);

                parentTable = PTableImpl.makePTable(parentTable,
table.getTimeStamp(), newIndexes);

                tables.put(parentTable.getKey(), parentTable);

        }

        ….

}}}

 

The method makePTable will increase T’s sequence number by 1. 

 

{{{

    public static PTableImpl makePTable(PTable table, long timeStamp,
List<PTable> indexes) throws SQLException {

        return new PTableImpl(

                table.getTenantId(), table.getSchemaName(),
table.getTableName(), table.getType(), table.getIndexState(), timeStamp, 

                table.getSequenceNumber() + 1, table.getPKName(),
table.getBucketNum(), getColumnsToClone(table), table.getParentTableName(),
indexes,

                table.isImmutableRows(), table.getPhysicalNames(),
table.getDefaultFamilyName(), table.getViewStatement(),
table.isWALDisabled(), table.isMultiTenant(), table.getViewType(),
table.getViewIndexId());

}}}

 

But during my debug the server side sequence number seem unchanged, and then
I made a “alter table T drop column”, there is a
ConcurrentMutationException thrown due to inconsistent sequence number.

I can see that the code catch the Exception and update table T with sever
side metadata, and then a retry complement the drop column operation. 

My question is why we increase the sequence number on client side in the
beginning? Which side is wrong, server or client?

 

daniel(孟庆义)

 

Reply via email to