supertokens / supertokens-core

Open source alternative to Auth0 / Firebase Auth / AWS Cognito
https://supertokens.com
Other
13.17k stars 523 forks source link

How can we have distributed locks so that NoSQL databases can have login functionality? #91

Open rishabhpoddar opened 4 years ago

rishabhpoddar commented 4 years ago

❓ Questions and Help

This issue is related to: https://github.com/supertokens/supertokens-plugin-interface/issues/3

rishabhpoddar commented 3 years ago

Essentially locking can be achieved by consensus across cores. We can achieve consensus by having an ordered queue in the database (using ordered UUIDs). Core1 would insert some UUID, Core2 would insert something else. They both would read both the UUIDs, and order them, and if Core1's UUID is "first", then Core1 knows it is the winner.