You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by "Erik Rozendaal (JIRA)" <ji...@apache.org> on 2009/10/22 09:32:59 UTC

[jira] Created: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Scanners not closed properly in certain circumstances (memory leak)
-------------------------------------------------------------------

                 Key: HBASE-1927
                 URL: https://issues.apache.org/jira/browse/HBASE-1927
             Project: Hadoop HBase
          Issue Type: Bug
          Components: regionserver
    Affects Versions: 0.20.1
            Reporter: Erik Rozendaal
             Fix For: 0.20.2


Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.

Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.

The quick fix is to add an else clause to the if on line 58:

} else {
  scanner.close()
}

The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "Jonathan Gray (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Gray updated HBASE-1927:
---------------------------------

    Attachment: HBASE-1927-v1-trunk.patch

Patch didn't apply cleanly to trunk, just want to run local tests before committing.

> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>            Assignee: Jonathan Gray
>             Fix For: 0.20.2, 0.21.0
>
>         Attachments: HBASE-1927-v1-trunk.patch, HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "Jonathan Gray (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Gray updated HBASE-1927:
---------------------------------

    Status: Patch Available  (was: Open)

> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>            Assignee: Jonathan Gray
>             Fix For: 0.20.2, 0.21.0
>
>         Attachments: HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "Jonathan Gray (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Gray updated HBASE-1927:
---------------------------------

    Attachment: HBASE-1927-v1.patch

Thanks for finding this Erik.

Patch adds closing of empty KVScanners in KVHeap and adds comment in constructor javadoc.

Also adds a test in TestKeyValueHeap that uncovers the issue.  Test passes with patch.

> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>             Fix For: 0.20.2
>
>         Attachments: HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "Erik Rozendaal (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12768793#action_12768793 ] 

Erik Rozendaal commented on HBASE-1927:
---------------------------------------

Patch applies, compiles, and fixes the problem. Thanks!


> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>            Assignee: Jonathan Gray
>             Fix For: 0.20.2, 0.21.0
>
>         Attachments: HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "Jonathan Gray (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Gray updated HBASE-1927:
---------------------------------

      Resolution: Fixed
    Hadoop Flags: [Reviewed]
          Status: Resolved  (was: Patch Available)

Test passes on branch and trunk.  Committed to both.  Thanks Erik and Stack.

> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>            Assignee: Jonathan Gray
>             Fix For: 0.20.2, 0.21.0
>
>         Attachments: HBASE-1927-v1-trunk.patch, HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "Jonathan Gray (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Gray updated HBASE-1927:
---------------------------------

    Fix Version/s: 0.21.0
         Assignee: Jonathan Gray

Bug exists in trunk as well.  Please review for commit.

> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>            Assignee: Jonathan Gray
>             Fix For: 0.20.2, 0.21.0
>
>         Attachments: HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HBASE-1927) Scanners not closed properly in certain circumstances (memory leak)

Posted by "stack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12768765#action_12768765 ] 

stack commented on HBASE-1927:
------------------------------

+1 for branch and trunk.  Thanks Erik for the fix.

> Scanners not closed properly in certain circumstances (memory leak)
> -------------------------------------------------------------------
>
>                 Key: HBASE-1927
>                 URL: https://issues.apache.org/jira/browse/HBASE-1927
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: regionserver
>    Affects Versions: 0.20.1
>            Reporter: Erik Rozendaal
>            Assignee: Jonathan Gray
>             Fix For: 0.20.2, 0.21.0
>
>         Attachments: HBASE-1927-v1.patch
>
>
> Scanners are sometimes leaked by the KeyValueHeap class. The constructor adds each scanner to a heap, but only if the scanner's peek() method returns not null (line 58). Otherwise the scanner is dropped without being closed.
> Unfortunately some scanners (like StoreScanner and MemStoreScanner) register themselves to some global list when constructed and only deregister on close(). This can cause a memory leak, for example with MemStoreScanners on an empty memory store.
> The quick fix is to add an else clause to the if on line 58:
> } else {
>   scanner.close()
> }
> The root cause is that ownership of the scanners is transferred from the caller to the KeyValueHeap on construction. Maybe this should be made clear in the documentation or changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.