Remove race condition (in TaskLog)

Delete all duplicate rows with same (task_name, host, period_beginning,
period_ending) expect one with the biggest value in `id` column.

Create UC on fields (task_name, host, period_beginning, period_ending)

Replace Select then Insert -> Try to Insert.

blueprint db-unique-keys

Change-Id: I99f45a6de6630482e9c56738f894cc55a37fffaf
This commit is contained in:
Boris Pavlovic
2013-01-25 07:16:37 +04:00
parent 9f2dc6a3ba
commit 8f35da317f

View File

@@ -1792,6 +1792,13 @@ class TaskLogTestCase(test.TestCase):
self.end, self.host)
self.assertEqual(result['task_name'], 'fake')
def test_task_log_begin_task_duplicate(self):
params = (self.context, 'fake', self.begin, self.end, self.host)
db.task_log_begin_task(*params, message=self.message)
self.assertRaises(exception.TaskAlreadyRunning,
db.task_log_begin_task,
*params, message=self.message)
def test_task_log_end_task(self):
errors = 1
db.task_log_end_task(self.context, self.task_name, self.begin,