Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Submitted By: Stanislaw Pitucha (viraptor)
Assigned to: Nobody/Anonymous (nobody)
Summary: atomic registration handling
Here's a patch we've been using since ~1.3.X and ported until 1.6.X. It seems stable, although some of the functionality was ported by copy-pasting and might need a review (I did not know much about opensips when I wrote it!)
Basically it allows setting db_atomic=1 if you're already using realtime database and will eliminate a race condition when doing re-registration. During normal operation, it's possible that opensips does:
SELECT .... FROM location (checking existing ones)
DELETE FROM location WHERE (timer cleaning up the existing registration)
UPDATE location SET ... (trying to update registration that doesn't exist anymore)
We've had problems with people getting randomly deregistered and after patching we didn't get any more complaints. Using db_atomic=1 requires a database schema change. Depending on whether you use domains or not, you need:
UNIQUE KEY `registration_idx` (`username`,`contact`)
UNIQUE KEY `registration_idx` (`username`,`domain`,`contact`)
in the location table.