Management service won't start due to management/server/migration.go trying to create duplicate index.
Describe the problem
Management service won't start due to managemnt/server/migration.go trying to create duplicate index.
I'm using MySQL as the storage engine.
I upgraded to v0.50.0, which went fine. I then restarted the management service and it errors out with:
Error: failed creating Store: /var/lib/netbird/: migratePostAuto: failed to create index idx_account_ip: Error 1061 (42000): Duplicate key name 'idx_account_ip'
Then it goes into a restart loop.
To Reproduce
Steps to reproduce the behavior:
- Upgrade to v0.50.0
- Restart the management service a few minutes after the upgrade is complete.
Expected behavior
I'd expect the management service to run, and not error out and enter a restart loop.
Are you using NetBird Cloud?
Self-hosted
NetBird version
v0.50.0 (can duplicate right up to v0.50.3)
Is any other VPN software installed?
No
Debug output
From the management service logs:
2025-07-14T12:48:06Z INFO [context: SYSTEM] management/server/migration/migration.go:407: executing index creation: CREATE UNIQUE INDEX idx_account_ip ON peers (account_id, ip(64)) Error: failed creating Store: /var/lib/netbird/: migratePostAuto: failed to create index idx_account_ip: Error 1061 (42000): Duplicate key name 'idx_account_ip'
Screenshots
N/A
Additional context
Seems the changes in commit 22678bc to management/server/migration.go have failed to consider that the index may already exist when the storage engine is MySQL.
If I custom compile the management service and comment out lines 402 to 412, I can get the management service to run successfully.
Have you tried these troubleshooting steps?
- [X] Reviewed client troubleshooting (if applicable)
- [X] Checked for newer NetBird versions
- [X] Searched for similar issues on GitHub (including closed ones)
- [X] Restarted the NetBird client
- [X] Disabled other VPN software
- [X] Checked firewall settings
Hi @jasonk1978, you are right, there is an issue on MySQL if the index already exists. I will fix this. Thanks for reporting!
@pascal-fischer I've confirmed this is now working.