Bug #4904

"onedb upgrade" and "onedb restore" do not correctly restore database

Added by Roy Keene over 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:11/07/2016
Priority:HighDue date:
Assignee:Jaime Melis% Done:

0%

Category:Core & System
Target version:Release 5.4
Resolution:fixed Pull request:
Affected Versions:OpenNebula 5.2

Description

Currently if "onedb upgrade" fails it attempts to restore the database:

root@aurae-dashboard:/var/lib/one# onedb upgrade --username oneadmin --password ee32fd38dc029f3cf7cab123f0fdad9341896652 --dbname 'opennebula'
MySQL dump stored in /var/lib/one/mysql_localhost_opennebula_2016-11-7_16:55:55.sql
Use 'onedb restore' or restore the DB using the mysql command:
mysql -u user -h server -P port db_name < backup_file

>>> Running migrators for shared tables
Database migrated from 4.11.80 to 5.2.0 (OpenNebula 5.2.0) by onedb command.

...
Do you want to proceed ? [y/N]y

Mysql::Error: Duplicate entry '0-0' for key 'PRIMARY'
...
The database will be restored
MySQL DB opennebula at localhost restored.
root@aurae-dashboard:/var/lib/one#

However, it does not faithfully restore this backup -- it leaves any new tables created by the attempted upgrade in place, causing future upgrades to fail:

root@aurae-dashboard:/var/lib/one# onedb upgrade --username oneadmin --password ee32fd38dc029f3cf7cab123f0fdad9341896652 --dbname 'opennebula'
MySQL dump stored in /var/lib/one/mysql_localhost_opennebula_2016-11-7_16:56:21.sql
Use 'onedb restore' or restore the DB using the mysql command:
mysql -u user -h server -P port db_name < backup_file

>>> Running migrators for shared tables

Mysql::Error: Table 'marketplace_pool' already exists
/lib/ruby/gems/2.3.0/gems/sequel-4.19.0/lib/sequel/adapters/mysql.rb:175:in `query'
/lib/ruby/gems/2.3.0/gems/sequel-4.19.0/lib/sequel/adapters/mysql.rb:175:in `block in _execute'

Attempting to restore the database with "onedb restore" fails in exactly the same way.

To workaround it I had to drop all the tables manually:

root@aurae-dashboard:/var/lib/one# echo 'DROP TABLE acl, cluster_datastore_relation, cluster_network_relation, cluster_pool, cluster_vnc_bitmap, datastore_pool, db_versioning, document_pool, group_pool, group_quotas, history, host_monitoring, host_pool, image_pool, local_db_versioning, marketplace_pool, marketplaceapp_pool, network_pool, network_vlan_bitmap, pool_control, secgroup_pool, system_attributes, template_pool, user_pool, user_quotas, vdc_pool, vm_import, vm_monitoring, vm_pool, vm_showback, vrouter_pool, zone_pool;' | mysql -u oneadmin --password=ee32fd38dc029f3cf7cab123f0fdad9341896652 -B opennebula
root@aurae-dashboard:/var/lib/one#

(NOTE: All passwords above are randomly generated on this test system, not leaks)


Related issues

Related to Bug #5225: onedb upgrade errors (migrator scripts) Closed 07/11/2017

Associated revisions

Revision 93404c2e
Added by Javi Fontan almost 4 years ago

B #4904: fix sqlite backups, drop tables

History

#1 Updated by Roy Keene over 4 years ago

This also happens with "onedb import-slave" if the import fails -- both databases are left broken to further attempts at importing.

#2 Updated by Ruben S. Montero over 4 years ago

  • Status changed from Pending to New
  • Priority changed from Normal to High
  • Target version set to Release 5.4

#3 Updated by Ruben S. Montero about 4 years ago

  • Assignee set to Javi Fontan

#4 Updated by Javi Fontan almost 4 years ago

  • Assignee changed from Javi Fontan to Jaime Melis

#5 Updated by Javi Fontan almost 4 years ago

  • Related to Bug #5225: onedb upgrade errors (migrator scripts) added

#6 Updated by Javi Fontan almost 4 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

Fixed in master.

Also available in: Atom PDF