[LintDiff][PR Workflow] Handle cases where check result is too large to be processed by our infrastructure
- Dominant language
- C#
- Stars
- 135
- Forks
- 260
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 143
Description
TLDR:
- Tool is slow and doesn't run in parallel, so a lot of files with a lot of diffs is just slow
- Small change causes entire API version to be re-evaluated twice. See [here](https://github.com/Azure/azure-rest-api-specs/pull/28092#issuecomment-2003059205)
Dumping here some of my correspondences to provide context:
From email thread with subject `LINTDIFF big diff issue: Asking for help & info about issues with LintDiff runs that produce a large diff`
Email 1 from me:
> Hey Roopesh!
Some LintDiff runs produce large amount of data (and run for 25+ minutes). For example see [this log](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdev.azure.com%2Fazure-sdk%2Finternal%2F_build%2Fresults%3FbuildId%3D3340285%26view%3Dlogs%26j%3D0574a2a6-2d0a-5ec6-40e4-4c6e2f70bea2%26t%3D80c3e782-49f0-5d1c-70dd-cbee57bdd0c7&data=05%7C02%7Ckojamroz%40microsoft.com%7Cda534f85cfdd41a9998708dbfc2465df%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638381005489663509%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cuS3vwSCmZm05XncIKBtcH2Gd7NA0M2nVT5wRbBm%2B7w%3D&reserved=0) which is for [this check for PR 26992](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-rest-api-specs%2Fpull%2F26992%2Fchecks%3Fcheck_run_id%3D19613568566&data=05%7C02%7Ckojamroz%40microsoft.com%7Cda534f85cfdd41a9998708dbfc2465df%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638381005489671785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fve6OzT1xgMzKYvkDo74gbE2OTBHAJ8bOQFsCB867lg%3D&reserved=0)
Or [this one](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdev.azure.com%2Fazure-sdk%2Finternal%2F_build%2Fresults%3FbuildId%3D3336876%26view%3Dlogs%26j%3D688669d0-441c-57c3-cf6d-f89a22ccfa5d%26t%3Db91b1e88-b042-5e18-36d8-34e4fb3a9b3b&data=05%7C02%7Ckojamroz%40microsoft.com%7Cda534f85cfdd41a9998708dbfc2465df%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638381005489678354%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gF9tpFNz4bO4QwsvPxEtn5KjpvCVcjerwVdEVPL9AxE%3D&reserved=0), for Staging LintDiff, also for PR 26992.
>
> Unfortunately, due to our infrastructure drawbacks we cannot process such runs fully, and we have to discard such results, without ever showing them on GitHub. This is because we use MongoDB database to communicate from ADO to GitHub, and the massive amount of data is above [the 17 MB limit](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F60996826%2Fthe-value-of-offset-is-out-of-range-it-must-be-0-17825792%2F67571711%2367571711&data=05%7C02%7Ckojamroz%40microsoft.com%7Cda534f85cfdd41a9998708dbfc2465df%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638381005489685140%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5fVN9KRDapCk2fdoPx7gQmv5oCfUZx6hggQVIJ4KVJM%3D&reserved=0).
>
> Ask to you from us:
While we will be working on figuring out how to make such be fully supported on GitHub, can you please have a look if this is expected behavior? Maybe some of the LintDiff rules are triggering too often? Would possibly truncating the results be an option here?
Email 2:
> Hey, some additional info on what caused LintDiff to run for so long and produce so much data.
>
> Looking at the affected PR of 26992, it modified files [in 12 different API versions](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-rest-api-specs%2Fpull%2F26992%2Ffiles&data=05%7C02%7Ckojamroz%40microsoft.com%7Cda534f85cfdd41a9998708dbfc2465df%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638381005489653883%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=n8Rd%2Fe%2BcVtWeeu4B6JVc7Mb0bX0IGll2mqWPdKnrex4%3D&reserved=0). As a result, LintDiff ran 24 times: for each of the API version, once “before changes” and once “after changes”. LintDiff runs as a plugin to AutoRest, and AutoRest decides which files are in scope by looking at the API version tag in README. This resulted in large amount of files being ingested as input to these AutoRest/LintDiff runs, resulting in the huge log. The tooling doesn’t care about which files from given API versions were modified exactly: it runs twice on all files in given API version, even if only 1 file changed in it.
>
> The question is how we should handle such cases. There doesn’t seem to be much utility in producing this amount of errors, they won’t be too actionable to the PR author. LintDiff appears to be designed to work with PRs that modify no more than few API versions at a time.
Reply by Roopesh:
> We need to inspect what sort of changes are being made across multiple API versions given any contract change to previous API versions would result in a breaking change. This is not representative of a typical scenario for which PRs are raised.
>
> How frequently are you seeing this behavior? Also is there an impact beyond just the checks taking longer for that one PR? Or is it slowing checks for other PRs down as well - noisy neighbor?
Email 3 from me:
> Re frequency:
>
> I think we saw it, like, once 😃 in just one PR.
>
> With the hotfix from today now the impact on the rest of the system will be primarily delay: the “automated merging requirements met” check won’t conclude until all dependencies conclude, including LintDiff, which may run for 25+ minutes in such cases. Also, the GitHub LintDiff check view won’t reflect the information: if the log is too large, more than 17 MB, now we just discard it and never show the update on GitHub side (can be still viewed in ADO though).
Re:
> We need to inspect what sort of changes are being made across multiple API versions given any contract change to previous API versions would result in a breaking change. This is not representative of a typical scenario for which PRs are raised.
The changes have been approved by Mike K. because (info from private Teams group chat):
> If the REST API was incorrect -- it does not match the behavior of the service -- then we allow an existing API version (preview or GA) to be "corrected". And that might involve correcting many GA versions. Notes from the approval:
>
>> The property does not exist in the OpenAPI
>>
>> Just correcting the REST API definition.
>
> Approvals like these happen once every few months.
# Technical details
The affected PR:
- https://github.com/Azure/azure-rest-api-specs/pull/26992/files
Modified files in 12 API versions. As a result, the LintDiff check launched AutoRest with https://github.com/Azure/azure-openapi-validator extension 24 times: twice (`before` and `after` changes) for each API version, resulting in gigantic diff. The tool ran for [over 27 minutes](https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3340749&view=logs&j=0574a2a6-2d0a-5ec6-40e4-4c6e2f70bea2) and produced log 402 MB in size. The same problem happened for [staging LintDiff](https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3340750&view=logs&j=688669d0-441c-57c3-cf6d-f89a22ccfa5d&t=b91b1e88-b042-5e18-36d8-34e4fb3a9b3b).
This is the produced 402 MB log:
https://dev.azure.com/azure-sdk/590cfd2a-581c-4dcb-a12e-6568ce786175/_apis/build/builds/3336876/logs/20
# Hotfix applied
We put a `try/catch` block over putting things in database that continues on failure:
- https://devdiv.visualstudio.com/DevDiv/_git/openapi-alps/pullrequest/516527
The failure happened because the task result data was so big, it crossed the 17 MB threshold, as [explained in this Stack Overflow answer](https://stackoverflow.com/a/67571711/986533).
# How we found the root-cause
I queried pipeline-bot logs and observed the `RangeError [ERR_OUT_OF_RANGE]` in column having the `console.out` logs. Then I looked for relevant logs and found out we put too big of a document, which was crashing our pipeline-bot instances before we added the hotfix try/catch. This log pointed out to the name of the LintDiff check.
[Example occurrence of the ERR_OUT_OF_RANGE in logs](https://dataexplorer.azure.com/clusters/https%3a%2f%2fazsdkengsys.westus2.kusto.windows.net/databases/Pipelines?query=H4sIAAAAAAAEAJ1TbU%2fbMBD%2bXqn%2fweuXtloSJymlLxKTGGKIqdCqgPYxcpxragi25XMKSPvxc9qUZgM2aVIU2XfP3T3P3ZlScik3gFbkzAqZk8USiVSWWCPyHExl0kJDISQQU0qiJIliGg1oHMaDdotSMlPqoYIxSwjhKoMp6Z4vl8n87jaZf0uWp9cX5912ixclWjC97tpajVNKWQZBoXImWfFiBcdAKIplitwIbYWSSMc8hDCLQp%2fH2bF%2fFKdjP42yiQ%2bjaBCnx6tozAbUAKrScMiNKjVSk%2ftcScscX%2bMzrdHXRmXU%2fTYiA4P0UXCjUK1soDQYVlViTh2KfG2RPinzgJpxaBxN%2fpqxSljlm7BJ3O0HGbMsZQi9zr%2fAnX5wtrefau3OqAqYqRyTs1m79ZM8rcEAseIREktSsE8AkvRcAahsvarbfhS7rx8Eb61H%2ff4hyWuhi6ol18ylRLJmSDr7Sfqpsp1DgKPhEJ%2b2kMvrb3PiWDvE9APIYn5zSyiJw%2fADAGVaUNfUDWwB8GxBZmThok7InntSWp5YlRSKs6K30%2b2Rzt0NXTAuVoJ3Goqq0C%2bH2IPuAQkn06PRNJwEw3gSjsdh349CBP5%2fsZ%2bHdagybldI%2brKNzgB5Q4dT%2bh3dMzghmhmE5N5delv5%2fQaq3XKvgdzdnjlcrW5nejsdh3hvZDV%2bCZsa5E4C3br%2b5q59NalAumvtmcEGioarqO6172spX5i8wrzhf8S89v5wz8EqeQWILG9mf9xZDkqqJZ6XdgdJsNLvduceuPUN7JroOuhVffDeEent1Xlk999y9g70vD%2b4eI2if1v4t%2bvu%2b%2fh8PBCl9ofZeDha8XTI%2fY0c3cvOBwNvt34BiytUkB0FAAA%3d),
[Chart showing when the problem started](https://dataexplorer.azure.com/clusters/https%3a%2f%2fazsdkengsys.westus2.kusto.windows.net/databases/Pipelines?query=H4sIAAAAAAAEAK1VXW%2fbNhR9N%2bD%2fwOkl9iaJ%2fii6xFsHdG5adEhjw46xh2EQKOpGZiOTAi%2flzMN%2bfC8luVKTFn2ZHwyS99yvw3Mpztl7fQR0KhdO6ZytN8i0ccxZledg%2fVGpSiiUBmYrzYxm0xmfzvlsMpsPB5yz5V5YjxfSg1H9C0xpaUEgMHMEy5w6wHBQgGPoCHpHW%2faKZcKBt4wufKRoOoum04vxL8OBLCp0YEcXe%2bdKXHAuMogLkwstipNTEmNlOFYpSqtKp4xGfiknMMmmk0jOspfRi1l6GaXT7CqCn6fzWfryfnop5twCmspKyK2pSuQ2j6TRTlBjNhJliVFpTcbp76gysMgPSlqD5t7FpgQrfCZBNKDK9w75o7EPWAoJvaXNP0f0AX28K3E1uxjH1KxIiZBR8D1wMI6X5%2fPXZUlrNAXcmByT5c1w8B973IOFmtPEsd86Sp%2fZfu1sP82zzvw5%2fDtPxK0gMLK9QBacLzpKjQs6B0pOiB9qyPvbtytGtRJi8Q3IerW9Y5zNJpNvALgoFScqj1AD4B8HOmNr8upUkVROJs4khZGiGDUdhSzYbfmadHavZDD2vsbSVbH0VHtngLIXkFL%2bgSTXV6wUFiH5SJtRXce4hxoOGP12d0vCtWmao%2bc0EeJr3LX4DRxbEK0Uklq%2bMLe2tqhY07a13MARip6p8PvW9nulT0J%2fwLxnP2DeWv8kNTqjPwCiyPvRD81J14nX0KpyDSRB3z9d4keQLrLQkEgMhp6H8CtNhufuQtb81zWHXXnhk1rCXtIvlHcupBbC1uvTPxo0AIWS9YjR28F4hZZEUtIwqiMJgtMAahJN9ACpSHmhUpYpS8UbewpIA88Cb4TO4dpaMv11vdkkq91dsnqbbF7fvrv%2bu%2fboiK0dRmfpbwCrwi1NEZcUTNjmQRvXQq1l1PN8VG5PQ2MNPQJ4fQTtFsTqzhYLFjQLFoSsKr2md5pEC9m6TfMmXTAn8OENENNFbOustSi8r9yDfKgF0643lfZhA%2fbj90slVP0GB3F%2furb%2biBRulHajGvd%2facBHDruSw6bz7tIV0ucEDqU7jbZP8jb5ngR4NtaimWpLbbQfE%2bm%2fOJ8A1ZtlMroGAAA%3d), due to large size of document to be put to db:

Contributor guide
Assessment
This issue has not been assessed yet.