ERROR 1062 (23000): Duplicate entry 'r1-n-m-api-nova-metadata-0' for key 'uniq_services0host0binary0deleted'
So the first suggested fix is to prepend 'nova-' to the name, and make both
queries ask for 'nova-metadata'. There's also a check that it doesn't start
with 'nova-', incase someone decides to prepend 'nova-' to the NAME= in the
wsgi-file. Which migth be a litte overkill, but just a safeguard none the less.
Change-Id: I58cf9a0115a98c78e5d2fb57c41c13ba6fac0fad
Closes-bug: 1715463
(cherry picked from commit 0b4a021e4224981e83dca67e7519458f9939f3cd)
Reviewed: https:/ /review. openstack. org/524531 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=2d79baf6a3c e4529ba61a5efde d7f043d89825a2
Committed: https:/
Submitter: Zuul
Branch: stable/pike
commit 2d79baf6a3ce452 9ba61a5efded7f0 43d89825a2
Author: Erik Berg <email address hidden>
Date: Wed Sep 6 18:38:29 2017 +0000
Fix binary name
Before an upgrade, we have these type of entries in the db.
MariaDB [nova]> SELECT id, host, `binary`, deleted, version FROM services; --+---- ------- ---+--- ------- ------- ---+--- ------+ ------- --+ --+---- ------- ---+--- ------- ------- ---+--- ------+ ------- --+
+--
| id | host | binary | deleted | version |
+--
| 5 | r1-n-os-api | nova-osapi_compute | 0 | 16 |
| 21 | r1-n-m-api | nova-metadata | 0 | 16 |
The wsgi files we run basically boil down to something like
NAME=metadata init_applicatio n(NAME)
return wsgi_app.
In the wsgi_app.py we see this function
service_ref = objects. Service. get_by_ host_and_ binary( ctxt, host, name)
Which results in a really big query, which again comes down to
SELECT host, `binary` FROM services
WHERE host = 'r1-n-m-api' AND `binary` == 'metadata'
No results. service_ref is set to None. Carry on.
if service_ref:
service_ obj.host = host
service_ obj.binary = 'nova-%s' % name
service_ obj.create( )
#Nope.
else:
try:
...
Which results in a INSERT statement something like this;
INSERT INTO services(host, `binary`, report_count, disabled, deleted, version)
VALUES ('r1-n-m-api', 'nova-metadata', 0, 0, 0, 22)
ERROR 1062 (23000): Duplicate entry 'r1-n-m- api-nova- metadata- 0' for key 'uniq_services0 host0binary0del eted'
So the first suggested fix is to prepend 'nova-' to the name, and make both
queries ask for 'nova-metadata'. There's also a check that it doesn't start
with 'nova-', incase someone decides to prepend 'nova-' to the NAME= in the
wsgi-file. Which migth be a litte overkill, but just a safeguard none the less.
Change-Id: I58cf9a0115a98c 78e5d2fb57c41c1 3ba6fac0fad e83dca67e751945 8f9939f3cd)
Closes-bug: 1715463
(cherry picked from commit 0b4a021e4224981