Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-11868

Data loss in hlog when the hdfs is unavailable



    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 0.98.5
    • Fix Version/s: 0.98.6
    • Component/s: None
    • Labels:
    • Hadoop Flags:


      When using the new thread model in hbase 0.98, we found a bug which may cause data loss when the the hdfs is unavailable.

      When writing wal Edits to hlog in doMiniBatchMutation of HRegion, the hlog first call appendNoSync to write the edits to hlog and then call sync with txid.

      Assumed that the txid of current write is 10, and the syncedTillHere in hlog is 9 and the failedTxid is 0. When the the hdfs is unavailable, the AsyncWriter or AsyncSyncer will fail to apend the edits or sync, then they will update the syncedTillHere to 10 and the failedTxid to 10.

      When the hlog calls the sync with txid :10, the failedTxid will nerver be checked for txid equals with syncedTillHere. The client thinks the write success , but the data only be writtten to memstore not hlog. If the regionserver is down later before the memstore is flushed, the data will be lost.

      See: FSHLog.java #1348

        // sync all transactions upto the specified txid
        private void syncer(long txid) throws IOException {
          synchronized (this.syncedTillHere) {
            while (this.syncedTillHere.get() < txid) {
              try {
                if (txid <= this.failedTxid.get()) {
                  assert asyncIOE != null :
                    "current txid is among(under) failed txids, but asyncIOE is null!";
                  throw asyncIOE;
              } catch (InterruptedException e) {
                LOG.debug("interrupted while waiting for notification from AsyncNotifier");

      We can fix this issue by moving the comparing of txid and failedTxid outside the while block.


        1. HBASE-11868-0.98-v1.diff
          1 kB
          Shaohui Liu
        2. HBASE-11868-0.98-v2.diff
          2 kB
          Shaohui Liu



            • Assignee:
              liushaohui Shaohui Liu
              liushaohui Shaohui Liu
            • Votes:
              0 Vote for this issue
              7 Start watching this issue


              • Created: