When a pull request is being created, there is a 'uniqueness' check performed to make sure that there are no existing pull requests with the exact same from and to refs.
If there is already an existing pull request with the same refs, then the pull request creation is rejected with an error message "Only one pull request may be open for a given source and target branch".
However, if multiple requests are performed at the exact same time with the same refs, it is possible for the uniqueness check to pass (there are no existing pull requests with these refs) and then more than one request gets inserted into the database (the uniqueness is not enforced in the db).
Any subsequent attempt to create a pull request with the same refs will not return the above error message, but instead will return a 500 error code, "query did not return a unique result: 2" (this error is because the uniqueness check assumes there will never be more than 1 entry - but in the scenario just described it is possible to have more than 1 entry).
There is no workaround necessary