Create Hive Job Hanging in Web Application

Aug 28, 2014 at 10:41 PM
I am using the sample console application code to submit a Hive query and it is working fine. When I try to run the same code in a web application it hangs on the following line:

JobCreationResults jobResults = jobClient.CreateHiveJob(hiveJobDefinition);

No exception are being thrown and it appears to not timeout. The code is being executed on localhost from the Visual Studio environment.

Should the code work outside of console application?
Oct 30, 2014 at 8:49 PM
I am seeing this too. Has anyone else seen this?
Nov 6, 2014 at 9:48 PM
Edited Nov 6, 2014 at 9:49 PM
Its because of blocking in the UI Synchronization context from your web app. I assume you are invoking it directly from your view page.

Try the following.
  1. override the SynchronizationContext

    var sc = new SynchronizationContext();
    SynchronizationContext.SetSynchronizationContext(sc);
    {
    Invoke SDK commands here
    }
  2. Start an Async task
    {
    Task.Run(async () =>
               {
                 Invoke SDK commands here
               });
    }
Jan 23, 2015 at 10:17 PM
Also see https://hadoopsdk.codeplex.com/workitem/66 for a solution. I believe this is not a SynchronizationContext problem but an issue with how the SDK has implemented the async/await pattern. The workaround is to wrap all calls (sync or async) to the SDK in Task.Run methods.