Mail: Can't recreate account (mailbox sql viloation)

Created on 1 Sep 2019  路  6Comments  路  Source: nextcloud/mail

Expected behavior

After updating to 0.16.0, most of my accounts were broken (exclamation mark) without error.
When recreating one (delete then add new), client do back to main view but account isn't visible (even after hard refresh)

Logs contains an SQL error on oc_mail_mailboxes

[mail] Error: Doctrine\DBAL\Exception\NotNullConstraintViolationException: An exception occurred while executing 'INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(?, ?, ?, ?, ?, ?, ?)' with params ["dovecot", 16, "[\"\\\\nonexistent\",\"\\\\noselect\"]", ".", 0, 0, false]:

SQLSTATE[HY000]: General error: 1364 Field 'sync_token' doesn't have a default value at <<closure>>

 0. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 184
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... e", Doctrine\DBAL\Dr ... ]})
 1. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 158
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... e")
 2. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1088
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "INSERT INTO `oc ... )", {1: "dovecot",2: ... e})
 3. /var/www/html/lib/private/DB/Connection.php line 216
    Doctrine\DBAL\Connection->executeUpdate("INSERT INTO `oc ... )", ["dovecot",16,"[ ... e], [2,1,2,2,1,1,5])
 4. /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 222
    OC\DB\Connection->executeUpdate("INSERT INTO `oc ... )", {dcValue1: "dove ... e}, {dcValue1: 2,dcV ... 5})
 5. /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php line 214
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/html/lib/public/AppFramework/Db/QBMapper.php line 121
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/html/apps/mail/lib/IMAP/MailboxSync.php line 136
    OCP\AppFramework\Db\QBMapper->insert(OCA\Mail\Db\Mailbox {id: "dovecot"})
 8. /var/www/html/apps/mail/lib/IMAP/MailboxSync.php line 99
    OCA\Mail\IMAP\MailboxSync->createMailboxFromFolder(OCA\Mail\Account {}, OCA\Mail\Folder {})
 9. /var/www/html/apps/mail/lib/IMAP/MailboxSync.php line 88
    OCA\Mail\IMAP\MailboxSync->persist(OCA\Mail\Account {}, [OCA\Mail\Folder ... }], [])
10. /var/www/html/apps/mail/lib/Service/MailManager.php line 81
    OCA\Mail\IMAP\MailboxSync->sync(OCA\Mail\Account {})
11. /var/www/html/apps/mail/lib/Controller/FoldersController.php line 76
    OCA\Mail\Service\MailManager->getFolders(OCA\Mail\Account {})
12. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 166
    OCA\Mail\Controller\FoldersController->index(16)
13. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Controller\FoldersController {}, "index")
14. /var/www/html/lib/private/AppFramework/App.php line 126
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Controller\FoldersController {}, "index")
15. /var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OCA\\Mail\\Cont ... r", "index", OC\AppFramework\ ... {}, {accountId: "16" ... "})
16. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({accountId: "16" ... "})
17. /var/www/html/lib/private/Route/Router.php line 297
    undefinedundefinedcall_user_func(OC\AppFramework\ ... {}, {accountId: "16" ... "})
18. /var/www/html/lib/base.php line 975
    OC\Route\Router->match("/apps/mail/api/accounts/16/folders")
19. /var/www/html/index.php line 42
    OC::handleRequest()

GET /index.php/apps/mail/api/accounts/16/folders
from 10.0.0.8 by sheychen at 2019-09-01T09:54:03+00:00

Actual behavior

Create new account "normally"

Mail app

Mail app version: 0.16.0

Mailserver or service: https://github.com/tomav/docker-mailserver (works on thunderbird)

Server configuration

Operating system: Debian Testing (Docker)

Web server: Caddy

Database: MariaDB

PHP version: Nextcloud docker php fpm

Nextcloud Version: 16.0.4

Client configuration

Browser: Firefox 68.0.2

Operating system: Arch Linux

4. to release bug

Most helpful comment

Perfectly fixed by 0.17.0
Awesome reactivity, thanks

All 6 comments

I think I'm affected by this bug too.

Same here:

  Debug    mail               Connecting to account <REDACTED>@gmail.com                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          2019-09-01T21:57:26+00:00

  Info     mail               Setting up manually configured account                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            2019-09-01T21:57:26+00:00

  Error    mail               Doctrine\DBAL\Exception\NotNullConstraintViolationException: An exception occurred while executing 'INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(?, ?, ?, ?, ?, ?, ?)' with params ["[Gmail]", 12, "[\"\\\\hashchildren\",\"\\\\nonexistent\",\"\\\\noselect\"]", "\/", 0, 0, false]:                                                                                                                                                               2019-09-01T21:57:31+00:00

                              SQLSTATE[HY000]: General error: 1364 Field 'sync_token' doesn't have a default value at .../lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 122

                               0. 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 184
                                  Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException(
                                    "An exception occurred while executing 'INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(?, ?, ?, ?, ?, ?, ?)' with params [\"[Gmail]\", 12, \"[\\\"\\\\\\\\hashchildren\\\",\\\"\\\\\\\\nonexistent\\\",\\\"\\\\\\\\noselect\\\"]\", \"\\\/\", 0, 0, false]:\n\nSQLSTATE[HY000]: General error: 1364 Field 'sync_token' doesn't have a default value",
                                    Doctrine\DBAL\Driver\PDOException {}
                                  )
                               1. 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 158
                                  Doctrine\DBAL\DBALException::wrapException(
                                    Doctrine\DBAL\Driver\PDOMySql\Driver {},
                                    Doctrine\DBAL\Driver\PDOException {},
                                    "An exception occurred while executing 'INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(?, ?, ?, ?, ?, ?, ?)' with params [\"[Gmail]\", 12, \"[\\\"\\\\\\\\hashchildren\\\",\\\"\\\\\\\\nonexistent\\\",\\\"\\\\\\\\noselect\\\"]\", \"\\\/\", 0, 0, false]:\n\nSQLSTATE[HY000]: General error: 1364 Field 'sync_token' doesn't have a default value"
                                  )
                               2. 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 1088
                                  Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Driver\PDOException {}, "INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(?, ?, ?, ?, ?, ?, ?)", {})
                               3. lib/private/DB/Connection.php line 216
                                  Doctrine\DBAL\Connection->executeUpdate("INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(?, ?, ?, ?, ?, ?, ?)", [], [])
                               4. 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php line 222
                                  OC\DB\Connection->executeUpdate("INSERT INTO `oc_mail_mailboxes` (`id`, `account_id`, `attributes`, `delimiter`, `messages`, `unseen`, `selectable`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4, :dcValue5, :dcValue6, :dcValue7)", {}, {})
                               5. lib/private/DB/QueryBuilder/QueryBuilder.php line 214
                                  Doctrine\DBAL\Query\QueryBuilder->execute()
                               6. lib/public/AppFramework/Db/QBMapper.php line 121
                                  OC\DB\QueryBuilder\QueryBuilder->execute()
                               7. custom_apps/mail/lib/IMAP/MailboxSync.php line 136
                                  OCP\AppFramework\Db\QBMapper->insert(OCA\Mail\Db\Mailbox {})
                               8. custom_apps/mail/lib/IMAP/MailboxSync.php line 99
                                  OCA\Mail\IMAP\MailboxSync->createMailboxFromFolder(OCA\Mail\Account {}, OCA\Mail\Folder {})
                               9. custom_apps/mail/lib/IMAP/MailboxSync.php line 88
                                  OCA\Mail\IMAP\MailboxSync->persist(OCA\Mail\Account {}, [], [])
                              10. custom_apps/mail/lib/Service/MailManager.php line 81
                                  OCA\Mail\IMAP\MailboxSync->sync(OCA\Mail\Account {})
                              11. custom_apps/mail/lib/Controller/FoldersController.php line 76
                                  OCA\Mail\Service\MailManager->getFolders(OCA\Mail\Account {})
                              12. lib/private/AppFramework/Http/Dispatcher.php line 166
                                  OCA\Mail\Controller\FoldersController->index(12)
                              13. lib/private/AppFramework/Http/Dispatcher.php line 99
                                  OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Controller\FoldersController {}, "index")
                              14. lib/private/AppFramework/App.php line 126
                                  OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Controller\FoldersController {}, "index")
                              15. lib/private/AppFramework/Routing/RouteActionHandler.php line 47
                                  OC\AppFramework\App::main("OCA\\Mail\\Controller\\FoldersController", "index", OC\AppFramework\DependencyInjection\DIContainer {}, {})
                              16. <<closure>>
                                  OC\AppFramework\Routing\RouteActionHandler->__invoke({})
                              17. lib/private/Route/Router.php line 297
                                  call_user_func(OC\AppFramework\Routing\RouteActionHandler {}, {})
                              18. lib/base.php line 975
                                  OC\Route\Router->match("\/apps\/mail\/api\/accounts\/12\/folders")
                              19. index.php line 42
                                  OC::handleRequest()

Guess this is related to not all mailboxes having a sync token. Most likely it's the ones that can't be selected.

Fix is at https://github.com/nextcloud/mail/pull/1983, but also requires #1971

Perfectly fixed by 0.17.0
Awesome reactivity, thanks

0.17.0 fixed it for me as well! Thanks for the quick turnaround on that! 馃槂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clem-bcc picture clem-bcc  路  4Comments

benks-io picture benks-io  路  4Comments

sscherfke picture sscherfke  路  5Comments

jancborchardt picture jancborchardt  路  4Comments

Quix0r picture Quix0r  路  5Comments