From be6e4c6593f4ae94e3dfddcb9e359cf611885ee0 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 23 May 2012 20:17:44 +0000 Subject: [PATCH] HBASE-6065 Log for flush would append a non-sequential edit in the hlog, leading to possible data loss (Chunhui) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1342019 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/regionserver/wal/HLogSplitter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java index 3739592b626..35f04138129 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java @@ -1303,8 +1303,15 @@ public class HLogSplitter { * Update region's maximum edit log SeqNum. */ void updateRegionMaximumEditLogSeqNum(Entry entry) { - regionMaximumEditLogSeqNum.put(entry.getKey().getEncodedRegionName(), - entry.getKey().getLogSeqNum()); + synchronized (regionMaximumEditLogSeqNum) { + Long currentMaxSeqNum=regionMaximumEditLogSeqNum.get(entry.getKey().getEncodedRegionName()); + if (currentMaxSeqNum == null + || entry.getKey().getLogSeqNum() > currentMaxSeqNum) { + regionMaximumEditLogSeqNum.put(entry.getKey().getEncodedRegionName(), + entry.getKey().getLogSeqNum()); + } + } + } Long getRegionMaximumEditLogSeqNum(byte[] region) {