Store Promise<Response> instead of Response for HTTP API transactions
This fixes a race whereby: - User hits an endpoint. - No cached transaction so executes main code. - User hits same endpoint. - No cache transaction so executes main code. - Main code finishes executing and caches response and returns. - Main code finishes executing and caches response and returns. This race is common in the wild when Synapse is struggling under load. This commit fixes the race by: - User hits an endpoint. - Caches the promise to execute the main code and executes main code. - User hits same endpoint. - Yields on the same promise as the first request. - Main code finishes executing and returns, unblocking both requests.
Showing
- synapse/rest/client/v1/base.py 2 additions, 2 deletionssynapse/rest/client/v1/base.py
- synapse/rest/client/v1/room.py 39 additions, 43 deletionssynapse/rest/client/v1/room.py
- synapse/rest/client/v1/transactions.py 15 additions, 37 deletionssynapse/rest/client/v1/transactions.py
- synapse/rest/client/v2_alpha/sendtodevice.py 12 additions, 6 deletionssynapse/rest/client/v2_alpha/sendtodevice.py
Loading
Please register or sign in to comment