Commit caae3ca1 authored by Leigh B Stoller's avatar Leigh B Stoller

Add new table called emulab_locks, which is a table of name,value

pairs. Used only by the pool daemon, to control concurrency between
the pool daemon and mapper.
parent 5b03dab6
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -69,6 +69,11 @@ DBQueryFatal("update experiments set event_sched_pid=0");
#
DBQueryFatal("delete from login");
#
# Clear the pool daemon lock.
#
DBQueryFatal("replace into emulab_locks set name='pool_daemon',value='0'");
#
# Check for experiments stuck in transition.
#
......
......@@ -463,6 +463,17 @@ CREATE TABLE `emulab_indicies` (
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `emulab_locks`
--
DROP TABLE IF EXISTS `emulab_locks`;
CREATE TABLE `emulab_locks` (
`name` varchar(64) NOT NULL default '',
`value` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `emulab_pubs`
--
......
......@@ -20,3 +20,4 @@ INSERT IGNORE INTO os_boot_cmd VALUES ('Linux','9.0','linkdelay','linkdelay');
INSERT IGNORE INTO emulab_indicies (name,idx) VALUES ('cur_log_seq', 1);
INSERT IGNORE INTO emulab_indicies (name,idx) VALUES ('next_osid', 10000);
INSERT IGNORE INTO emulab_locks (name,value) VALUES ('pool_daemon', 0);
#
# Add a locks table, for the pool_daemon.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
if (!DBTableExists("emulab_locks")) {
DBQueryFatal("CREATE TABLE `emulab_locks` ( ".
" `name` varchar(64) NOT NULL default '', ".
" `value` int(10) unsigned NOT NULL default '0', ".
" PRIMARY KEY (`name`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
DBQueryFatal("lock tables emulab_locks write");
my $query_result =
DBQueryFatal("select * from emulab_locks where name='pool_daemon'");
if (!$query_result->numrows) {
DBQueryFatal("insert into emulab_locks values ('pool_daemon', 0)");
}
DBQueryFatal("unlock tables");
return 0;
}
1;
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