dotnet / dotnet/aspnetcore

SQL Server distributed cache backend should perform "slide" UPDATE lazily

Open
#55,109 7 comments 0 reactions 0 assignees View on GitHub
area-networking feature-caching
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Context: https://github.com/dotnet/aspnetcore/issues/47596#issuecomment-2051952109

Currently a blanket UPDATE is issued as part of fetch, causing blocking. This could potentially be deferred until we know we actually *have* sliding expiration (capturing the slide during the SELECT that we need to do *anyway*). Since sliding expiration is not universal, this may remove many conflicting UPDATE operations

We should also check the indexing on that table

Slight complication: we'd need to think about lock escalation / deadlocks; a read followed by an update risks the situation where two separate SPIDs get competing read locks (possibly row, possibly range page), allowing neither to take their write lock. Locking hints may be appropriate, and we should check the isolation level.

### Expected Behavior

Low conflicts accessing the cache table

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.