Is the generation of invitation links secure against data races?

AI-generated summary

The discussion revolves around the security of invitation link generation in Discourse concerning data races. Willy raises concerns about potential issues when two users request invitation links simultaneously, fearing one or both might not receive them. pfaffman suggests the system is likely safe, citing confidence in Postgres and Rails handling such scenarios. Willy clarifies the concern involves a high volume of requests. tobiaseigen moves the topic to Development, noting it’s a developer-level question, and highlights that Discourse is widely used, implying its robustness in handling such cases.

I want to create invitation links every time a user submits a request, but if there is a data race in which two users request a Discourse invitation link at the same time, I am afraid that one or even both of them will not receive a link because Discourse may not know how to handle the data race. This is critical for me since they have paid to obtain it, and creating them in advance is not an option because that would complicate the project architecture too much.

I don’t think there should be any problems.

Even with a thousand (to exaggerate) requests at the same time?

Without looking at the code, yes. Between Postgres and Rails, I’m pretty sure they thought of race conditions. It’s not really a difficult or unexpected problem.

@willy did Jay answer your question to your satisfaction?

Well, he said without reading the code, so I left the question open in case anyone who read the code has something to say.

I am moving this topic to Development because it is a developer question.

I am not a developer myself but do know that Discourse is used by many thousands of sites with many millions of users, and I have never heard of any case where an invitation got lost. Discourse is a platform that is built for scale.