stash-jenkins-postreceive-webhook icon indicating copy to clipboard operation
stash-jenkins-postreceive-webhook copied to clipboard

fix request action logging

Open marvinthepa opened this issue 7 years ago • 0 comments

Problem: If a lot of commits are pushed to different repos that all have the hook installed, the bitbucket log may contain entries like the following one. Here the request logged is for the rep_1 repository, while the notification URL is for the rep_2 repository:

2017-07-12 16:22:14,009 ERROR [JenkinsWebhook:thread-1353] [email protected] @1NT5XEPx981x8325789x2 1oo66tb 127.0.0.1 SSH - git-receive-pack '/project_1/rep_1.git' com.nerdwin15.stash.webhook.Notifier Error triggering jenkins with url 'http://localhost:8080/jenkins/git/notifyCommit?url=http%3A%2F%2Flocalhost%3A7990%2Fbitbucket%2Fscm%2Fproject_2%2Frep_2.git'

(this one only occurs when the hook runs into an error, but similar ones can be found for succesful requests when setting the com.nerdwin15.stash logger to DEBUG)

This is caused by the fact that we are running in a thread pool, and the original request that caused this (that was run in a different thread) is not correctly associated in the MDC map of logback.

Fix: Tell logback about the original request manually.

See https://stackoverflow.com/questions/6073019/how-to-use-mdc-with-thread-pools#19329668 https://logback.qos.ch/manual/mdc.html#managedThreads

Also see https://jira.atlassian.com/browse/BSERV-8749

marvinthepa avatar Jul 21 '17 11:07 marvinthepa