Hi Eugen:

In Neutron we don't support contract operations since Newton.

If you are in Victoria and you correctly finished the DB migration, your HEADs should be:
* contract: 5c85685d616d (from Newton)
* expand: I38991de2b4 (from the last DB change in Victoria, source_and_destination_ip_prefix_neutron_metering_rule)

Please check what you have in the DB table neutron.alembic_version. The first register should be the expand number, the second the contract one. If not, update them with the ones I've provided. Before executing the migration tool again, be sure the DB schema matches the latest migration patch for your version. You can deploy a VM with devstack and run this version.

Regards.


On Fri, Nov 25, 2022 at 1:58 PM Eugen Block <eblock@nde.ag> wrote:
Hi *,

I'd like to ask you for advice on how to clean up my neutron db. At 
some point (which I don't know exactly, probably train) my neutron 
database got inconsistent, apparently one of the upgrades did not go 
as planned. The interesting thing is that the database still works, I 
just upgraded from ussuri to victoria where that issue popped up again 
during 'neutron-db-manage upgrade --expand', I'll add the information 
at the end of this email. Apparently, I have multiple heads, and one 
of them is from train, it seems as if I never ran --contract (or it 
failed and I didn't notice).
Just some additional information what I did with this database: this 
cloud started out as a test environment with a single control node and 
then became a production environment. About two and a half years ago 
we decided to reinstall this cloud with version ussuri and import the 
databases. I had a virtual machine in which I upgraded the database 
dump from production to the latest versions at that time. That all 
worked quite well, I only didn't notice that something was missing. 
Now that I finished the U --> V upgrade I want to fix this 
inconsistency, I just have no idea how to do it. As I'm not sure how 
all the neutron-db-manage commands work exactly I'd like to ask for 
some guidance. For example, could the "stamp" command possibly help? 
Or how else can I get rid of the train head and/or how to get the 
train revision to "contract" so I can finish the upgrade and contract 
the victoria revision? I can paste the whole neutron-db history if 
necessary (neutron-db-manage history), please let me know what 
information would be required to get to the bottom of this.
Any help is greatly appreciated!

Thanks!
Eugen


---snip---
controller01:~ # neutron-db-manage upgrade --expand
[...]
alembic.script.revision.MultipleHeads: Multiple heads are present for 
given argument 'expand@head'; 633d74ebbc4b, I38991de2b4

controller01:~ # neutron-db-manage current --verbose
   Running current for neutron ...
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Current revision(s) for mysql+pymysql://neutron:XXXXX@controller.fqdn/neutron:
Rev: bebe95aae4d4 (head)
Parent: b5344a66e818
Branch names: contract
Path: 
/usr/lib/python3.6/site-packages/neutron/db/migration/alembic_migrations/versions/ussuri/contract/bebe95aae4d4_.py

Rev: 633d74ebbc4b (head)
Parent: 6c9eb0469914
Branch names: expand
Path: 
/usr/lib/python3.6/site-packages/neutron/db/migration/alembic_migrations/versions/train/expand/633d74ebbc4b_.py

Rev: I38991de2b4 (head)
Parent: 49d8622c5221
Branch names: expand
Path: 
/usr/lib/python3.6/site-packages/neutron/db/migration/alembic_migrations/versions/victoria/expand/I38991de2b4_source_and_destination_ip_prefix_neutron_metering_rule.py

   OK
---snip---