Until now, Open vSwitch "start" has always converted the database to the
current database schema. This compacts the database, which as a side
effect throws away useful information about the transactions that were
executed to bring the database into its current state. This can make
debugging database-related problems more difficult.
This commit changes the "start" command to only convert the database if
the database schema has changed. It also works a bit harder to give backup
files unique names: if there is already a backup file for a given database
version, it uses the database checksum instead.
I tested the xenserver version but not the Debian version.
---
debian/openvswitch-switch.init | 13 ++++++++-----
xenserver/etc_init.d_openvswitch | 15 ++++++++-------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init
index 60cc369..dd75e78 100755
--- a/debian/openvswitch-switch.init
+++ b/debian/openvswitch-switch.init
@@ -226,12 +226,15 @@ case "$1" in
if test ! -e $conf_file; then
# Create configuration database.
ovsdb-tool -vANY:console:emer create $conf_file $schema_file
- else
- # If schema version changed, then back up the old version.
- old_ver=`ovsdb-tool db-version "$conf_file"`
- if test "X$old_ver" != "X$schema_ver"; then
- cp "$conf_file" "$conf_file.backup$old_ver"
+ elif test "X`ovsdb-tool needs-conversion $conf_file $schema_file`" !=
Xno; then
+ # Back up the old version.
+ suffix=`ovsdb-tool db-version "$conf_file"`
+ backup=$conf_file.backup$suffix
+ if test -e "$backup"; then
+ suffix=`ovsdb-tool db-cksum "$conf_file" | awk '{print $1}'`
+ backup=$conf_file.backup$suffix
fi
+ cp "$conf_file" "$backup"
# Upgrade or downgrade schema and compact database.
ovsdb-tool -vANY:console:emer convert $conf_file $schema_file
diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch
index a9e51de..6bbbb50 100755
--- a/xenserver/etc_init.d_openvswitch
+++ b/xenserver/etc_init.d_openvswitch
@@ -389,14 +389,15 @@ function start {
action "Creating empty database $OVSDB_SERVER_DB" true
$ovsdb_tool -vANY:console:emer create "$OVSDB_SERVER_DB"
"$VSWITCHD_OVSDB_SCHEMA"
- else
- # If schema version changed, then back up the old version.
- oldver=`$ovsdb_tool db-version "$OVSDB_SERVER_DB"`
- if test "X$oldver" != "X$schemaver"; then
- backup=$OVSDB_SERVER_DB.backup$oldver
- action "Backing up $OVSDB_SERVER_DB in $backup before converting
from schema version \"$oldver\" to \"$schemaver\"" true
- cp "$OVSDB_SERVER_DB" "$backup"
+ elif test "X`$ovsdb_tool needs-conversion "$OVSDB_SERVER_DB"
"$VSWITCHD_OVSDB_SCHEMA"`" != Xno; then
+ # Back up the old version.
+ suffix=`$ovsdb_tool db-version "$OVSDB_SERVER_DB"`
+ backup=$OVSDB_SERVER_DB.backup$suffix
+ if test -e "$backup"; then
+ suffix=`$ovsdb_tool db-cksum "$OVSDB_SERVER_DB" | awk '{print $1}'`
+ backup=$OVSDB_SERVER_DB.backup$suffix
fi
+ cp "$OVSDB_SERVER_DB" "$backup"
# Upgrade or downgrade schema and compact database.
$ovsdb_tool -vANY:console:emer convert "$OVSDB_SERVER_DB"
"$VSWITCHD_OVSDB_SCHEMA"
--
1.7.1
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev_openvswitch.org