bitbucket-branch-source-plugin icon indicating copy to clipboard operation
bitbucket-branch-source-plugin copied to clipboard

PR can be triggered multiple times by NativeServerPushHookProcessor

Open sams-gleb opened this issue 3 years ago • 2 comments

Jenkins and plugins versions report

Jenkins and plugins versions report: Jenkins LTS 2.303.3

Bitbucket: v7.17.1

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 18.04.6 LTS

Reproduction steps

Sometimes when we have too many opened PRs and a lot of incoming events we can see incorrectly triggered builds (revision could be changed back to previous one). This is related to parallel processing of events (there are 10 parallel threads for scm processing) and necessity to call "changes" api for each PR beforehand when using BB 7.

Example series of events:

  • 14:45 (finished 14:55) master branch updated hook which checks for all incoming PRs and takes some time to finish calls for change api (in our case with ~150 active PRs it might be about 10 mins) and seems at this point it overrides version created by PR hook (at 14:49) to the previous one (so happened after 14:49 and before 14:55) -

9e619cb07af077c783d801197bce92ef5effc0c5+56e0e8848c3e60f5278b4d90051bff939295f36e → 8f3f63fc14f7058ca097b43cb9fc2d2a88b7df47+56e0e8848c3e60f5278b4d90051bff939295f36e

  • 14:47 (finished 14:47) new commit, updates revision and triggers build

8f3f63fc14f7058ca097b43cb9fc2d2a88b7df47+56e0e8848c3e60f5278b4d90051bff939295f36e → 9e5dcbad241994b7e4300704147dbffbb4d54d1c+56e0e8848c3e60f5278b4d90051bff939295f36e

  • 14:49 (finished 14:49) new rebase, update revision and triggers build -

9e5dcbad241994b7e4300704147dbffbb4d54d1c+56e0e8848c3e60f5278b4d90051bff939295f36e → 9e619cb07af077c783d801197bce92ef5effc0c5+56e0e8848c3e60f5278b4d90051bff939295f36e

  • 14:53 (finished 14:59:47) next master hook

8f3f63fc14f7058ca097b43cb9fc2d2a88b7df47+56e0e8848c3e60f5278b4d90051bff939295f36e → 9e619cb07af077c783d801197bce92ef5effc0c5+816b6b76b68480a9bcbcdd4cb11c18804229590c

So here we had 2 actual changes and 4 triggered builds

Expected Results

1 PR build triggered per change

Actual Results

3 PR builds triggered

Anything else?

No response

sams-gleb avatar Dec 28 '21 10:12 sams-gleb

What version of the plugin are you using? I assume the latest? Does it help to add a quietPeriod?

lifeofguenter avatar Jan 03 '22 11:01 lifeofguenter

Version was the latest one 737.vdf9dc06105be, but as I remember we had similar issues previously as well... Also I was not able to reproduce it on the test instance, it happens only if we have a lot of PRs opened and one PR gets updates in the middle of main branch hook processing. Quiet period would decrease the number of unnesessary builds but given the log lines we have we might need a longer quiet period like e.g. 5 mins which doesn't make much sense

sams-gleb avatar Jan 10 '22 14:01 sams-gleb