tephra-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TEPHRA-212) CompactionState #savePruneUpperBoundForRegion put call might because problems if regions are not available
Date Tue, 31 Jan 2017 22:28:52 GMT

    [ https://issues.apache.org/jira/browse/TEPHRA-212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15847647#comment-15847647
] 

ASF GitHub Bot commented on TEPHRA-212:
---------------------------------------

Github user poornachandra commented on a diff in the pull request:

    https://github.com/apache/incubator-tephra/pull/29#discussion_r98786621
  
    --- Diff: tephra-hbase-compat-1.1-base/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
---
    @@ -0,0 +1,104 @@
    +/*
    + * 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 "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.tephra.hbase.txprune;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.tephra.hbase.coprocessor.TransactionProcessor;
    +
    +import java.io.IOException;
    +import java.util.concurrent.TimeUnit;
    +import java.util.concurrent.atomic.AtomicBoolean;
    +import java.util.concurrent.atomic.AtomicLong;
    +
    +/**
    + * Thread that will write the the prune upper bound
    + */
    +public class PruneUpperBoundWriter {
    +  private static final Log LOG = LogFactory.getLog(TransactionProcessor.class);
    +
    +  private final DataJanitorState dataJanitorState;
    +  private final byte[] regionName;
    +  private final long pruneFlushInterval;
    +  private final AtomicLong pruneUpperBound;
    +  private final AtomicBoolean shouldFlush;
    +
    +  private Thread flushThread;
    +  private long lastChecked;
    +
    +  public PruneUpperBoundWriter(DataJanitorState dataJanitorState, byte[] regionName,
long pruneFlushInterval) {
    +    this.dataJanitorState = dataJanitorState;
    +    this.regionName = regionName;
    +    this.pruneFlushInterval = pruneFlushInterval;
    +    this.pruneUpperBound = new AtomicLong();
    +    this.shouldFlush = new AtomicBoolean(false);
    +    startFlushThread();
    +  }
    +
    +  public boolean isAlive() {
    +    return flushThread.isAlive();
    +  }
    +
    +  public void persistPruneEntry(long pruneUpperBound) {
    +    this.pruneUpperBound.set(pruneUpperBound);
    +    this.shouldFlush.set(true);
    +  }
    +
    +  public void stop() {
    +    if (flushThread != null) {
    +      flushThread.interrupt();
    +    }
    +  }
    +
    +  private void startFlushThread() {
    +    flushThread = new Thread("tephra-prune-upper-bound-writer") {
    +      @Override
    +      public void run() {
    +        while (!isInterrupted()) {
    +          long now = System.currentTimeMillis();
    +          if (now > (lastChecked + pruneFlushInterval)) {
    +            if (shouldFlush.compareAndSet(true, false)) {
    +              // should flush data
    +              try {
    +                dataJanitorState.savePruneUpperBoundForRegion(regionName, pruneUpperBound.get());
    +              } catch (IOException ex) {
    +                LOG.warn("Cannot record prune upper bound in table after compacting region
" + ex.getMessage());
    --- End diff --
    
    Also it would be good to have the region name and the state table name in the exception
message.


> CompactionState #savePruneUpperBoundForRegion put call might because problems if regions
are not available
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: TEPHRA-212
>                 URL: https://issues.apache.org/jira/browse/TEPHRA-212
>             Project: Tephra
>          Issue Type: Bug
>    Affects Versions: 0.11.0-incubating
>            Reporter: Gokul Gunasekaran
>            Assignee: Gokul Gunasekaran
>             Fix For: 0.11.0-incubating
>
>
> If the regions corresponding to prune state table are not available, trying to do a put
to that table might cause multiple retries etc and might cause issues. Instead of doing this
write in a synchronous fashion, this should be done asynchronously.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message