nova-manage db sync fails with MemoryError if large number passed as 'version'

Bug #1550138 reported by Dinesh Bhor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sqlalchemy-migrate
In Progress
Undecided
Dinesh Bhor

Bug Description

nova-manage db sync fails with MemoryError if large number passed as 'version'

Command:
$ nova-manage db sync 2147483646

LOG:

2016-02-25 10:25:11.100 CRITICAL nova [-] MemoryError

2016-02-25 10:25:11.100 TRACE nova Traceback (most recent call last):
2016-02-25 10:25:11.100 TRACE nova File "/usr/local/bin/nova-manage", line 10, in <module>
2016-02-25 10:25:11.100 TRACE nova sys.exit(main())
2016-02-25 10:25:11.100 TRACE nova File "/opt/stack/nova/nova/cmd/manage.py", line 1481, in main
2016-02-25 10:25:11.100 TRACE nova ret = fn(*fn_args, **fn_kwargs)
2016-02-25 10:25:11.100 TRACE nova File "/opt/stack/nova/nova/cmd/manage.py", line 934, in sync
2016-02-25 10:25:11.100 TRACE nova return migration.db_sync(version)
2016-02-25 10:25:11.100 TRACE nova File "/opt/stack/nova/nova/db/migration.py", line 26, in db_sync
2016-02-25 10:25:11.100 TRACE nova return IMPL.db_sync(version=version, database=database)
2016-02-25 10:25:11.100 TRACE nova File "/opt/stack/nova/nova/db/sqlalchemy/migration.py", line 57, in db_sync
2016-02-25 10:25:11.100 TRACE nova version)
2016-02-25 10:25:11.100 TRACE nova File "/usr/local/lib/python2.7/dist-packages/migrate/versioning/api.py", line 186, in upgrade
2016-02-25 10:25:11.100 TRACE nova return _migrate(url, repository, version, upgrade=True, err=err, **opts)
2016-02-25 10:25:11.100 TRACE nova File "<decorator-gen-15>", line 2, in _migrate
2016-02-25 10:25:11.100 TRACE nova File "/usr/local/lib/python2.7/dist-packages/migrate/versioning/util/__init__.py", line 160, in with_engine
2016-02-25 10:25:11.100 TRACE nova return f(*a, **kw)
2016-02-25 10:25:11.100 TRACE nova File "/usr/local/lib/python2.7/dist-packages/migrate/versioning/api.py", line 345, in _migrate
2016-02-25 10:25:11.100 TRACE nova changeset = schema.changeset(version)
2016-02-25 10:25:11.100 TRACE nova File "/usr/local/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 82, in changeset
2016-02-25 10:25:11.100 TRACE nova changeset = self.repository.changeset(database, start_ver, version)
2016-02-25 10:25:11.100 TRACE nova File "/usr/local/lib/python2.7/dist-packages/migrate/versioning/repository.py", line 224, in changeset
2016-02-25 10:25:11.100 TRACE nova versions = range(int(start) + range_mod, int(end) + range_mod, step)
2016-02-25 10:25:11.100 TRACE nova MemoryError
2016-02-25 10:25:11.100 TRACE nova

This is because in changeset() method of /migrate/versioning/repository.py [1] inbuilt range() method is
used which generates a list of integers [2] all at once in memory causing MemoryError.
This issue is also there in cinder, glance and keystone as well.

[1] https://github.com/openstack/sqlalchemy-migrate/blob/master/migrate/versioning/repository.py#L224
[2] https://docs.python.org/2/library/functions.html#range

Changed in sqlalchemy-migrate:
assignee: nobody → Dinesh Bhor (dinesh-bhor)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to sqlalchemy-migrate (master)

Fix proposed to branch: master
Review: https://review.openstack.org/286389

Changed in sqlalchemy-migrate:
status: New → In Progress
Revision history for this message
Sean Dague (sdague) wrote :

I don't think this is valid bug, this is just a "don't do that" kind of issue

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on sqlalchemy-migrate (master)

Change abandoned by Sean Dague (<email address hidden>) on branch: master
Review: https://review.openstack.org/286389

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.