Counter updates with high concurrency?

I would appreciate feedback on my approach to dealing with a potential for overlapping counter updates.

I came up with two ideas -

I’m concerned that in the time between putting the counter value into a variable and updating the counter, another process could have grabbed the same value, resulting in duplication.

Tim

Could you please describe in plain English what you’re trying to accomplish? Don’t describe the implementation, but rather describe the end result.

Hi @mark-piller

  • Correctly track and increment the next Microstore Id in the counter
  • Ensure two DB records don’t end up with the same Microstore Id

Tim

How about using this whenever you need a new counter value?
UI Builder - ConsoleDemo - Backendless 2023-07-21 13-30-07

Oh :man_facepalming:

I didn’t realize you could increment the counter and get the value. I feel really stupid right now.

I should have looked closer at the block. Sorry to waste your time.

Tim

No worries, that’s what support is for.

Regards,
Mark

1 Like