We got code, running on page load. That code asks certain SPList for its items by CamlQuery, which gets only items with specific (current) user in one field (field A) and with some value in other field (field B). Combination of those two field makes items unique.
So when there is no such item, we create new one.
If there is such item, we only update it.
So we dont want to have duplicate items with same values in fields A and B. And code which I described, works pretty well.
With one little exception - when user have more than one home page set on our SharePoint in his browser, every loading homepage executes this code at the same time. That means GetItems with caml query returns no item in both cases, so both requests creates same new item.
Questions are: Can we avoid this? How? Are there any logical errors in how we manipulate with items?