Fix gerrit show-queue timing out when webhooks are processed

When webhooks are processed and one calls the following command
  ssh -p 29418 admin@server gerrit show-queue --by-queue -w

command times out and javamelody reports ssh show-queue thread as
BLOCKED here is the trace:

SSH gerrit show-queue --by-queue -w (jcentkowski)
com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:158)
com.googlesource.gerrit.plugins.webhooks.PostTask.toString(PostTask.java:110)
com.google.gerrit.server.git.WorkQueue$Task.toString(WorkQueue.java:456)
com.google.gerrit.server.config.ListTasks$TaskInfo.(ListTasks.java:124)
com.google.gerrit.server.config.ListTasks$1.getTaskInfo(ListTasks.java:91)
com.google.gerrit.server.config.ListTasks$1.getTaskInfo(ListTasks.java:88)
com.google.gerrit.server.git.WorkQueue.getTaskInfos(WorkQueue.java:128)
com.google.gerrit.server.config.ListTasks.getTasks(ListTasks.java:87)
com.google.gerrit.server.config.ListTasks.apply(ListTasks.java:62)
com.google.gerrit.sshd.commands.ShowQueue.run(ShowQueue.java:97)
com.google.gerrit.sshd.SshCommand$1.run(SshCommand.java:35)
com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:453)
java.base@9/java.lang.Thread.run(Unknown Source)

It is eventually unblocking but leaves show-queue command timing out for
the time required by process.get() to return.

As a solution don't call processor.get() in toString() as it could take substantial
amount of time to gather request data (depends on EventProcessor.process()
implementation) but rely on data that is already available like event and remote.
That is sufficient for show-queue and logging purposes.

Change-Id: I618e00bb5f06335b17cda36e19f48cd3ba679e6a
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
1 file changed
tree: a4a6496a53685e2e128e59e188d895cdb4f1c9d5
  1. src/
  2. tools/
  3. .gitignore
  4. bazlets.bzl
  5. BUILD
  6. external_plugin_deps.bzl
  7. WORKSPACE