Whoops, looks like something went wrong. Check your librenms.log. lnms migrate not working

Hi

Got the the following prompt this morning:
Whoops, looks like something went wrong. Check your librenms.log.

su - librenms
$ ./validate.php

Component Version
LibreNMS 21.4.0
DB Schema 2020_12_14_091314_create_port_group_port_table (202)
PHP 7.4.13
Python 3.6.9
MySQL 10.5.9-MariaDB-1:10.5.9+maria~bionic
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

====================================

[OK] Composer Version: 2.0.12
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate
$ ./lnms migrate


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

Migrating: 2020_12_14_091314_create_port_groups_table

In Connection.php line 678:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(2
55) null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

In PDOStatement.php line 112:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

Can anyone please assist?

$ ./lnms migrate --pretend


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

CreatePortGroupsTable: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(255) null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’
CreatePortGroupsTable: alter table port_groups add unique port_groups_name_unique(name)
MigrateToUtf8mb4: ALTER SCHEMA librenms DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
MigrateToUtf8mb4: select TABLE_NAME from information_schema.tables where table_schema = ?
MigrateToUtf8mb4: select * from information_schema.columns where table_schema = ? and CHARACTER_SET_NAME is not null and COLLATION_NAME is not null and (CHARACTER_SET_NAME != ? or COLLATION_NAME != ?)
RenameTonerTable: rename table toner to printer_supplies

In SchemaException.php line 86:

There is no column with name ‘toner_id’ on table ‘printer_supplies’.

Hi,
same here did you find a solution?

No solution yet.

My monitoring is down at the moment :unamused:

RenameTonerTable: rename table toner to printer_supplies

I think this is what needs to happen but I dont know how to it.

[previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.printer_supplies’ doesn’t exist at /opt/librenms/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnecti
on.php:79)
[stacktrace]

This is is error im getting in my logs what does yours say?

I had the same issue today and I renamed the database table referenced in the log files. This is how I did it:

  • Backup your VM/database first!
  • Run “mysql -u librenms -p” and supply your DB password (found in config.php)
  • Select the database by running “use librenms”
  • Run the command “alter table toner rename to printer_supplies;”
  • LibreNMS GUI should now load again

Hope it helps!

3 Likes

Works like a charm

works for me too but is still get

====================================

Component Version
LibreNMS 21.4.0
DB Schema 2020_12_14_091314_create_port_group_port_table (202)
PHP 7.4.16
Python 3.6.9
MySQL 10.5.9-MariaDB-1:10.5.9+maria~bionic
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

====================================

[OK] Composer Version: 2.0.12
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate

With

[email protected]:/opt/librenms$ sudo -u librenms ./lnms migrate


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

Migrating: 2020_12_14_091314_create_port_groups_table

In Connection.php line 678:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar
(255) null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

In PDOStatement.php line 112:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

I had this problem because I had defined a custom VIEW in the database. This prevented the 2021_02_09_122930_migrate_to_utf8mb4 migration from working (SQLSTATE[HY000]: General error: 1347 ‘librenms.myview’ is not of type ‘BASE TABLE’) which blocked all the later migrations and led to this problem. Removing the view allowed the migration to work.

I only saw this when running lnms migrate in real mode (–pretend showed different errors similar to what others are seeing that is not the root cause).

Works for me to but now I get same error
sudo -u librenms ./lnms migrate


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

Migrating: 2020_12_14_091314_create_port_groups_table

In Connection.php line 678:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(2
55) null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

In PDOStatement.php line 112:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

must I

drop table port_groups;

So that it can be recreated?

Yep @NotARobot.

Thanks

Did the above

Now getting this error

Migrating: 2020_12_14_091314_create_port_groups_table
Migrated: 2020_12_14_091314_create_port_groups_table (42.13ms)
Migrating: 2021_02_09_122930_migrate_to_utf8mb4
Migrated: 2021_02_09_122930_migrate_to_utf8mb4 (21,880.10ms)
Migrating: 2021_03_11_003540_rename_toner_table

In Connection.php line 678:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.toner’ doesn’t exist (SQL: rename table toner to printer_supplies)

In Exception.php line 18:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.toner’ doesn’t exist

In PDOStatement.php line 112:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.toner’ doesn’t exist

Thanks

Currently unable to use librenms " Whoops, looks like something went wrong. Check your librenms.log."

Found similar error in my librenms.log:

Error in printer-supplies module. SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.printer_supplies’ doesn’t exist (SQL: select * from printer_supplies where printer_supplies.device_id = 85 and printer_supplies.device_id is not null)

git fetch --tags && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
HEAD is now at 5f7682d4f Bump version to 21.4.0

and ./daily.sh execute without issue.

Running sudo -u librenms ./lnms migrate does not fix the issue, states ‘port_groups’ already exists, etc.

Thanks!

Thanks to @danetmxr, I can confirm his solution fixes this issue.

  • Run “mysql -u librenms -p” and supply your DB password (found in config.php)
  • Select the database by running “use librenms”
  • Run the command “alter table toner rename to printer_supplies;”
  • LibreNMS GUI should now load again