When testing latest master we ran into issue where push to gerrit was rejected with internal server error. I traced this down to commit "Perform change update on multiple threads" c545c0901241314190cac02a24aa95f831dd0572. Commit introduces the Callable wrapper voa ServletScopes which has a check to ensure that the call does not happen on the HTTP thread, resulting in exception:
java.lang.IllegalStateException: Cannot continue request in the same thread as a HTTP request!
Reverting this commit allowed gerrit to work again. Please see the full stack trace below.
com.google.gwtorm.server.OrmException: Error updating database
at com.google.gerrit.server.git.ReceiveCommits$1.apply(ReceiveCommits.java:226)
at com.google.gerrit.server.git.ReceiveCommits$1.apply(ReceiveCommits.java:220)
at com.google.common.util.concurrent.Futures$MappingCheckedFuture.mapException(Futures.java:1215)
at com.google.common.util.concurrent.AbstractCheckedFuture.checkedGet(AbstractCheckedFuture.java:85)
at com.google.gerrit.server.git.ReceiveCommits.insertChangesAndPatchSets(ReceiveCommits.java:675)
at com.google.gerrit.server.git.ReceiveCommits.processCommands(ReceiveCommits.java:521)
at com.google.gerrit.server.git.AsyncReceiveCommits$Worker.run(AsyncReceiveCommits.java:90)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:196)
at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:174)
at com.google.inject.servlet.ServletScopes$3.call(ServletScopes.java:194)
at com.google.gerrit.server.util.RequestScopePropagator$1.call(RequestScopePropagator.java:81)
at com.google.gerrit.server.util.RequestScopePropagator$2.run(RequestScopePropagator.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Cannot continue request in the same thread as a HTTP request!
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
at com.google.common.util.concurrent.AbstractCheckedFuture.checkedGet(AbstractCheckedFuture.java:78)
... 18 more
Caused by: java.lang.IllegalStateException: Cannot continue request in the same thread as a HTTP request!
at com.google.inject.internal.util.$Preconditions.checkState(Preconditions.java:142)
at com.google.inject.servlet.ServletScopes$3.call(ServletScopes.java:187)
at com.google.gerrit.server.util.RequestScopePropagator$1.call(RequestScopePropagator.java:81)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:56)
at com.google.gerrit.server.git.ReceiveCommits$CreateRequest.insertChange(ReceiveCommits.java:1291)
at com.google.gerrit.server.git.ReceiveCommits.insertChangesAndPatchSets(ReceiveCommits.java:671)