Potential Inconsistency from `resetInterfaceStore` with Stale Artifacts
Opened this issue · 1 comments
When resetInterfaceStore is invoked, there is no session restart after resetting the GHC artifact’s GetModificationTime.
As a result, two different versions of the same artifact may be used within the same session:
- The version loaded before
resetInterfaceStore, version A. - The version loaded after
resetInterfaceStore, version B.
This mismatch could potentially lead to inconsistencies or incorrect behavior, since the our build system may simultaneously rely on outdated and updated artifacts.
But there is no easy way to workaround this. The main point is that the rule GetModificationTime is seperated from the caller rule of resetInterfaceStore. The caller rule of resetInterfaceStore actually have much left to do. And we can not restart session here, otherwise the caller rule would end up in a loop since resetInterfaceStore would just be called again and we need to restart session again. Further, doing one session restart per GHC artifact is also not a workable choice:(
In particular see
isDirty :: Foldable t => Result -> t (a, Result) -> Bool
isDirty me = any (\(_,dep) -> resultBuilt me < resultChanged dep)
and
compute db stack key RunDependenciesSame (Just result)
Here, version B may report the same resultChanged timestamp as it's dependent's resultBuild timestamp that use version A.
As a result, refreshDepsdoes not detect the artifact has changed, and rules that depend on Version A may be cut off early, even though Version B is already present and should be used.
Rule GetFileHash might suffer from it since GetModificationTime is its only dep.