0% completed
Write-through cache slim in potential failure explanation?
Marko Urh
Jul 11, 2024
I'm thinking about write-through cache:
Data Consistency: Provides strong consistency between the cache and the primary storage. No Data Loss on Crash: Since data is written to the primary storage, there’s no risk of data loss if the cache fails.
What if cache write fails, ok we have DB, maybe we can fill cache-miss, but what if DB fails. I have a problem now. I need to ensure atomicity of this parallel operation. To achieve transaction on two separate systems something like Two phase commit, it would be useful to maybe add some more sugar to this.If there's no mechanism like that successful cache write could be serving wrong data, while DB is trying to be written or ultimately fails, but then needs to rollback cache. Unless we ensure some transaction across these two with "simultaneous" also being true.
3
0
Comments
Sid D4 months ago
I think in practicality you update cache after db txn succeeds. Not really simultaneous.
Else an alternate approach can be
Invalidate cache entry
Update db
if txn success: update cache val
in all failure cases, cache will re-fetch data from db. This should be r...