Allow archiving deleted rows to shadow tables, for performance.

Implements bp db-archiving

Add versions of all tables with "shadow_" prepended to their names.
These shadow tables do not have indexes.

Adds API function archive_deleted_rows, which moves some deleted
rows from production tables to the corresponding shadow tables.
(It only does a few rows, to avoid blocking the process or hitting
the database too hard.  So it needs to be called regularly.)

Also adds a db archive_deleted_rows command to nova-manage.

Uses Boris Pavlovic's code for copying columns from existing tables
to new tables.

Change-Id: I7c8f2fb8794b6f9cd2531e54a1a9635010f8c97e
This commit is contained in:
David Ripton
2012-12-13 16:10:57 -05:00
parent a606c497bd
commit c41e7c9980
3 changed files with 218 additions and 0 deletions

View File

@@ -771,6 +771,17 @@ class DbCommands(object):
"""Print the current database version."""
print migration.db_version()
@args('--max_rows', dest='max_rows', metavar='<number>',
help='Maximum number of deleted rows to archive')
def archive_deleted_rows(self, max_rows=None):
"""Move up to max_rows deleted rows from production tables to shadow
tables.
"""
if max_rows is not None:
max_rows = int(max_rows)
admin_context = context.get_admin_context()
db.archive_deleted_rows(admin_context, max_rows)
class InstanceTypeCommands(object):
"""Class for managing instance types / flavors."""