Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#31253 closed Bug (fixed)

Possible data loss when using caching from async code.

Reported by: Mariusz Felisiak Owned by: Jon Dufresne
Component: Core (Cache system) Version: 3.0
Severity: Release blocker Keywords: asgi async
Cc: Andrew Godwin, Carlton Gibson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

CacheHandler use threading.local instead of asgiref.local.Local, hence it's a chance of data corruption if someone tries to use caching from async code. There is a potential race condition if two coroutines touch the same cache object at exactly the same time.

Change History (4)

comment:1 Changed 8 months ago by Mariusz Felisiak

comment:2 Changed 8 months ago by Mariusz Felisiak

Needs documentation: unset
Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:3 Changed 8 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In e3f6e185:

Fixed #31253 -- Fixed data loss possibility when using caching from async code.

Case missed in a415ce70bef6d91036b00dd2c8544aed7aeeaaed.

comment:4 Changed 8 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 7540b7eb:

[3.0.x] Fixed #31253 -- Fixed data loss possibility when using caching from async code.

Case missed in a415ce70bef6d91036b00dd2c8544aed7aeeaaed.

Backport of e3f6e18513224c8ad081e5a19da641f49b0b43da from master

Note: See TracTickets for help on using tickets.
Back to Top