After the last mailcow update I only get the message 502 Bad Gateway from the webserver.
The container mailcow/phpfpm:1.23 is always restarting.
If I want to open the UI, the server calls the /web/inc/init_db.inc.php script and following error occurs:
Waiting for SQL...
php-fpm-mailcow_1 | Uptime: 1 Threads: 8 Questions: 1 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 1.000
php-fpm-mailcow_1 | Running DB init...
php-fpm-mailcow_1 |
php-fpm-mailcow_1 | Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mailcow._sogo_static_view' doesn't exist in /web/inc/init_db.inc.php:1023
php-fpm-mailcow_1 | Stack trace:
php-fpm-mailcow_1 | #0 /web/inc/init_db.inc.php(1023): PDO->query('REPLACE INTO _s...')
php-fpm-mailcow_1 | #1 {main}
php-fpm-mailcow_1 | thrown in /web/inc/init_db.inc.php on line 1023
php-fpm-mailcow_1 | Uptime: 4 Threads: 9 Questions: 22 Slow queries: 0 Opens: 21 Flush tables: 1 Open tables: 15 Queries per second avg: 5.500
php-fpm-mailcow_1 | Running DB init...
I think there is a relation to this commit: https://github.com/mailcow/mailcow-dockerized/commit/3094dd3822db3ceb22619d66520b4f0012f4d9ce
So I can't initialize the database correctly and sogo is waiting for the database initialization:
sogo-mailcow_1 | Waiting for database initialization...
Do you use an external SQL or any other changes?
Because...
$stmt = $pdo->query("SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'sogo_view'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results != 0) {
$stmt = $pdo->query("REPLACE INTO _sogo_static_view SELECT * from sogo_view");
$stmt = $pdo->query("DELETE FROM _sogo_static_view WHERE `c_uid` NOT IN (SELECT `username` FROM `mailbox` WHERE `active` = '1');");
}
...it would not run REPLACE INTO when sogo_view is non-existent. Iirc some SQL servers would return non-empty results for the above query. But we don't:
MariaDB [mailcow]> SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'asdasd';
Empty set (0.01 sec)
No, I use the docker mariadb image.
I comment out the lines and now the database is initialized and everything is working.
But maybe other users get this problem, too.
The mailcow installation was very old and the last update was 8 months ago.
It does not return non-empty results for this query when the view does not exist. Don't know why this happened. I just tried a clean installation, too, just to be sure. It returns an empty result here.
Not sure what happened here, but whoever runs into this: let us know or keep a backup to reproduce. :-)
Not sure what happened here, but whoever runs into this too, let us know.
Ok, thank you for your help.
..it would not run REPLACE INTO when sogo_view is non-existent.
The table sogo_view exists but the new table _sogo_static_view doesn't exists.
Ah! I misread that. :-) You are right. When you didn鈥檛 update in a longer time, that can happen! I will fix it when I鈥檓 home.
Happened to me too. After the upgrade i cant login and the error: occures:
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mailcow._sogo_static_view' doesn't exist in /web/inc/init_db.inc.php:1023
Stack trace:
thrown in /web/inc/init_db.inc.php on line 1023
mail is coming in and imap is working. just seems that the webmail is not working at all.
Most helpful comment
Ah! I misread that. :-) You are right. When you didn鈥檛 update in a longer time, that can happen! I will fix it when I鈥檓 home.