Opened 5 years ago

Closed 5 years ago

Last modified 5 years 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 by Mariusz Felisiak, 5 years ago

comment:2 by Mariusz Felisiak, 5 years ago

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

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In e3f6e185:

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

Case missed in a415ce70bef6d91036b00dd2c8544aed7aeeaaed.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

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