The problem would occur when the `ForkedProjectLink` was deleted, but
the `ForkNetworkMember` was not. The delete would be rolled back and
retried.
But the error would not be saved because `Project#forked?`
would still be true, because the `ForkNetworkMember` exists. But the
`Project#forked_project_link` would be `nil`. So the validation for
the visibility level would fail.
The number of forks of a project doesn't change very frequently and
running a COUNT(*) every time this information is requested can be quite
expensive. We also end up running such a COUNT(*) query at least twice
on the homepage of a project.
By caching this data and refreshing it when necessary we can reduce
project homepage loading times by around 60 milliseconds (based on the
timings of https://gitlab.com/gitlab-org/gitlab-ce).