tephra-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anew <...@git.apache.org>
Subject [GitHub] incubator-tephra pull request #20: Compute global prune upper bound using co...
Date Sat, 03 Dec 2016 16:21:42 GMT
Github user anew commented on a diff in the pull request:

    --- Diff: tephra-hbase-compat-1.1-base/src/main/java/org/apache/tephra/hbase/coprocessor/janitor/HBaseTransactionPruningPlugin.java
    @@ -0,0 +1,289 @@
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.tephra.hbase.coprocessor.janitor;
    +import com.google.common.base.Function;
    +import com.google.common.collect.Iterables;
    +import com.google.common.collect.Maps;
    +import com.google.common.collect.Sets;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.HRegionInfo;
    +import org.apache.hadoop.hbase.HTableDescriptor;
    +import org.apache.hadoop.hbase.TableName;
    +import org.apache.hadoop.hbase.client.Admin;
    +import org.apache.hadoop.hbase.client.Connection;
    +import org.apache.hadoop.hbase.client.ConnectionFactory;
    +import org.apache.hadoop.hbase.client.Table;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.tephra.TxConstants;
    +import org.apache.tephra.hbase.coprocessor.TransactionProcessor;
    +import org.apache.tephra.janitor.TransactionPruningPlugin;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import java.io.IOException;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.SortedSet;
    +import java.util.TreeSet;
    + * Default implementation of the {@link TransactionPruningPlugin} for HBase.
    + *
    + * This plugin determines the prune upper bound for transactional HBase tables that use
    + * coprocessor {@link TransactionProcessor}.
    + *
    + * <h3>State storage:</h3>
    + *
    + * This plugin expects the TransactionProcessor to save the prune upper bound for invalid
    + * after every major compaction of a region. Let's call this <i>(region, prune
upper bound)</i>.
    + * In addition, the plugin also persists the following information on a run at time <i>t</i>
    + * <ul>
    + *   <li>
    + *     <i>(t, set of regions)</i>: Set of transactional regions at time <i>t</i>.
    + *     Transactional regions are regions of the tables that have the coprocessor TransactionProcessor
    + *     attached to them.
    + *   </li>
    + *   <li>
    + *     <i>(t, prune upper bound)</i>: This is the smallest not in-progress
transaction that
    + *     will not have writes in any HBase regions that are created after time <i>t</i>.
    + *     This value is determined by the Transaction Service based on the transaction state
at time <i>t</i>
    + *     and passed on to the plugin.
    + *   </li>
    + * </ul>
    + *
    + * <h3>Computing prune upper bound:</h3>
    + *
    + * In a typical HBase instance, there can be a constant change in the number of regions
due to region creations,
    + * splits and merges. At any given time there can always be a region on which a major
compaction has not been run.
    + * Since the prune upper bound will get recorded for a region only after a major compaction,
    + * using only the latest set of regions we may not be able to find the
    + * prune upper bounds for all the current regions. Hence we persist the set of regions
that exist at that time
    + * of each run of the plugin, and use historical region set for time <i>t</i>,
<i>t - 1</i>, etc.
    + * to determine the prune upper bound.
    + *
    + * From the regions saved at time <i>t</i>, <i>t - 1</i>, etc.,
    + * the plugin tries to find the latest <i>(t, set of regions)</i> where all
regions have been major compacted,
    + * i.e, all regions have prune upper bound recorded in <i>(region, prune upper
    + * <br/>
    + * If such a set is found for time <i>t1</i>, the prune upper bound returned
by the plugin is the minimum of
    + * <ul>
    + *   <li>Prune upper bounds of regions in set <i>(t1, set of regions)</i></li>
    + *   <li>Prune upper bound from <i>(t1, prune upper bound)</i></li>
    + * </ul>
    + *
    + * <p/>
    + * Above, when we find <i>(t1, set of regions)</i>, there may a region that
was created after time <i>t1</i>,
    + * but has a data write from an invalid transaction that is smaller than the prune upper
bounds of all
    + * regions in <i>(t1, set of regions)</i>. This is possible because <i>(region,
prune upper bound)</i> persisted by
    + * TransactionProcessor is always the latest prune upper bound for a region.
    + * <br/>
    + * However a region created after time <i>t1</i> cannot have writes from
an invalid transaction that is smaller than
    + * <i>min(max(invalid list), min(in-progress list) - 1)</i> at the time the
region was created.
    + * Since we limit the plugin prune upper bound using <i>(t1, prune upper bound)</i>,
there should be no invalid
    --- End diff --
    so, for t1, the prune upper bound = min(max(invalid list), min(in-progress list) - 1)
at time t1? That is the pruneUpperBoundForTime passed to fetchPruneUpperBound is the greatest
tx id for which it is guaranteed that it will never create any writes after t1? I think it
would be good to find a name for that parameter that reflects that. 

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.

View raw message