[ 
https://issues.apache.org/jira/browse/HBASE-11794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14106794#comment-14106794
 ] 

Jean-Marc Spaggiari commented on HBASE-11794:
---------------------------------------------

What's about something like this?

{code}
  @Override
  public List<Path> flushSnapshot(MemStoreSnapshot snapshot, long 
cacheFlushSeqNum,
      MonitoredTask status) throws IOException {
    int cellsCount = snapshot.getCellsCount();
    if (cellsCount == 0) return new ArrayList<Path>(); // don't flush if there 
are no entries

    long smallestReadPoint = store.getSmallestReadPoint();
    InternalScanner scanner = createScanner(snapshot.getScanner(), 
smallestReadPoint);
    if (scanner == null) {
      return new ArrayList<Path>();; // NULL scanner returned from coprocessor 
hooks means skip normal processing
    }

    // Let policy select flush method.
    StripeFlushRequest req = this.policy.selectFlush(this.stripes, cellsCount);

    boolean success = false;
    StripeMultiFileWriter mw = null;
    List<Path> result = null;
    try {
      mw = req.createWriter(); // Writer according to the policy.
      StripeMultiFileWriter.WriterFactory factory = createWriterFactory(
          snapshot.getTimeRangeTracker(), cellsCount);
      StoreScanner storeScanner = (scanner instanceof StoreScanner) ? 
(StoreScanner)scanner : null;
      mw.init(storeScanner, factory, store.getComparator());

      synchronized (flushLock) {
        performFlush(scanner, mw, smallestReadPoint);
        result = mw.commitWriters(cacheFlushSeqNum, false);
        success = true;
      }
    } finally {
      if (!success && (mw != null)) {
        if (result != null) {
          result.clear();
        }
        for (Path leftoverFile : mw.abortWriters()) {
          try {
            store.getFileSystem().delete(leftoverFile, false);
          } catch (Exception e) {
            LOG.error("Failed to delete a file after failed flush: " + e);
          }
        }
      }
      try {
        scanner.close();
      } catch (IOException ex) {
        LOG.warn("Failed to close flush scanner, ignoring", ex);
      }
    }
    return result;
  }
{code}

Idea is, if we don't need to return the empty list, then we create an ArrayList 
that we loose after when we assign result with mw.commitWriters. I don't know 
how often this method is called but this will save one object creation.

> StripeStoreFlusher causes NullPointerException and Region down
> --------------------------------------------------------------
>
>                 Key: HBASE-11794
>                 URL: https://issues.apache.org/jira/browse/HBASE-11794
>             Project: HBase
>          Issue Type: Bug
>          Components: Compaction
>    Affects Versions: 0.98.3, 0.98.4, 0.98.5
>            Reporter: jeongmin kim
>            Priority: Critical
>         Attachments: HBASE_11794.patch
>
>
> StoreFlusher.flushSnapshot() mustn't return null value.
> But StripeStoreFlusher.flushSnapshot() does.
> It cause NullPointerException at 
> org.apache.hadoop.hbase.regionserver.HStore.flushCache(HStore.java:802)
> and this makes regions dead after exhaustive retries and no recovery 
> available from it.
> the code (StripeStoreFlusher:64) has to be changed 
> ===============
> from
>     List<Path> result = null 
> to
>      List<Path> result = new ArrayList<Path>();
>  ===============
> to return a empty list not null value.
>     



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to