From hdfs-issues-return-239283-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Sun Oct 21 13:53:05 2018 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 mx-eu-01.ponee.io (Postfix) with SMTP id BB99918065D for ; Sun, 21 Oct 2018 13:53:04 +0200 (CEST) Received: (qmail 96604 invoked by uid 500); 21 Oct 2018 11:53:03 -0000 Mailing-List: contact hdfs-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-issues@hadoop.apache.org Received: (qmail 96593 invoked by uid 99); 21 Oct 2018 11:53:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Oct 2018 11:53:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 579EE180B80 for ; Sun, 21 Oct 2018 11:53:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 7u5EkzpyYWDh for ; Sun, 21 Oct 2018 11:53:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 59D865F16F for ; Sun, 21 Oct 2018 11:53:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7CCC7E070F for ; Sun, 21 Oct 2018 11:53:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2F903252A0 for ; Sun, 21 Oct 2018 11:53:00 +0000 (UTC) Date: Sun, 21 Oct 2018 11:53:00 +0000 (UTC) From: "Tsz Wo Nicholas Sze (JIRA)" To: hdfs-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HDDS-638) enable ratis snapshots for HDDS datanodes 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/HDDS-638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16658188#comment-16658188 ] Tsz Wo Nicholas Sze commented on HDDS-638: ------------------------------------------ Some comments on ContainerStateMachine: - For updating lastAppliedTermIndex: -* ConcurrentHashMap does not support null values. It won't work since addRequest always returns null. Just remove addRequest. -* Remove addRequest(..) since it do not seem useful. -* lastSuccessfullyAppliedIndex does not seem useful. How about removing it? Just use lastAppliedTermIndex in BaseStateMachine. The code should look like below: {code} + private void updateLastAppliedTermIndex() { + Long appledTerm = null; + long appliedIndex = -1; + for(long i = getLastAppliedTermIndex().getIndex() + 1;; i++) { + final Long removed = containerCommandCompletionMap.remove(i); + if (removed == null) { + break; + } + appledTerm = removed; + appliedIndex = i; + } + if (appledTerm != null) { + updateLastAppliedTermIndex(appliedIndex, appledTerm); + } + } + /* * ApplyTransaction calls in Ratis are sequential. */ @Override public CompletableFuture applyTransaction(TransactionContext trx) { + final long index = trx.getLogEntry().getIndex(); try { metrics.incNumApplyTransactionsOps(); ContainerCommandRequestProto requestProto = @@ -418,7 +476,7 @@ private ByteString readStateMachineData(LogEntryProto entry, blockDataProto.getBlockID()); return completeExceptionally(ioe); } - blockData.setBlockCommitSequenceId(trx.getLogEntry().getIndex()); + blockData.setBlockCommitSequenceId(index); final ContainerProtos.PutBlockRequestProto putBlockRequestProto = ContainerProtos.PutBlockRequestProto .newBuilder(requestProto.getPutBlock()) @@ -440,6 +498,13 @@ private ByteString readStateMachineData(LogEntryProto entry, future.thenApply( r -> createContainerFutureMap.remove(containerID).complete(null)); } + + future.thenAccept( m -> { + final Long previous = containerCommandCompletionMap.put(index, trx.getLogEntry().getTerm()); + Preconditions.checkState(previous == null); + updateLastAppliedTermIndex(); + }); + return future; } catch (IOException e) { metrics.incNumApplyTransactionsFails(); {code} - Why "TODO persist open containers in snapshots"? Open containers should be persisted if the index is applied to state machine. No? - In loadSnapshot, remove the snapshotFile.exists() check. It must exist by storage.getLatestSnapshot(). -* Remove the warning from the snapshot == null case. It is normal when the storage is newly formatted. - Add @Override to takeSnapshot() and it should throw IOException when createNewFile() fails. - In the test, it should check if the expected snapshot files exists. Some other comments: - flushStateMachineData is expensive since it loops through the entire map. It should be rewritten (probably in a sepearted JIRA.) - The following TODO in initialize(.,) can be removed. BaseStateMachine.getId() will the server id iff initialize has been called; otherwise, it returns null. {code} // TODO: Add a flag that tells you that initialize has been called. // Check with Ratis if this feature is done in Ratis. {code} > enable ratis snapshots for HDDS datanodes > ----------------------------------------- > > Key: HDDS-638 > URL: https://issues.apache.org/jira/browse/HDDS-638 > Project: Hadoop Distributed Data Store > Issue Type: Bug > Components: Ozone Datanode > Affects Versions: 0.3.0 > Reporter: Mukul Kumar Singh > Assignee: Mukul Kumar Singh > Priority: Blocker > Attachments: HDDS-638.001.patch > > > Currently on a restart, a hdds datanode, starts applying log entries from the start of the log. > This should can be avoided by taking a ratis snapshot to persist the last stable state and on restart the datanodes start applying log from that index. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org