Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 75E431665D1 for ; Tue, 25 Jul 2017 11:04:44 +0200 (CEST) Received: (qmail 83664 invoked by uid 500); 25 Jul 2017 09:04:43 -0000 Mailing-List: contact commits-help@bookkeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bookkeeper-dev@bookkeeper.apache.org Delivered-To: mailing list commits@bookkeeper.apache.org Received: (qmail 83655 invoked by uid 99); 25 Jul 2017 09:04:43 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jul 2017 09:04:43 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 1FF6581575; Tue, 25 Jul 2017 09:04:41 +0000 (UTC) Date: Tue, 25 Jul 2017 09:04:41 +0000 To: "commits@bookkeeper.apache.org" Subject: [bookkeeper] branch master updated: BOOKKEEPER-1044: Entrylogger is not readding rolled logs back to the logChannelsToFlush list when exception happens while trying to flush rolled logs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <150097348165.7269.10792226656219072089@gitbox.apache.org> From: eolivelli@apache.org Reply-To: "commits@bookkeeper.apache.org" X-Git-Host: gitbox.apache.org X-Git-Repo: bookkeeper X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 96d82102bef3152934f564db16373b12b1689ead X-Git-Newrev: 24ac8ead6240aaaaa845afccb4e606fbe0da1602 X-Git-Rev: 24ac8ead6240aaaaa845afccb4e606fbe0da1602 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. eolivelli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/bookkeeper.git The following commit(s) were added to refs/heads/master by this push: new 24ac8ea BOOKKEEPER-1044: Entrylogger is not readding rolled logs back to the logChannelsToFlush list when exception happens while trying to flush rolled logs 24ac8ea is described below commit 24ac8ead6240aaaaa845afccb4e606fbe0da1602 Author: Sijie Guo AuthorDate: Tue Jul 25 11:04:36 2017 +0200 BOOKKEEPER-1044: Entrylogger is not readding rolled logs back to the logChannelsToFlush list when exception happens while trying to flush rolled logs Descriptions of the changes in this PR: This is a straightforward fix to add unflushed list of entry log files back to flushed list. Test is missing at this point because it is a bit complicated to test this without proper mocking. I would defer adding the test later and creating a github issue later on if it makes sense. Author: Sijie Guo Reviewers: Enrico Olivelli This closes #286 from sijie/BOOKKEEPER-1044 --- .../org/apache/bookkeeper/bookie/EntryLogger.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java index 418b7e0..d277b2b 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java @@ -724,8 +724,24 @@ public class EntryLogger { if (null == channels) { return; } - for (BufferedLogChannel channel : channels) { - channel.flush(true); + Iterator chIter = channels.iterator(); + while (chIter.hasNext()) { + BufferedLogChannel channel = chIter.next(); + try { + channel.flush(true); + } catch (IOException ioe) { + // rescue from flush exception, add unflushed channels back + synchronized (this) { + if (null == logChannelsToFlush) { + logChannelsToFlush = channels; + } else { + logChannelsToFlush.addAll(0, channels); + } + } + throw ioe; + } + // remove the channel from the list after it is successfully flushed + chIter.remove(); // since this channel is only used for writing, after flushing the channel, // we had to close the underlying file channel. Otherwise, we might end up // leaking fds which cause the disk spaces could not be reclaimed. -- To stop receiving notification emails like this one, please contact ['"commits@bookkeeper.apache.org" '].