Added methods to create utilize a lock table for managing access to the database during a multi-threaded import. Currently, only MySQL is supported
This commit is contained in:
@@ -107,6 +107,15 @@ class Sql:
|
||||
elif db_server == 'sqlite':
|
||||
self.query['createSettingsTable'] = """CREATE TABLE Settings
|
||||
(version INTEGER NOT NULL) """
|
||||
|
||||
################################
|
||||
# Create InsertLock
|
||||
################################
|
||||
if db_server == 'mysql':
|
||||
self.query['createLockTable'] = """CREATE TABLE InsertLock (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||
locked BOOLEAN NOT NULL DEFAULT FALSE)
|
||||
ENGINE=INNODB"""
|
||||
|
||||
################################
|
||||
# Create RawHands (this table is all but identical with RawTourneys)
|
||||
@@ -4501,6 +4510,25 @@ class Sql:
|
||||
self.query['analyze'] = "analyze"
|
||||
elif db_server == 'sqlite':
|
||||
self.query['analyze'] = "analyze"
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['selectLock'] = """
|
||||
SELECT locked
|
||||
FROM InsertLock
|
||||
WHERE locked=True
|
||||
LOCK IN SHARE MODE"""
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['switchLock'] = """
|
||||
UPDATE InsertLock SET
|
||||
locked=%s
|
||||
WHERE id=%s"""
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['missedLock'] = """
|
||||
UPDATE InsertLock SET
|
||||
missed=missed+%s
|
||||
WHERE id=%s"""
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['lockForInsert'] = """
|
||||
|
||||
Reference in New Issue
Block a user