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

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

One Q on this below code part
{code}
Chunk saveChunkFromGC(int chunkID) {
    Chunk c = strongChunkIdMap.get(chunkID); // check whether the chunk is 
already protected
    if (c != null)                           // with strong pointer
      return c;
    WeakReference<Chunk> ref = weakChunkIdMap.get(chunkID);
    if (ref != null) {
      c = ref.get();
    }
    if (c != null) {
      // put this strong reference to chunk into the strongChunkIdMap
      // the read of the weakMap is always happening before the read of the 
strongMap
      // so no synchronization issues here
      this.strongChunkIdMap.put(chunkID, c);
      this.weakChunkIdMap.remove(chunkID);
      return c;
    }
    // we should actually never return null as someone should not ask to save 
from GC a chunk,
    // which is already released. However, we are not asserting it here and we 
let the caller
    // to deal with the return value an assert if needed
    return null;
  }
{code}
My case is with not using pool. So when the chunk was created by the 
ChunkCreator, the ref is put in weak map and no refs in strong map. So weak map 
refer to the Chunk object as such.  Now MSLAB impl class will have ref to 
current Chunk (To which cells are written).  Then we may move to next chunks 
and old ones, we keep only chunk ids.  The active Cells will refer to the 
ByteBuffer within the Chunk. So no refs to Chunk object as such.
Are we always sure when the above is called, the weak map will have refs to 
Chunks still ?  The Chunk object as such is not referred from any other place 
though the ByteBuffer is referred.  Ya the Chunk is having ref to live BB 
object but the Chunk object as such is unreferred? 


> The pool chunks from ChunkCreator are deallocated while in pool because there 
> is no reference to them
> -----------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-18375
>                 URL: https://issues.apache.org/jira/browse/HBASE-18375
>             Project: HBase
>          Issue Type: Sub-task
>    Affects Versions: 2.0.0-alpha-1
>            Reporter: Anastasia Braginsky
>            Assignee: Anastasia Braginsky
>            Priority: Critical
>             Fix For: 2.0.0, 3.0.0, 2.0.0-alpha-2
>
>         Attachments: HBASE-18375-V01.patch, HBASE-18375-V02.patch, 
> HBASE-18375-V03.patch, HBASE-18375-V04.patch
>
>
> Because MSLAB list of chunks was changed to list of chunk IDs, the chunks 
> returned back to pool can be deallocated by JVM because there is no reference 
> to them. The solution is to protect pool chunks from GC by the strong map of 
> ChunkCreator introduced by HBASE-18010. Will prepare the patch today.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to