You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by dalaro <gi...@git.apache.org> on 2015/11/23 23:24:35 UTC

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

GitHub user dalaro opened a pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154

    TINKERPOP3-988 Change SparkGraphComputer executor

    https://issues.apache.org/jira/browse/TINKERPOP3-988 describes the problem and my justification of this change.
    
    ForkJoinPool.commonPool shouldn't be used here, but I'm also not certain that creating one single-threaded executor per `submit` call is a reasonable alternative.  My assumption is that `SparkGraphComputer.submit` is an operation with pretty heavyweight processing implications, so this isn't something you'd want to fire off ten thousand times a second, and the overhead of one thread per call isn't that bad.  I can rework it if you think this is not acceptable though.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dalaro/incubator-tinkerpop master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-tinkerpop/pull/154.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #154
    
----
commit df930bb5b3f36daea33f40e13996cf75fe307979
Author: Dan LaRocque <da...@hopcount.org>
Date:   2015-11-23T21:42:46Z

    TINKERPOP3-988 Change SparkGraphComputer executor
    
    Changed SparkGraphComputer's submit method to use a custom executor
    instead of ForkJoinPool.commonPool.
    
    The submit method does very little in the calling thread; most of its
    work is done in an asynchronously-executed completable future.
    
    If the async task executes on ForkJoinPool.commonPool (the default if
    no executor is supplied), then two problems can arise:
    
    1. Loss of context classloader
    
    The context classloader of the thread that called submit is not
    necessarily the same as the context classloader common forkjoin pool
    threads. This matters because multiple bits of code reachable from
    submit's async task rely on the context classloader. SparkMemory is
    one; Hadoop's UserGroupInformation is another, depending on the
    credentials configuration (UGI is reached indirectly via
    FileSystem.get). This basically means that the caller has to use
    whatever context classloader is currently in use by the fork join
    common pool, or else bad things can happen, such as
    nonsensical-looking ClassCastExceptions.
    
    2. Inability to set context classloader
    
    When System.getSecurityManager() != null, the common forkjoin pool
    switches from its default worker thread factory implementation to a
    more restrictive alternative called
    InnocuousForkJoinWorkerThreadFactory. Threads created by this factory
    can't call setContextClassLoader. Attempting to do so throws a
    SecurityException. However, UserGroupInformation.newLoginContext must
    be able to call setContextClassLoader. It saves the CCL to a variable,
    does some work, then restores the CCL from a variable. This is
    impossible if the method throws a SecurityException. So, if a security
    manager is present in the VM, submit's async task can die in
    FileSystem.get -> UGI before any useful work even begins.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-159212987
  
    hmmm - I can see where @dalaro is coming on this one though I didn't know that it would cause problems or whether it would cause problems elsewhere or just Spark.  
    
    VOTE +1 - pending dan's answer on `Giraph/TinkerGraphComputer` which both have `ForkJoinPool` usage.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by dalaro <gi...@git.apache.org>.
Github user dalaro closed the pull request at:

    https://github.com/apache/incubator-tinkerpop/pull/154


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by dalaro <gi...@git.apache.org>.
Github user dalaro commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-159313974
  
    I think this problem also applies to GiraphGraphComputer.  Consider the following sequence of operations in SparkGraphComputer when `null != System.getSecurityManager()`.
    
    * submit passes a task to CompletableFuture.supplyAsync (served by the forkjoin common pool)
    * submitted task calls FileSystem.get
    * FileSystem.get calls a bunch of Hadoop permission guts and eventually gets to UserGroupInformation.newLoginContext
    * UserGroupInformation.newLoginContext calls setContextClassLoader on the current thread
    * setContextClassLoader throws SecurityException if `null != System.getSecurityManager()` and the task is running in a common forkjoin pool thread, killing the task
    
    The FileSystem.get call is visible in SGC's source.  The succeeding calls happen inside FileSystem.get and aren't visible in TP's source.  But GGC calls FileSystem.get with the same parameter signature as SGC, so they should both be affected by this problem.
    
    I don't know whether the same problem applies to TinkerGraphComputer, but my guess is no, unless TinkerGraphComputer's internals touch the context classloader or something else that does, like Hadoop.
    
    I'll rework the PR to apply to both SGC and GGC (but not TGC).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-160643374
  
    We will merge this when @dalaro submits the same fix for `GiraphGraphComputer`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by dalaro <gi...@git.apache.org>.
Github user dalaro commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-160962223
  
    I'll open a new PR.  Don't merge this one.  I extracted the common executor-related logic into a helper shared between the Giraph and Spark computers, but much more importantly, my first attempt at this leaks executors.  Nowhere does my patch call `shutdown` or `shutdownNow`.   The `newSingleThreadExecutor` factory method that I invoked internally sets the core-pool size to 1, so the idle thread could never die, even after its submission-related work is all done.  I resolved this in an incoming PR with a try-finally construct where the try block constructs the executor and the finally block invokes `shutdown`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-159091761
  
    I have no idea why this is good or bad but if @dalaro says it should be as he has it, I'm all for it. Also, to answer @dalaro -- no, this is not a heavily threaded method. This is batch processing and thus, you won't be "firing off ten thousand times a second."
    
    @dalaro -- QUESTION: Should we do the same for `GiraphGraphComputer`? If so, can you update your PR for that as well. Also, what about `TinkerGraphComputer`?
    
    I pulled into a local branch. Tested `SparkGraphComputerProcessIntegrationTest`. It passed fully. I also ran the `mvn clean install` to test other non-integration tests for Spark. They all passed as well.
    
    VOTE +1.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-160630596
  
    Full test suite passed for me.
    
    VOTE: +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP3-988 Change SparkGraph...

Posted by dalaro <gi...@git.apache.org>.
Github user dalaro commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/154#issuecomment-160992073
  
    This is superseded by https://github.com/apache/incubator-tinkerpop/pull/164.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---