RFR: 1658: Minimize race window when updating PR body [v2]

Erik Joelsson erikj at openjdk.org
Tue Nov 29 22:32:26 UTC 2022


On Wed, 9 Nov 2022 00:30:51 GMT, Zhao Song <zsong at openjdk.org> wrote:

>> Currently, when the pr bot tries to update the PR body, users are also likely to update the PR body at the same time. Therefore, users' updates are likely to be overwritten by bot.  
>> 
>> This is a race between the bot and user and the race window is a little big right now.
>> 
>> To reduce the race window, in this patch, when PR bot is trying to update PR body, it will check whether the PR body has been modified by user. And if the PR bot has been modified, PR bot would not overwrite it.
>
> Zhao Song has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Added an automatic test for latestBody

bots/pr/src/main/java/org/openjdk/skara/bots/pr/CheckRun.java line 747:

> 745:         } else {
> 746:             log.info("PR body has been modified, won't update PR body this time");
> 747:             return description;

If we detect concurrent modification, we have to fail the WorkItem so that it gets scheduled for a retry. To make that happen, throw RuntimeException.

forge/src/main/java/org/openjdk/skara/forge/PullRequest.java line 252:

> 250:     }
> 251: 
> 252:     String latestBody();

I'm not sure of this method. We could just fetch a new `PullRequest` instance and read the body from that, and I don't think there is any real overhead in doing so.

-------------

PR: https://git.openjdk.org/skara/pull/1416


More information about the skara-dev mailing list