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

Anoop Sam John commented on HBASE-16438:
----------------------------------------

The discussion here made to again read the code in MSLABImpl#getOrMakeChunk()
{code}
while (true) {
      // Try to get the chunk
      Chunk c = curChunk.get();
      if (c != null) {
        return c;
      }

     .....
        c = new OnheapChunk(chunkSize);// When chunk is not from pool, always 
make it as on heap.
      ...
      if (curChunk.compareAndSet(null, c)) {
        // we won race - now we need to actually do the expensive
        // allocation step
        c.init();
        ...
        return c;
      }
          ..
      // someone else won race - that's fine, we'll try to grab theirs
      // in the next iteration of the loop.
    }
{code}
I believe there is a possible multi thread case bug here.
2 Threads trying to make chunk. Both made OnheapChunk objects (Not init) and 
only one will succeed in CAS. That will do the init and so make BB in chunk. 
Unless this init() call is happened, the chunk's underlying data is null.  Now 
the second thread, after failed in CAS op, went to next iteration and see 
curChunk is not null and it will use that. But remember, if this thread getting 
chance 1st before actual init() op on this chunk, any try for copy on to it 
will fail with NPE !

> Create a cell type so that chunk id is embedded in it
> -----------------------------------------------------
>
>                 Key: HBASE-16438
>                 URL: https://issues.apache.org/jira/browse/HBASE-16438
>             Project: HBase
>          Issue Type: Sub-task
>    Affects Versions: 2.0.0
>            Reporter: ramkrishna.s.vasudevan
>            Assignee: ramkrishna.s.vasudevan
>         Attachments: HBASE-16438_1.patch, HBASE-16438.patch, 
> MemstoreChunkCell_memstoreChunkCreator_oldversion.patch, 
> MemstoreChunkCell_trunk.patch
>
>
> For CellChunkMap we may need a cell such that the chunk out of which it was 
> created, the id of the chunk be embedded in it so that when doing flattening 
> we can use the chunk id as a meta data. More details will follow once the 
> initial tasks are completed. 
> Why we need to embed the chunkid in the Cell is described by [~anastas] in 
> this remark over in parent issue 
> https://issues.apache.org/jira/browse/HBASE-14921?focusedCommentId=15244119&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15244119



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to