Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Could I use a single schema instance on concurrent request? #783
Funny you ask because that very same day we've been facing issues that look quite like concurrency issues.
We use marshmallow + webargs and we pass webargs's
Some requests receive an error message that obviously corresponds to another request that occurred concurrently.
This does not occur when passing a schema class.
We're investigating this. The root cause could be the fact that the
#: Callable unmarshalling object self._unmarshal = marshalling.Unmarshaller()
(same issue with
I've checked in webargs code and it is meant to receive either a class or an instance, so this looks like a bug.
If this is really the case, then it is a serious show-stopper.
I'm not sure how to isolate/reproduce/fix/test. Help very much welcome.
And if I'm wrong, well... great, what a relief, sorry for the noise.
From a quick analysis, I think the consequences are "limited" to spurious error messages.
Take the following with care, I have no certainty at this point:
So you'd have false positives, but no false negatives.
This would mitigate the issue a bit.
This was referenced
Apr 26, 2018
It should be noted that this happens only if two concurrent requests occur and one of them fails validation. In the case of a loaded server, as long as all requests are valid, there is no problem.
Also, we managed to see and reproduce this because we're using marshmallow to parse pretty fat inputs. In the general case of normal size inputs, the race condition is much less likely to occur.