jdavidbakr / MultiServerEvent

Laravel plugin to allow scheduled events across multiple servers with the same scheduler to not overlap.
MIT License
37 stars 17 forks source link

Storage engine for mysql locking a table should be one of these (MyISAM, MEMORY or MERGE) #3

Closed tayyabhussain closed 8 years ago

tayyabhussain commented 8 years ago

Storage engine for mysql locking a table should be one of these (MyISAM, MEMORY or MERGE) as explained here mysql locking but in your table says it is innoDB

CREATE TABLE IF NOT EXISTS `multi_server_event` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `mutex` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `lock` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `complete` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `multi_server_event_mutex_unique` (`mutex`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
jdavidbakr commented 8 years ago

The table is not being locked, instead the logic inserts a random string into the lock column using 'where NULL' and then reads the row back to make sure the row was updated. In the case of a race condition only one process will actually change the row and therefore proceed with the event processing.