Commit b36cb698 authored by Leigh Stoller's avatar Leigh Stoller

Check for existing dataset (same pid/id) while we have the lock.

parent 4603e0dd
......@@ -182,6 +182,8 @@ sub Refresh($)
sub Create($$)
{
my ($class, $argref) = @_;
my $pid = $argref->{'pid'};
my $id = $argref->{'dataset_id'};
my $uuid;
if (exists($argref->{'uuid'})) {
......@@ -208,6 +210,16 @@ sub Create($$)
return undef;
}
$query_result =
DBQueryWarn("select uuid from apt_datasets ".
"where pid='$pid' and dataset_id='$id'");
if ($query_result->numrows) {
DBQueryWarn("unlock tables");
tberror("Dataset $pid/$id already exists!");
return undef;
}
my $query = "insert into apt_datasets set ".
" locked=now(),locker_pid='$PID', ".
" idx='$idx',created=now(),uuid='$uuid', ".
......
......@@ -339,7 +339,7 @@ sub DoCreate()
my $dataset = APT_Dataset->Create($blob);
if (!defined($dataset)) {
fatal("Internal error creating dataset object");
fatal("Error creating dataset object");
}
# new dataset is returned locked. If we have instance, try to lock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment