Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 280421791F for ; Tue, 3 Mar 2015 14:53:06 +0000 (UTC) Received: (qmail 16886 invoked by uid 500); 3 Mar 2015 14:53:06 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 16839 invoked by uid 500); 3 Mar 2015 14:53:05 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 16826 invoked by uid 99); 3 Mar 2015 14:53:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2015 14:53:05 +0000 Date: Tue, 3 Mar 2015 14:53:05 +0000 (UTC) From: "Ted Yu (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-13146) Race Condition in ScheduledChore and ChoreService MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-13146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14345164#comment-14345164 ] Ted Yu commented on HBASE-13146: -------------------------------- lgtm > Race Condition in ScheduledChore and ChoreService > ------------------------------------------------- > > Key: HBASE-13146 > URL: https://issues.apache.org/jira/browse/HBASE-13146 > Project: HBase > Issue Type: Bug > Components: regionserver > Affects Versions: 2.0.0, 1.1.0 > Reporter: zhangduo > Assignee: zhangduo > Fix For: 2.0.0, 1.1.0 > > Attachments: HBASE-13146.patch > > > Here is my findings when addressing HBASE-13145. > {code:title=ChoreService.java} > public synchronized boolean scheduleChore(ScheduledChore chore) { > ... > ScheduledFuture future = > scheduler.scheduleAtFixedRate(chore, chore.getInitialDelay(), chore.getPeriod(), > chore.getTimeUnit()); > chore.setChoreServicer(this); > ... > } > {code} > So we schedule the chore first, and then set chore servicer. And for CompactionChecker, the initialDelay is 0, so it is possible that the chore is run before we set chore servicer for it. And see this > {code:title=ScheduledChore.java} > public void run() { > ... > else if (stopper.isStopped() || !isScheduled()) { > cancel(false); > cleanup(); > if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " was stopped"); > } > ... > } > ... > public synchronized boolean isScheduled() { > return choreServicer != null && choreServicer.isChoreScheduled(this); > } > {code} > So it is possible that isScheduled() returns false and we start to cancel the chore. You can insert a sleep between scheduled chore and set chore servicer, then you can always get the log ' Chore: CompactionChecker was stopped'. But it does not always actually cancel the chore because the cancel method's implementation. > {code:title=ScheduledChore.java} > public synchronized void cancel(boolean mayInterruptIfRunning) { > if (isScheduled()) choreServicer.cancelChore(this, mayInterruptIfRunning); > choreServicer = null; > } > {code} > So if you insert a sleep before cancel(remember to set a larger sleep time here), then you can make the test always fail. -- This message was sent by Atlassian JIRA (v6.3.4#6332)