I’m noticing some failures in my executions and I believe I’ve traced it back to a difficult issue.
My flow is getting a webhook for a new contact in hubspot. The purpose is to update some properties on that contact with n8n. I have no problem with n8n and hubspot. The issue is that one of the properties is a unique code stored in our database. So in my flow, after the webhook, I run a postgres query to get a code that hasn’t been issued yet (based on there being no
date_used column value).
But I what think is happening is that when multiple webhooks come in at the same time, this DB query is running in two (or more) executions at once and returning the same unique code and saving that to a contact, which we don’t want.
Is there a way to space out the executions such that one needs to complete before the next one in the queue happens? Right now my query to get the code just grabs the one with the highest ID that isn’t used, but I could make this random, but there still could be collisions.
Any thoughts on how to approach this?