NuGet / NuGetGallery

NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
https://www.nuget.org/
Apache License 2.0
1.52k stars 643 forks source link

[Hotfix] Allow unrelated entity changes to be committed in PackageDeprecationService #9951

Closed joelverhagen closed 1 month ago

joelverhagen commented 1 month ago

Mitigation for https://github.com/NuGet/NuGetGallery/issues/9950 in the package deprecation path.

Hotfix justification: deprecation API calls that would otherwise no-op sometimes return HTTP 500. Since this is a private preview API, there is no data correctness impact, and non-no-op deprecations work just fine, we could choose to not do a hotfix. I would just to prefer to get this fixed ASAP to eliminate a source of HTTP 500s.

Currently, if a deprecation call no-ops all package version and the node handling the deprecation has a different download count cached for a package version than is what in the DB, an HTTP 500 occurs.

This is because the package entity has changes (per the issue referenced above) but the deprecation service does not detect any changes on the entity. IPackageUpdateService.UpdatePackagesAsync is called with an empty list and throws an argument exception which is causing the HTTP 500. We have seen this about 300 times on the deprecation API in the past week, all of which are first party packages or are related to https://github.com/DefinitelyTyped/NugetAutomation/issues/21.

This was not detected locally because storage-based statistics are not used. This was not detected on DEV or INT because the package used for testing had the same download count in DB and in the downloads.v1.json file therefore the DownloadCountObjectMaterializedInterceptor did not introduce any entity changes.