Return-Path: Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: (qmail 84789 invoked from network); 26 Jan 2011 09:09:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Jan 2011 09:09:16 -0000 Received: (qmail 52479 invoked by uid 500); 26 Jan 2011 09:09:15 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 52381 invoked by uid 500); 26 Jan 2011 09:09:13 -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 52356 invoked by uid 99); 26 Jan 2011 09:09:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jan 2011 09:09:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jan 2011 09:09:10 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id p0Q98mnw026575 for ; Wed, 26 Jan 2011 09:08:48 GMT Message-ID: <2556309.210731296032928828.JavaMail.jira@thor> Date: Wed, 26 Jan 2011 04:08:48 -0500 (EST) From: "ryan rawson (JIRA)" To: issues@hbase.apache.org Subject: [jira] Commented: (HBASE-3481) max seq id in flushed file can be larger than its correct value causing data loss during recovery In-Reply-To: <4326013.210121296031617614.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HBASE-3481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12986907#action_12986907 ] ryan rawson commented on HBASE-3481: ------------------------------------ if we avoid the skip behaviour, which isnt optimization, we will introduce duplicate KVs into the HFiles, which for people who are depending on the version count to keep a reasonable, important, number of versions will be trouble for them. why not just nab the largest seqid during flush and provide it at the end? The footer is written out at close() time, and we have time between the last KV being appened and close() being called to add a correct SEQ_ID. > max seq id in flushed file can be larger than its correct value causing data loss during recovery > ------------------------------------------------------------------------------------------------- > > Key: HBASE-3481 > URL: https://issues.apache.org/jira/browse/HBASE-3481 > Project: HBase > Issue Type: Bug > Reporter: Kannan Muthukkaruppan > Priority: Critical > > [While doing some cluster kill tests, I noticed some missing data after log recovery. Upon investigating further, and pretty printing contents of HFiles and recovered logs, this is my analysis of the situation/bug. Please confirm the theory and pitch in with suggestions.] > When memstores are flushed, the max sequence id recorded in the HFile should be the max sequence id of all KVs in the memstore. However, we seem to simply obtain the current sequence id from the HRegion, and stamp the HFile's MAX_SEQ_ID with it. > From HRegion.java: > {code} > sequenceId = (wal == null)? myseqid: wal.startCacheFlush(); > {code} > where, startCacheFlush() is: > {code} > public long startCacheFlush() { > this.cacheFlushLock.lock(); > return obtainSeqNum(); > } > {code} > where, obtainSeqNum() is simply: > {code} > private long obtainSeqNum() { > return this.logSeqNum.incrementAndGet(); > } > {code} > So let's say a memstore contains edits with sequence number 1..10. > Meanwhile, say more Puts come along, and are going through this flow (in pseudo-code) > {code} > 1. HLog.append(); > 1.1 obtainSeqNum() > 1.2 writeToWAL() > 2 updateMemStore() > {code} > So it is possible that the sequence number has already been incremented to say 15 if there are 5 more outstanding puts. Say the writeToWAL() is still in progress for these puts. In this case, none of these edits (11..15) would have been written to memstore yet. > At this point if a cache flush of the memstore happens, then we'll record its MAX_SEQ_ID as 16 in the store file instead of 10 (because that's what obtainSeqNum() would return as the next sequence number to use, right?). > Assume that the edits 11..15 eventually complete. And so HLogs do contain the data for edits 11..15. > Now, at this point if the region server were to crash, and we run log recovery, the splits all go through correctly, and a correct recovered.edits file is generated with the edits 11..15. > Next, when the region is opened, the HRegion notes that one of the store file says MAX_SEQ_ID is 16. So, when it replays the recovered.edits file, it skips replaying edits 11..15. Or in other words, data loss. > ---- -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.