You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Woody Anderson (JIRA)" <ji...@apache.org> on 2011/04/07 07:00:05 UTC

[jira] [Created] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
----------------------------------------------------------------------------

                 Key: PIG-1973
                 URL: https://issues.apache.org/jira/browse/PIG-1973
             Project: Pig
          Issue Type: Bug
          Components: impl
    Affects Versions: 0.8.0, 0.9.0
            Reporter: Woody Anderson
            Assignee: Woody Anderson
            Priority: Minor
             Fix For: 0.8.0
         Attachments: 1973.patch

this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

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

Woody Anderson updated PIG-1973:
--------------------------------

    Issue Type: Improvement  (was: Bug)

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

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

Woody Anderson updated PIG-1973:
--------------------------------

    Attachment: 1973.patch

use the initialValue method of ThreadLocal, which is how to correctly handle lazy initialization. 

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.8.0
>
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

Posted by "Richard Ding (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13022373#comment-13022373 ] 

Richard Ding commented on PIG-1973:
-----------------------------------

I agree that this is a better usage idiom. But the initialValue method is invoked the first time a thread accesses the ThreadLocal variable with the get method, so the outcomes are the same. 

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

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

Olga Natkovich updated PIG-1973:
--------------------------------

    Fix Version/s:     (was: 0.8.0)
                   0.9.0

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext usage of ThreadLocal pattern is not typical

Posted by "Thejas M Nair (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thejas M Nair updated PIG-1973:
-------------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

+1 
Patch committed to trunk.
Thanks Woody!

> UDFContext.getUDFContext usage of ThreadLocal pattern is not typical
> --------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>         Attachments: 1973.patch, PIG-1973.1.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

Posted by "Thejas M Nair (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thejas M Nair updated PIG-1973:
-------------------------------

    Attachment: PIG-1973.1.patch

Patch looks good.
I have re-generated the patch (PIG-1973.1.patch) with latest svn trunk. Running run test-patch and unit tests.

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>         Attachments: 1973.patch, PIG-1973.1.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

Posted by "Woody Anderson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13022584#comment-13022584 ] 

Woody Anderson commented on PIG-1973:
-------------------------------------

incorrect.

initialValue is invoked when get() is first called. However, in the old code, initialValue returns null b/c it was not overridden.
thus, if 2 threads call getUDFContext() at the same time they may get 2 different UDFContext objects, b/c the method 
does an unprotected comparison/set check:

{code}
     public static UDFContext getUDFContext() {
        if (tss.get() == null) {
            UDFContext ctx = new UDFContext();
            tss.set(ctx);
        }
        return tss.get();
     }
{code}

this is CLASSIC race condition.


> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

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

Alan Gates updated PIG-1973:
----------------------------

    Status: Patch Available  (was: Open)

Marking as submitpatch so we can get this reviewed and committed.

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext usage of ThreadLocal pattern is not typical

Posted by "Thejas M Nair (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thejas M Nair updated PIG-1973:
-------------------------------

    Summary: UDFContext.getUDFContext usage of ThreadLocal pattern is not typical  (was: UDFContext.getUDFContext has a thread race condition around it's ThreadLocal)

Updating the summary to indicate that this is a code improvement, but not a bug.


> UDFContext.getUDFContext usage of ThreadLocal pattern is not typical
> --------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>         Attachments: 1973.patch, PIG-1973.1.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

Posted by "Woody Anderson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13022939#comment-13022939 ] 

Woody Anderson commented on PIG-1973:
-------------------------------------

ok. i agree. it's not a bug.
though, i still find it misleading code, in that it doesn't utilize the easy concise form, and at least to me "looks wrong" on 1st and second inspection.

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.9.0
>
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PIG-1973) UDFContext.getUDFContext has a thread race condition around it's ThreadLocal

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

Olga Natkovich updated PIG-1973:
--------------------------------

    Fix Version/s:     (was: 0.9.0)

> UDFContext.getUDFContext has a thread race condition around it's ThreadLocal
> ----------------------------------------------------------------------------
>
>                 Key: PIG-1973
>                 URL: https://issues.apache.org/jira/browse/PIG-1973
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>         Attachments: 1973.patch
>
>
> this is probably isn't manifesting anywhere, but it's an incorrect use of the ThreadLocal pattern.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira