Commit ae7e18a2 authored by Julien Muchembled's avatar Julien Muchembled

mysql: drop support for horizontal partitioning of trans/obj

It has never been enabled and the code to drop partitions will be changed in
a way that only 'trans' may still benefit of partitioning. We'll see in the
future if we have cases where 'trans' is too big to delete all rows (of a
given partition) in a single query.
parent 16682553
...@@ -20,9 +20,6 @@ from MySQLdb import DataError, IntegrityError, \ ...@@ -20,9 +20,6 @@ from MySQLdb import DataError, IntegrityError, \
OperationalError, ProgrammingError OperationalError, ProgrammingError
from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
from MySQLdb.constants.ER import DATA_TOO_LONG, DUP_ENTRY, NO_SUCH_TABLE from MySQLdb.constants.ER import DATA_TOO_LONG, DUP_ENTRY, NO_SUCH_TABLE
# BBB: the following 2 constants were added to mysqlclient 1.3.8
DROP_LAST_PARTITION = 1508
SAME_NAME_PARTITION = 1517
from array import array from array import array
from hashlib import sha1 from hashlib import sha1
import os import os
...@@ -53,8 +50,6 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -53,8 +50,6 @@ class MySQLDatabaseManager(DatabaseManager):
ENGINES = "InnoDB", "RocksDB", "TokuDB" ENGINES = "InnoDB", "RocksDB", "TokuDB"
_engine = ENGINES[0] # default engine _engine = ENGINES[0] # default engine
_use_partition = False
_max_allowed_packet = 32769 * 1024 _max_allowed_packet = 32769 * 1024
def _parse(self, database): def _parse(self, database):
...@@ -201,10 +196,6 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -201,10 +196,6 @@ class MySQLDatabaseManager(DatabaseManager):
PRIMARY KEY (rid, nid) PRIMARY KEY (rid, nid)
) ENGINE=""" + engine) ) ENGINE=""" + engine)
if self._use_partition:
p += """ PARTITION BY LIST (`partition`) (
PARTITION dummy VALUES IN (NULL))"""
# The table "trans" stores information on committed transactions. # The table "trans" stores information on committed transactions.
q("""CREATE TABLE IF NOT EXISTS trans ( q("""CREATE TABLE IF NOT EXISTS trans (
`partition` SMALLINT UNSIGNED NOT NULL, `partition` SMALLINT UNSIGNED NOT NULL,
...@@ -413,16 +404,6 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -413,16 +404,6 @@ class MySQLDatabaseManager(DatabaseManager):
q("INSERT INTO pt VALUES (%d, %d, %d)" q("INSERT INTO pt VALUES (%d, %d, %d)"
" ON DUPLICATE KEY UPDATE state = %d" " ON DUPLICATE KEY UPDATE state = %d"
% (offset, nid, state, state)) % (offset, nid, state, state))
if self._use_partition:
for offset in offset_list:
add = """ALTER TABLE %%s ADD PARTITION (
PARTITION p%u VALUES IN (%u))""" % (offset, offset)
for table in 'trans', 'obj':
try:
self.conn.query(add % table)
except OperationalError as e:
if e.args[0] != SAME_NAME_PARTITION:
raise
def dropPartitions(self, offset_list): def dropPartitions(self, offset_list):
q = self.query q = self.query
...@@ -434,19 +415,9 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -434,19 +415,9 @@ class MySQLDatabaseManager(DatabaseManager):
data_id_list = [x for x, in data_id_list = [x for x, in
q("SELECT DISTINCT data_id FROM obj USE INDEX(PRIMARY)" + where) q("SELECT DISTINCT data_id FROM obj USE INDEX(PRIMARY)" + where)
if x] if x]
if not self._use_partition:
q("DELETE FROM obj" + where) q("DELETE FROM obj" + where)
q("DELETE FROM trans" + where) q("DELETE FROM trans" + where)
self._pruneData(data_id_list) self._pruneData(data_id_list)
if self._use_partition:
drop = "ALTER TABLE %s DROP PARTITION" + \
','.join(' p%u' % i for i in offset_list)
for table in 'trans', 'obj':
try:
self.conn.query(drop % table)
except OperationalError as e:
if e.args[0] != DROP_LAST_PARTITION:
raise
def _getUnfinishedDataIdList(self): def _getUnfinishedDataIdList(self):
return [x for x, in self.query("SELECT data_id FROM tobj") if x] return [x for x, in self.query("SELECT data_id FROM tobj") if x]
......
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