summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2004-09-05 09:41:33 +0000
committerivan <ivan>2004-09-05 09:41:33 +0000
commitc63c48cc357aecdd1a584e4102e7cfff74702229 (patch)
tree35e73a17292d4a5ed19b9f5dcbff25e5a43f3b38
parent47d18732ecb7f43fbed2c8f94226c509fe887a53 (diff)
acquire a database lock to prevent race conditions in duplicate checking
-rw-r--r--FS/FS/svc_acct.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index f935df50d..ded796ff7 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -247,6 +247,13 @@ sub insert {
#new duplicate username/username@domain/uid checking
+ #this is Pg-specific. what to do for mysql etc?
+ # ( mysql LOCK TABLES certainly isn't equivalent or useful here :/ )
+ warn "$me locking svc_acct table for duplicate search" if $DEBUG;
+ dbh->do("LOCK TABLE svc_acct IN SHARE ROW EXCLUSIVE MODE")
+ or die dbh->errstr;
+ warn "$me acquired svc_acct table lock for duplicate search" if $DEBUG;
+
my $part_svc = qsearchs('part_svc', { 'svcpart' => $self->svcpart } );
unless ( $part_svc ) {
$dbh->rollback if $oldAutoCommit;