nextcloud / groupware

Meta repo for the groupware team
9 stars 0 forks source link

Analyze and fix code for "causal reads" #24

Closed ChristophWurst closed 8 months ago

ChristophWurst commented 2 years ago

Description

High performance database backends might split their reads and writes to different nodes to balance load and improve throughput. For an application to work with these setups, some assumptions about data consistencies have to be softened. One of them is to not assume written data is readable instantly.

https://mariadb.com/docs/multi-node/maxscale/routers/readwritesplit/ensure-causal-consistency-maxscale-read-write-split-router/ covers this topic. The technical term is "causal reads". To achieve it, our apps must avoid reading and relying on data that just had been written in another transaction, because it might not be available.

As an example, the Mail initial synchronization is split into incremental chunks and each chunk relies on data of the previous run. With simple, one-node databases and in the lucky case, the chunked process will already read correct data based on the previous inserts. In the not so lucky case we read outdated data. This will result in insertion conflicts of unique natural keys.

It is not always possible to avoid the read. In that case we have to put the related code into one database transaction. The database cluster will make sure that the main node processes everything in one go and no read-only node is involved.

Affected components

To do

ChristophWurst commented 1 year ago

Idea to locate code that relies on causal reads

1) Set up a local, containerized cluster with read, write split and enable async replication 2) Force the container network to have a few seconds of delay from the write to the read nodes 3) Use the application or run tests against it

ChristophWurst commented 10 months ago

Thanks to https://github.com/nextcloud/server/pull/42345 Nextcloud can now detect dirty reads natively and will log a debug message when this happens.

ChristophWurst commented 10 months ago

A quick clicking through active apps on my dev env:

     42 "dirty table reads: SELECT DISTINCT `cp`.`cardid` FROM `*PREFIX*cards_properties` `cp` WHERE (`cp`.`addressbookid` IN (:dcValue1)) AND (`cp`.`name` IN (:dcValue2)) LIMIT 24: /nextcloud/apps/dav/lib/CardDAV/CardDavBackend.php:1082"
     42 "dirty table reads: SELECT DISTINCT `cp`.`cardid` FROM `*PREFIX*cards_properties` `cp` WHERE (`cp`.`addressbookid` IN (:dcValue1)) AND (`cp`.`name` IN (:dcValue2)) AND (`cp`.`value`  COLLATE utf8mb4_general_ci LIKE :dcValue3) LIMIT 1: /nextcloud/apps/dav/lib/CardDAV/CardDavBackend.php:1082"
     31 "dirty table reads: SELECT * FROM `*PREFIX*dav_cal_proxy` WHERE `proxy_id` = :dcValue1: /nextcloud/lib/public/AppFramework/Db/QBMapper.php:335"
     25 "dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE `principaluri` = :dcValue1 ORDER BY `calendarorder` ASC: /nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php:330"
     25 "dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `a`.`id`, `a`.`uri`, `a`.`synctoken`, `a`.`components`, `a`.`principaluri`, `a`.`transparent`, `s`.`access` FROM `*PREFIX*dav_shares` `s` INNER JOIN `*PREFIX*calendars` `a` ON `s`.`resourceid` = `a`.`id` WHERE (`s`.`principaluri` IN (:principaluri)) AND (`s`.`type` = :type): /nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php:384"
     24 "dirty table reads: SELECT `data` FROM `*PREFIX*accounts` WHERE `uid` = :uid: /nextcloud/lib/private/Accounts/AccountManager.php:297"
     24 "dirty table reads: SELECT `c`.`addressbookid`, `c`.`carddata`, `c`.`uri` FROM `*PREFIX*cards` `c` WHERE `c`.`id` IN (:matches): /nextcloud/apps/dav/lib/CardDAV/CardDavBackend.php:1220"
     16 "dirty table reads: SELECT `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = :dcValue1: /nextcloud/lib/private/AllConfig.php:434"
     13 "dirty table reads: SELECT * FROM `*PREFIX*user_status` WHERE `user_id` = :dcValue1: /nextcloud/lib/public/AppFramework/Db/QBMapper.php:275"
     12 "dirty table reads: SELECT `id`, `uri`, `displayname`, `principaluri`, `description`, `synctoken` FROM `*PREFIX*addressbooks` WHERE `principaluri` = :dcValue1: /nextcloud/lib/public/AppFramework/Db/TTransactional.php:63"

cat data/nextcloud.log | grep dirty | jq '.message + ": " + .exception.Trace[4].file + ":" + (.exception.Trace[4].line|tostring)' | sort | uniq -c | sort -nr | head

Edit: info is inaccurate because transacted reads were logged too.

ChristophWurst commented 9 months ago

How to

  1. Check out latest server master
  2. Disable user_status to avoid running into https://github.com/nextcloud/server/issues/43109
  3. tail -f data/nextcloud.log | grep dirty
  4. Click yourself through a feature

If I create a calendar in Calendar, I get these:

{"reqId":"PCu8z0SjXduKf3xyJhU2","level":0,"time":"2024-01-29T16:49:07+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"MKCOL","url":"/remote.php/dav/calendars/admin/aaa","message":"dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0","version":"29.0.0.5","exception":{"Exception":"Exception","Message":"","Code":0,"Trace":[{"file":"/home/christoph/workspace/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":337,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1",["aaa","principals/users/admin"],[2,2],null]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":377,"function":"executeQuery","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":280,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":293,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php","line":620,"function":"executeQuery","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/CalDAV/CalendarHome.php","line":170,"function":"getCalendarByUri","class":"OCA\\DAV\\CalDAV\\CalDavBackend","type":"->","args":["principals/users/admin","aaa"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/CalDAV/CalendarHome.php","line":171,"function":"getChild","class":"OCA\\DAV\\CalDAV\\CalendarHome","type":"->","args":["aaa"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":117,"function":"childExists","class":"Sabre\\CalDAV\\CalendarHome","type":"->","args":["aaa"]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php","line":674,"function":"nodeExists","class":"Sabre\\DAV\\Tree","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"sendFileIdHeader","class":"OCA\\DAV\\Connector\\Sabre\\FilesPlugin","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1239,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["afterBind",["*** sensitive parameters replaced ***"]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":560,"function":"createCollection","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpMkcol","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:MKCOL",[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/Server.php","line":370,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/remote.php","line":172,"args":["/home/christoph/workspace/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/home/christoph/workspace/nextcloud/lib/private/DB/Connection.php","Line":279,"message":"dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1","tables":["oc_calendars"],"reads":["oc_calendars"],"exception":{},"CustomMessage":"dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1"}}
{"reqId":"PCu8z0SjXduKf3xyJhU2","level":0,"time":"2024-01-29T16:49:07+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"MKCOL","url":"/remote.php/dav/calendars/admin/aaa","message":"dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0","version":"29.0.0.5","exception":{"Exception":"Exception","Message":"","Code":0,"Trace":[{"file":"/home/christoph/workspace/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":337,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1",["aaa","principals/users/admin"],[2,2],null]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":377,"function":"executeQuery","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":280,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":293,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php","line":620,"function":"executeQuery","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/CalDAV/CalendarHome.php","line":170,"function":"getCalendarByUri","class":"OCA\\DAV\\CalDAV\\CalDavBackend","type":"->","args":["principals/users/admin","aaa"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":83,"function":"getChild","class":"OCA\\DAV\\CalDAV\\CalendarHome","type":"->","args":["aaa"]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/Connector/Sabre/FilesPlugin.php","line":677,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"sendFileIdHeader","class":"OCA\\DAV\\Connector\\Sabre\\FilesPlugin","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1239,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["afterBind",["*** sensitive parameters replaced ***"]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":560,"function":"createCollection","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpMkcol","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:MKCOL",[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/home/christoph/workspace/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/lib/Server.php","line":370,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/home/christoph/workspace/nextcloud/remote.php","line":172,"args":["/home/christoph/workspace/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/home/christoph/workspace/nextcloud/lib/private/DB/Connection.php","Line":279,"message":"dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1","tables":["oc_calendars"],"reads":["oc_calendars"],"exception":{},"CustomMessage":"dirty table reads: SELECT `displayname`, `description`, `timezone`, `calendarorder`, `calendarcolor`, `deleted_at`, `id`, `uri`, `synctoken`, `components`, `principaluri`, `transparent` FROM `*PREFIX*calendars` WHERE (`uri` = :dcValue1) AND (`principaluri` = :dcValue2) LIMIT 1"}}

We do this for all of our features and make a list of the dirty reads logged.

st3iny commented 9 months ago

How to

1. Check out latest server master

2. Disable user_status to avoid running into [[Bug]: Dirty user_status table read server#43109](https://github.com/nextcloud/server/issues/43109)

3. `tail -f data/nextcloud.log | grep dirty`

4. Click yourself through a feature

To improve the readability of the output: tail -f data/nextcloud.log | jq 'select(.message | startswith("dirty table reads:"))'

st3iny commented 9 months ago

DAV

ChristophWurst commented 9 months ago

New dev docs on this topic: https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/performance.html#writing-scalable-transactions

JohannesGGE commented 9 months ago

Mail

After some clicking I found the following. I'm not sure how exactly the dirty reads are caused in each case.


If the jobs are executed separately one by one with occ, then there is no dirty read output.

OCP\BackgroundJob\TimedJob There are multiple dirty reads in the Jobs: - `\OCA\Mail\Service\Classification\ImportanceClassifier::train` - `\OCA\Mail\Service\PreprocessingService::process` - `\OCA\Mail\Service\PreprocessingService::process` - `\OCA\Mail\Service\AccountService::findById` ```json [ { "reqId": "AUdURC4BJHWinlw314Pq", "level": 0, "time": "2024-02-20T17:25:03+00:00", "remoteAddr": "", "user": "--", "app": "no app in context", "method": "", "url": "--", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "userAgent": "--", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", [ 3 ], [ 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 275, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 361, "function": "findOneQuery", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailAccountMapper.php", "line": 82, "function": "findEntity", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AccountService.php", "line": 93, "function": "findById", "class": "OCA\\Mail\\Db\\MailAccountMapper", "type": "->", "args": [ 3 ] }, { "file": "/var/www/html/apps-extra/mail/lib/BackgroundJob/TrainImportanceClassifierJob.php", "line": 70, "function": "findById", "class": "OCA\\Mail\\Service\\AccountService", "type": "->", "args": [ 3 ] }, { "file": "/var/www/html/lib/public/BackgroundJob/Job.php", "line": 80, "function": "run", "class": "OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob", "type": "->", "args": [ [ 3 ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php", "line": 102, "function": "start", "class": "OCP\\BackgroundJob\\Job", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] }, { "file": "/var/www/html/cron.php", "line": 175, "function": "start", "class": "OCP\\BackgroundJob\\TimedJob", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "tables": [ "oc_appconfig", "oc_jobs", "oc_mail_accounts", "oc_mail_mailboxes" ], "reads": [ "oc_mail_accounts" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1" } }, { "reqId": "AUdURC4BJHWinlw314Pq", "level": 0, "time": "2024-02-20T17:25:03+00:00", "remoteAddr": "", "user": "--", "app": "no app in context", "method": "", "url": "--", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "userAgent": "--", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", [ 3 ], [ 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 335, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailboxMapper.php", "line": 66, "function": "findEntities", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Classification/ImportanceClassifier.php", "line": 235, "function": "findAll", "class": "OCA\\Mail\\Db\\MailboxMapper", "type": "->", "args": [ [ "OCA\\Mail\\Account" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Classification/ImportanceClassifier.php", "line": 160, "function": "getIncomingMailboxes", "class": "OCA\\Mail\\Service\\Classification\\ImportanceClassifier", "type": "->", "args": [ [ "OCA\\Mail\\Account" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/BackgroundJob/TrainImportanceClassifierJob.php", "line": 90, "function": "train", "class": "OCA\\Mail\\Service\\Classification\\ImportanceClassifier", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OC\\AppFramework\\ScopedPsrLogger" ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/Job.php", "line": 80, "function": "run", "class": "OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob", "type": "->", "args": [ [ 3 ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php", "line": 102, "function": "start", "class": "OCP\\BackgroundJob\\Job", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] }, { "file": "/var/www/html/cron.php", "line": 175, "function": "start", "class": "OCP\\BackgroundJob\\TimedJob", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "tables": [ "oc_appconfig", "oc_jobs", "oc_mail_accounts", "oc_mail_mailboxes" ], "reads": [ "oc_mail_mailboxes" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1" } }, { "reqId": "AUdURC4BJHWinlw314Pq", "level": 0, "time": "2024-02-20T17:25:03+00:00", "remoteAddr": "", "user": "--", "app": "no app in context", "method": "", "url": "--", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `id` = :dcValue1", "userAgent": "--", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `id` = :dcValue1", [ 24 ], [ 1 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 275, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 361, "function": "findOneQuery", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailboxMapper.php", "line": 124, "function": "findEntity", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Classification/ImportanceClassifier.php", "line": 259, "function": "findById", "class": "OCA\\Mail\\Db\\MailboxMapper", "type": "->", "args": [ 24 ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Classification/ImportanceClassifier.php", "line": 163, "function": "getOutgoingMailboxes", "class": "OCA\\Mail\\Service\\Classification\\ImportanceClassifier", "type": "->", "args": [ [ "OCA\\Mail\\Account" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/BackgroundJob/TrainImportanceClassifierJob.php", "line": 90, "function": "train", "class": "OCA\\Mail\\Service\\Classification\\ImportanceClassifier", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OC\\AppFramework\\ScopedPsrLogger" ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/Job.php", "line": 80, "function": "run", "class": "OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob", "type": "->", "args": [ [ 3 ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php", "line": 102, "function": "start", "class": "OCP\\BackgroundJob\\Job", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] }, { "file": "/var/www/html/cron.php", "line": 175, "function": "start", "class": "OCP\\BackgroundJob\\TimedJob", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `id` = :dcValue1", "tables": [ "oc_appconfig", "oc_jobs", "oc_mail_accounts", "oc_mail_mailboxes" ], "reads": [ "oc_mail_mailboxes" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `id` = :dcValue1" } }, { "reqId": "AUdURC4BJHWinlw314Pq", "level": 0, "time": "2024-02-20T17:25:03+00:00", "remoteAddr": "", "user": "--", "app": "no app in context", "method": "", "url": "--", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "userAgent": "--", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", [ 3 ], [ 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 275, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 361, "function": "findOneQuery", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailAccountMapper.php", "line": 82, "function": "findEntity", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AccountService.php", "line": 93, "function": "findById", "class": "OCA\\Mail\\Db\\MailAccountMapper", "type": "->", "args": [ 3 ] }, { "file": "/var/www/html/apps-extra/mail/lib/BackgroundJob/PreviewEnhancementProcessingJob.php", "line": 70, "function": "findById", "class": "OCA\\Mail\\Service\\AccountService", "type": "->", "args": [ 3 ] }, { "file": "/var/www/html/lib/public/BackgroundJob/Job.php", "line": 80, "function": "run", "class": "OCA\\Mail\\BackgroundJob\\PreviewEnhancementProcessingJob", "type": "->", "args": [ [ 3 ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php", "line": 102, "function": "start", "class": "OCP\\BackgroundJob\\Job", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] }, { "file": "/var/www/html/cron.php", "line": 175, "function": "start", "class": "OCP\\BackgroundJob\\TimedJob", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "tables": [ "oc_appconfig", "oc_jobs", "oc_mail_accounts", "oc_mail_mailboxes" ], "reads": [ "oc_mail_accounts" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1" } }, { "reqId": "AUdURC4BJHWinlw314Pq", "level": 0, "time": "2024-02-20T17:25:03+00:00", "remoteAddr": "", "user": "--", "app": "no app in context", "method": "", "url": "--", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "userAgent": "--", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", [ 3 ], [ 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 335, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailboxMapper.php", "line": 66, "function": "findEntities", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/PreprocessingService.php", "line": 56, "function": "findAll", "class": "OCA\\Mail\\Db\\MailboxMapper", "type": "->", "args": [ [ "OCA\\Mail\\Account" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/BackgroundJob/PreviewEnhancementProcessingJob.php", "line": 94, "function": "process", "class": "OCA\\Mail\\Service\\PreprocessingService", "type": "->", "args": [ 1707240303, [ "OCA\\Mail\\Account" ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/Job.php", "line": 80, "function": "run", "class": "OCA\\Mail\\BackgroundJob\\PreviewEnhancementProcessingJob", "type": "->", "args": [ [ 3 ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php", "line": 102, "function": "start", "class": "OCP\\BackgroundJob\\Job", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] }, { "file": "/var/www/html/cron.php", "line": 175, "function": "start", "class": "OCP\\BackgroundJob\\TimedJob", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "tables": [ "oc_appconfig", "oc_jobs", "oc_mail_accounts", "oc_mail_mailboxes" ], "reads": [ "oc_mail_mailboxes" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1" } }, { "reqId": "AUdURC4BJHWinlw314Pq", "level": 0, "time": "2024-02-20T17:25:03+00:00", "remoteAddr": "", "user": "--", "app": "no app in context", "method": "", "url": "--", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "userAgent": "--", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", [ 3 ], [ 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 275, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 361, "function": "findOneQuery", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailAccountMapper.php", "line": 82, "function": "findEntity", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AccountService.php", "line": 93, "function": "findById", "class": "OCA\\Mail\\Db\\MailAccountMapper", "type": "->", "args": [ 3 ] }, { "file": "/var/www/html/apps-extra/mail/lib/BackgroundJob/QuotaJob.php", "line": 75, "function": "findById", "class": "OCA\\Mail\\Service\\AccountService", "type": "->", "args": [ 3 ] }, { "file": "/var/www/html/lib/public/BackgroundJob/Job.php", "line": 80, "function": "run", "class": "OCA\\Mail\\BackgroundJob\\QuotaJob", "type": "->", "args": [ [ 3 ] ] }, { "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php", "line": 102, "function": "start", "class": "OCP\\BackgroundJob\\Job", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] }, { "file": "/var/www/html/cron.php", "line": 175, "function": "start", "class": "OCP\\BackgroundJob\\TimedJob", "type": "->", "args": [ [ "OC\\BackgroundJob\\JobList" ] ] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1", "tables": [ "oc_appconfig", "oc_jobs", "oc_mail_accounts", "oc_mail_mailboxes" ], "reads": [ "oc_mail_accounts" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_accounts` WHERE `id` = :dcValue1" } } ] ```

In Mail not a big issue. But could be a in other areas. Server Ticket: https://github.com/nextcloud/server/issues/43892

\OCA\Mail\Service\SetupService::createNewAccount There is an dirty read for every Job that is created in `\OCA\Mail\Service\AccountService::save` ```json [ { "reqId": "GN7yk8s44tLTuH9tJt1F", "level": 0, "time": "2024-02-20T17:13:36+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/accounts", "message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", [ "OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob", "377f64949c338b756bd9ce4d6e1db80b" ], [ 2, 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/BackgroundJob/JobList.php", "line": 166, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/BackgroundJob/JobList.php", "line": 78, "function": "has", "class": "OC\\BackgroundJob\\JobList", "type": "->", "args": [ "OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob", "{\"accountId\":3}" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AccountService.php", "line": 159, "function": "add", "class": "OC\\BackgroundJob\\JobList", "type": "->", "args": [ "OCA\\Mail\\BackgroundJob\\TrainImportanceClassifierJob", [ 3 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/SetupService.php", "line": 130, "function": "save", "class": "OCA\\Mail\\Service\\AccountService", "type": "->", "args": [ [ "OCA\\Mail\\Db\\MailAccount", 3 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/AccountsController.php", "line": 392, "function": "createNewAccount", "class": "OCA\\Mail\\Service\\SetupService", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "create", "class": "OCA\\Mail\\Controller\\AccountsController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\AccountsController", "create", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "mail.accounts.create" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/accounts" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "tables": [ "oc_authtoken", "oc_mail_accounts", "oc_jobs" ], "reads": [ "oc_jobs" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1" } }, { "reqId": "GN7yk8s44tLTuH9tJt1F", "level": 0, "time": "2024-02-20T17:13:36+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/accounts", "message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", [ "OCA\\Mail\\BackgroundJob\\PreviewEnhancementProcessingJob", "377f64949c338b756bd9ce4d6e1db80b" ], [ 2, 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/BackgroundJob/JobList.php", "line": 166, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/BackgroundJob/JobList.php", "line": 78, "function": "has", "class": "OC\\BackgroundJob\\JobList", "type": "->", "args": [ "OCA\\Mail\\BackgroundJob\\PreviewEnhancementProcessingJob", "{\"accountId\":3}" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AccountService.php", "line": 160, "function": "add", "class": "OC\\BackgroundJob\\JobList", "type": "->", "args": [ "OCA\\Mail\\BackgroundJob\\PreviewEnhancementProcessingJob", [ 3 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/SetupService.php", "line": 130, "function": "save", "class": "OCA\\Mail\\Service\\AccountService", "type": "->", "args": [ [ "OCA\\Mail\\Db\\MailAccount", 3 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/AccountsController.php", "line": 392, "function": "createNewAccount", "class": "OCA\\Mail\\Service\\SetupService", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "create", "class": "OCA\\Mail\\Controller\\AccountsController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\AccountsController", "create", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "mail.accounts.create" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/accounts" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "tables": [ "oc_authtoken", "oc_mail_accounts", "oc_jobs" ], "reads": [ "oc_jobs" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1" } }, { "reqId": "GN7yk8s44tLTuH9tJt1F", "level": 0, "time": "2024-02-20T17:13:36+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/accounts", "message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", [ "OCA\\Mail\\BackgroundJob\\QuotaJob", "377f64949c338b756bd9ce4d6e1db80b" ], [ 2, 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/BackgroundJob/JobList.php", "line": 166, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/BackgroundJob/JobList.php", "line": 78, "function": "has", "class": "OC\\BackgroundJob\\JobList", "type": "->", "args": [ "OCA\\Mail\\BackgroundJob\\QuotaJob", "{\"accountId\":3}" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AccountService.php", "line": 161, "function": "add", "class": "OC\\BackgroundJob\\JobList", "type": "->", "args": [ "OCA\\Mail\\BackgroundJob\\QuotaJob", [ 3 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/SetupService.php", "line": 130, "function": "save", "class": "OCA\\Mail\\Service\\AccountService", "type": "->", "args": [ [ "OCA\\Mail\\Db\\MailAccount", 3 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/AccountsController.php", "line": 392, "function": "createNewAccount", "class": "OCA\\Mail\\Service\\SetupService", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "create", "class": "OCA\\Mail\\Controller\\AccountsController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\AccountsController", "create", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "mail.accounts.create" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/accounts" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1", "tables": [ "oc_authtoken", "oc_mail_accounts", "oc_jobs" ], "reads": [ "oc_jobs" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `id` FROM `*PREFIX*jobs` WHERE (`class` = :dcValue1) AND (`argument_hash` = :dcValue2) LIMIT 1" } }, { "reqId": "GN7yk8s44tLTuH9tJt1F", "level": 0, "time": "2024-02-20T17:13:37+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/accounts", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", [ 3 ], [ 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 335, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MailboxMapper.php", "line": 66, "function": "findEntities", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Listener/MailboxesSynchronizedSpecialMailboxesUpdater.php", "line": 72, "function": "findAll", "class": "OCA\\Mail\\Db\\MailboxMapper", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php", "line": 86, "function": "handle", "class": "OCA\\Mail\\Listener\\MailboxesSynchronizedSpecialMailboxesUpdater", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 230, "function": "__invoke", "class": "OC\\EventDispatcher\\ServiceEventListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ], "OCA\\Mail\\Events\\MailboxesSynchronizedEvent", [ "Symfony\\Component\\EventDispatcher\\EventDispatcher" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 59, "function": "callListeners", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ [ "Closure" ] ], "OCA\\Mail\\Events\\MailboxesSynchronizedEvent", [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ] ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 94, "function": "dispatch", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ], "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 106, "function": "dispatch", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent", [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/IMAP/MailboxSync.php", "line": 148, "function": "dispatchTyped", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MailboxesSynchronizedEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/AccountsController.php", "line": 411, "function": "sync", "class": "OCA\\Mail\\IMAP\\MailboxSync", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "create", "class": "OCA\\Mail\\Controller\\AccountsController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\AccountsController" ], "create" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\AccountsController", "create", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "mail.accounts.create" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/accounts" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1", "tables": [ "oc_authtoken", "oc_mail_accounts", "oc_jobs", "oc_mail_mailboxes" ], "reads": [ "oc_mail_mailboxes" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_mailboxes` WHERE `account_id` = :dcValue1" } } ] ```

The best way is to refactor the sync process. To not write imap to db and then read from db. It's a huge effort.

\OCA\Mail\Service\Sync\SyncService::syncMailbox Calls sync() and then getDatabaseSyncChanges() ```json [ { "reqId": "WD6zAlvOeVCVA3wzV1l1", "level": 0, "time": "2024-02-20T13:03:41+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/mailboxes/8/sync", "message": "dirty table reads: SELECT `m`.`id`, `m`.`sent_at` FROM `*PREFIX*mail_messages` `m` LEFT JOIN `*PREFIX*mail_messages` `m2` ON (`m`.`mailbox_id` = `m2`.`mailbox_id`) AND (`m`.`thread_root_id` = `m2`.`thread_root_id`) AND (`m`.`sent_at` < `m2`.`sent_at`) WHERE (`m`.`mailbox_id` = :dcValue2) AND (`m`.`id` NOT IN (:ids)) AND (`m2`.`id` IS NULL) AND (`m`.`sent_at` > (SELECT MIN(`sent_at`) FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)))) ORDER BY `m`.`sent_at` desc", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `m`.`id`, `m`.`sent_at` FROM `*PREFIX*mail_messages` `m` LEFT JOIN `*PREFIX*mail_messages` `m2` ON (`m`.`mailbox_id` = `m2`.`mailbox_id`) AND (`m`.`thread_root_id` = `m2`.`thread_root_id`) AND (`m`.`sent_at` < `m2`.`sent_at`) WHERE (`m`.`mailbox_id` = :dcValue2) AND (`m`.`id` NOT IN (:ids)) AND (`m2`.`id` IS NULL) AND (`m`.`sent_at` > (SELECT MIN(`sent_at`) FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)))) ORDER BY `m`.`sent_at` desc", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `m`.`id`, `m`.`sent_at` FROM `*PREFIX*mail_messages` `m` LEFT JOIN `*PREFIX*mail_messages` `m2` ON (`m`.`mailbox_id` = `m2`.`mailbox_id`) AND (`m`.`thread_root_id` = `m2`.`thread_root_id`) AND (`m`.`sent_at` < `m2`.`sent_at`) WHERE (`m`.`mailbox_id` = :dcValue2) AND (`m`.`id` NOT IN (:ids)) AND (`m2`.`id` IS NULL) AND (`m`.`sent_at` > (SELECT MIN(`sent_at`) FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)))) ORDER BY `m`.`sent_at` desc", [ "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***" ], [ 1, 1, 101 ], "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MessageMapper.php", "line": 103, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MessageMapper.php", "line": 1381, "function": "findIds", "class": "OCA\\Mail\\Db\\MessageMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Sync/SyncService.php", "line": 164, "function": "findNewIds", "class": "OCA\\Mail\\Db\\MessageMapper", "type": "->", "args": [ "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Sync/SyncService.php", "line": 136, "function": "getDatabaseSyncChanges", "class": "OCA\\Mail\\Service\\Sync\\SyncService", "type": "->", "args": [ "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/MailboxesController.php", "line": 156, "function": "syncMailbox", "class": "OCA\\Mail\\Service\\Sync\\SyncService", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "sync", "class": "OCA\\Mail\\Controller\\MailboxesController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\MailboxesController" ], "sync" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\MailboxesController" ], "sync" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\MailboxesController", "sync", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "8", "mail.mailboxes.sync" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/mailboxes/8/sync" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `m`.`id`, `m`.`sent_at` FROM `*PREFIX*mail_messages` `m` LEFT JOIN `*PREFIX*mail_messages` `m2` ON (`m`.`mailbox_id` = `m2`.`mailbox_id`) AND (`m`.`thread_root_id` = `m2`.`thread_root_id`) AND (`m`.`sent_at` < `m2`.`sent_at`) WHERE (`m`.`mailbox_id` = :dcValue2) AND (`m`.`id` NOT IN (:ids)) AND (`m2`.`id` IS NULL) AND (`m`.`sent_at` > (SELECT MIN(`sent_at`) FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)))) ORDER BY `m`.`sent_at` desc", "tables": [ "oc_mail_mailboxes", "oc_mail_messages" ], "reads": [ "oc_mail_messages", "oc_mail_messages", "oc_mail_messages" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `m`.`id`, `m`.`sent_at` FROM `*PREFIX*mail_messages` `m` LEFT JOIN `*PREFIX*mail_messages` `m2` ON (`m`.`mailbox_id` = `m2`.`mailbox_id`) AND (`m`.`thread_root_id` = `m2`.`thread_root_id`) AND (`m`.`sent_at` < `m2`.`sent_at`) WHERE (`m`.`mailbox_id` = :dcValue2) AND (`m`.`id` NOT IN (:ids)) AND (`m2`.`id` IS NULL) AND (`m`.`sent_at` > (SELECT MIN(`sent_at`) FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)))) ORDER BY `m`.`sent_at` desc" } }, { "reqId": "WD6zAlvOeVCVA3wzV1l1", "level": 0, "time": "2024-02-20T13:03:41+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/mailboxes/8/sync", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)) ORDER BY `sent_at` desc", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)) ORDER BY `sent_at` desc", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)) ORDER BY `sent_at` desc", [ "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***" ], [ 2, 101 ], "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 335, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MessageMapper.php", "line": 1220, "function": "findEntities", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Sync/SyncService.php", "line": 181, "function": "findByMailboxAndIds", "class": "OCA\\Mail\\Db\\MessageMapper", "type": "->", "args": [ "*** sensitive parameters replaced ***", "admin", "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/Sync/SyncService.php", "line": 136, "function": "getDatabaseSyncChanges", "class": "OCA\\Mail\\Service\\Sync\\SyncService", "type": "->", "args": [ "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***", "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/MailboxesController.php", "line": 156, "function": "syncMailbox", "class": "OCA\\Mail\\Service\\Sync\\SyncService", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "sync", "class": "OCA\\Mail\\Controller\\MailboxesController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\MailboxesController" ], "sync" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\MailboxesController" ], "sync" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\MailboxesController", "sync", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "8", "mail.mailboxes.sync" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/mailboxes/8/sync" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)) ORDER BY `sent_at` desc", "tables": [ "oc_mail_mailboxes", "oc_mail_messages" ], "reads": [ "oc_mail_messages" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`id` IN (:ids)) ORDER BY `sent_at` desc" } } ] ```

Sort fix: \OCA\Mail\Service\AutoCompletion\AddressCollector::saveAddress: Put exists() and insert in a Transaction: https://github.com/nextcloud/mail/pull/9422

Fix: Don't collect addresses in a extra table anymore. Use mail_messages or imap requests.

\OCA\Mail\Service\MailTransmission::sendLocalMessage `\OCA\Mail\Service\AutoCompletion\AddressCollector::addAddresses` ```json { "reqId": "vC4yNyC0cmQfSUpxfSZH", "level": 0, "time": "2024-02-21T12:35:14+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/outbox/7", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_coll_addresses` WHERE (`user_id` = :dcValue1) AND (`email` COLLATE utf8mb4_general_ci LIKE :dcValue2)", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_coll_addresses` WHERE (`user_id` = :dcValue1) AND (`email` COLLATE utf8mb4_general_ci LIKE :dcValue2)", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_coll_addresses` WHERE (`user_id` = :dcValue1) AND (`email` COLLATE utf8mb4_general_ci LIKE :dcValue2)", [ "admin", "abcabc@abc.dde" ], [ 2, 2 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 335, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/CollectedAddressMapper.php", "line": 75, "function": "findEntities", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AutoCompletion/AddressCollector.php", "line": 81, "function": "exists", "class": "OCA\\Mail\\Db\\CollectedAddressMapper", "type": "->", "args": [ "admin", "abc@abc.dde" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/AutoCompletion/AddressCollector.php", "line": 60, "function": "saveAddress", "class": "OCA\\Mail\\Service\\AutoCompletion\\AddressCollector", "type": "->", "args": [ "admin", [ "OCA\\Mail\\Address" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Listener/AddressCollectionListener.php", "line": 73, "function": "addAddresses", "class": "OCA\\Mail\\Service\\AutoCompletion\\AddressCollector", "type": "->", "args": [ "admin", [ "OCA\\Mail\\AddressList" ] ] }, { "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php", "line": 86, "function": "handle", "class": "OCA\\Mail\\Listener\\AddressCollectionListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageSentEvent" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 230, "function": "__invoke", "class": "OC\\EventDispatcher\\ServiceEventListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageSentEvent" ], "OCA\\Mail\\Events\\MessageSentEvent", [ "Symfony\\Component\\EventDispatcher\\EventDispatcher" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 59, "function": "callListeners", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ [ "Closure" ], [ "Closure" ], [ "Closure" ], [ "Closure" ] ], "OCA\\Mail\\Events\\MessageSentEvent", [ "OCA\\Mail\\Events\\MessageSentEvent" ] ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 94, "function": "dispatch", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageSentEvent" ], "OCA\\Mail\\Events\\MessageSentEvent" ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 106, "function": "dispatch", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ "OCA\\Mail\\Events\\MessageSentEvent", [ "OCA\\Mail\\Events\\MessageSentEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailTransmission.php", "line": 281, "function": "dispatchTyped", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageSentEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailTransmission.php", "line": 343, "function": "sendMessage", "class": "OCA\\Mail\\Service\\MailTransmission", "type": "->", "args": [ [ "OCA\\Mail\\Model\\NewMessageData" ], "", null ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/OutboxService.php", "line": 142, "function": "sendLocalMessage", "class": "OCA\\Mail\\Service\\MailTransmission", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\LocalMessage", 7 ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/OutboxController.php", "line": 247, "function": "sendMessage", "class": "OCA\\Mail\\Service\\OutboxService", "type": "->", "args": [ [ "OCA\\Mail\\Db\\LocalMessage", 7 ], [ "OCA\\Mail\\Account" ] ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "send", "class": "OCA\\Mail\\Controller\\OutboxController", "type": "->", "args": [ 7 ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\OutboxController" ], "send" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\OutboxController" ], "send" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\OutboxController", "send", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "7", "mail.outbox.send" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/outbox/7" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_coll_addresses` WHERE (`user_id` = :dcValue1) AND (`email` COLLATE utf8mb4_general_ci LIKE :dcValue2)", "tables": [ "oc_mail_coll_addresses" ], "reads": [ "oc_mail_coll_addresses" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_coll_addresses` WHERE (`user_id` = :dcValue1) AND (`email` COLLATE utf8mb4_general_ci LIKE :dcValue2)" } } ```

Fix: SELECT as subquery of DELETE in \OCA\Mail\Db\MessageMapper::deleteByUid: https://github.com/nextcloud/mail/pull/9423

\OCA\Mail\Db\MessageMapper::deleteByUid Caused by deleting/moving/snoozing thread Snooze: ```json { "reqId": "w53t51RGe9MVFENCQiLv", "level": 0, "time": "2024-02-21T12:22:49+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/thread/34/snooze", "message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", [ 40, [ 383 ] ], [ 2, 101 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MessageMapper.php", "line": 728, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Listener/MessageCacheUpdaterListener.php", "line": 67, "function": "deleteByUid", "class": "OCA\\Mail\\Db\\MessageMapper", "type": "->", "args": [ [ "OCA\\Mail\\Db\\Mailbox", 40 ], 383 ] }, { "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php", "line": 86, "function": "handle", "class": "OCA\\Mail\\Listener\\MessageCacheUpdaterListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 230, "function": "__invoke", "class": "OC\\EventDispatcher\\ServiceEventListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ], "OCA\\Mail\\Events\\MessageDeletedEvent", [ "Symfony\\Component\\EventDispatcher\\EventDispatcher" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 59, "function": "callListeners", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ [ "Closure" ] ], "OCA\\Mail\\Events\\MessageDeletedEvent", [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 94, "function": "dispatch", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ], "OCA\\Mail\\Events\\MessageDeletedEvent" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 315, "function": "dispatch", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ "OCA\\Mail\\Events\\MessageDeletedEvent", [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 928, "function": "moveMessage", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], "INBOX", 383, [ "OCA\\Mail\\Account" ], "Snoozed" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/SnoozeService.php", "line": 188, "function": "moveThread", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 40 ], [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 32 ], "<7ad5abed-1f60-49d4-8f7f-c3e88305b21d@posteo.de>" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/ThreadController.php", "line": 122, "function": "snoozeThread", "class": "OCA\\Mail\\Service\\SnoozeService", "type": "->", "args": [ [ "OCA\\Mail\\Db\\Message", 34 ], 1708930800, [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 40 ], [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 32 ] ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "snooze", "class": "OCA\\Mail\\Controller\\ThreadController", "type": "->", "args": [ 34, 1708930800, 32 ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\ThreadController" ], "snooze" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\ThreadController" ], "snooze" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\ThreadController", "snooze", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "34", "mail.thread.snooze" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/thread/34/snooze" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "tables": [ "oc_mail_recipients", "oc_mail_messages" ], "reads": [ "oc_mail_messages" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))" } } ``` Delete: ```json { "reqId": "rUbXh5LlR22I5ZBfvjFQ", "level": 0, "time": "2024-02-21T12:25:31+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "DELETE", "url": "/index.php/apps/mail/api/thread/38", "message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", [ 40, [ 385 ] ], [ 2, 101 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MessageMapper.php", "line": 728, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Listener/MessageCacheUpdaterListener.php", "line": 67, "function": "deleteByUid", "class": "OCA\\Mail\\Db\\MessageMapper", "type": "->", "args": [ [ "OCA\\Mail\\Db\\Mailbox", 40 ], 385 ] }, { "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php", "line": 86, "function": "handle", "class": "OCA\\Mail\\Listener\\MessageCacheUpdaterListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 230, "function": "__invoke", "class": "OC\\EventDispatcher\\ServiceEventListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ], "OCA\\Mail\\Events\\MessageDeletedEvent", [ "Symfony\\Component\\EventDispatcher\\EventDispatcher" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 59, "function": "callListeners", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ [ "Closure" ] ], "OCA\\Mail\\Events\\MessageDeletedEvent", [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 94, "function": "dispatch", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ], "OCA\\Mail\\Events\\MessageDeletedEvent" ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 106, "function": "dispatch", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ "OCA\\Mail\\Events\\MessageDeletedEvent", [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 390, "function": "dispatchTyped", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 340, "function": "deleteMessageWithClient", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 40 ], 385, [ "OCA\\Mail\\IMAP\\ImapClientRateLimitingDecorator", [ "HICenv", "HICflags", "HIChdrs", "HICdate", "HICsize", "HICstruct" ], true, true ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 957, "function": "deleteMessage", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], "INBOX", 385 ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/ThreadController.php", "line": 208, "function": "deleteThread", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 40 ], "<7ad5abed-1f60-49d4-8f7f-c3e88305b21d@posteo.de>" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "delete", "class": "OCA\\Mail\\Controller\\ThreadController", "type": "->", "args": [ 38 ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\ThreadController" ], "delete" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\ThreadController" ], "delete" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\ThreadController", "delete", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "38", "mail.thread.delete" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/thread/38" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "tables": [ "oc_mail_recipients", "oc_mail_messages" ], "reads": [ "oc_mail_messages" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))" } } ``` Move: ```json { "reqId": "eNAoLtTqC00WUTm9zoZX", "level": 0, "time": "2024-02-21T12:21:06+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "POST", "url": "/index.php/apps/mail/api/thread/33", "message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", [ 32, [ 3 ] ], [ 2, 101 ], null ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/MessageMapper.php", "line": 728, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Listener/MessageCacheUpdaterListener.php", "line": 67, "function": "deleteByUid", "class": "OCA\\Mail\\Db\\MessageMapper", "type": "->", "args": [ [ "OCA\\Mail\\Db\\Mailbox", 32 ], 3 ] }, { "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php", "line": 86, "function": "handle", "class": "OCA\\Mail\\Listener\\MessageCacheUpdaterListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 230, "function": "__invoke", "class": "OC\\EventDispatcher\\ServiceEventListener", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ], "OCA\\Mail\\Events\\MessageDeletedEvent", [ "Symfony\\Component\\EventDispatcher\\EventDispatcher" ] ] }, { "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php", "line": 59, "function": "callListeners", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ [ "Closure" ] ], "OCA\\Mail\\Events\\MessageDeletedEvent", [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php", "line": 94, "function": "dispatch", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Events\\MessageDeletedEvent" ], "OCA\\Mail\\Events\\MessageDeletedEvent" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 315, "function": "dispatch", "class": "OC\\EventDispatcher\\EventDispatcher", "type": "->", "args": [ "OCA\\Mail\\Events\\MessageDeletedEvent", [ "OCA\\Mail\\Events\\MessageDeletedEvent" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/MailManager.php", "line": 928, "function": "moveMessage", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], "Snoozed", 3, [ "OCA\\Mail\\Account" ], "INBOX" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/ThreadController.php", "line": 93, "function": "moveThread", "class": "OCA\\Mail\\Service\\MailManager", "type": "->", "args": [ [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 32 ], [ "OCA\\Mail\\Account" ], [ "OCA\\Mail\\Db\\Mailbox", 40 ], "<7ad5abed-1f60-49d4-8f7f-c3e88305b21d@posteo.de>" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "move", "class": "OCA\\Mail\\Controller\\ThreadController", "type": "->", "args": [ 33, 40 ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\ThreadController" ], "move" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\ThreadController" ], "move" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\ThreadController", "move", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "33", "mail.thread.move" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/thread/33" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))", "tables": [ "oc_mail_recipients", "oc_mail_messages" ], "reads": [ "oc_mail_messages" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT `id` FROM `*PREFIX*mail_messages` WHERE (`mailbox_id` = :dcValue1) AND (`uid` IN (:uids))" } } ```

Short fix: \OCA\Mail\Db\LocalMessageMapper::updateWithRecipients: move findByLocalMessageId() in transaction above: https://github.com/nextcloud/mail/pull/9424

Fix: Edit \OCA\Mail\Db\RecipientMapper::updateRecipients to return recipients and remove extra query findByLocalMessageId()

\OCA\Mail\Service\DraftsService::updateMessage `\OCA\Mail\Db\LocalMessageMapper::updateWithRecipients` seems to be the cause here ```json { "reqId": "Ir0vwXQG3y7nYvFjsGmC", "level": 0, "time": "2024-02-21T10:47:28+00:00", "remoteAddr": "192.168.21.6", "user": "admin", "app": "no app in context", "method": "PUT", "url": "/index.php/apps/mail/api/drafts/6", "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_recipients` WHERE `local_message_id` = :dcValue1", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", "version": "29.0.0.5", "exception": { "Exception": "Exception", "Message": "dirty table reads: SELECT * FROM `*PREFIX*mail_recipients` WHERE `local_message_id` = :dcValue1", "Code": 0, "Trace": [ { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 341, "function": "executeQuery", "class": "OC\\DB\\Connection", "type": "->", "args": [ "SELECT * FROM `*PREFIX*mail_recipients` WHERE `local_message_id` = :dcValue1", [ "*** sensitive parameters replaced ***" ], [ 1 ], "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php", "line": 377, "function": "executeQuery", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 280, "function": "execute", "class": "Doctrine\\DBAL\\Query\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php", "line": 293, "function": "execute", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php", "line": 335, "function": "executeQuery", "class": "OC\\DB\\QueryBuilder\\QueryBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/RecipientMapper.php", "line": 53, "function": "findEntities", "class": "OCP\\AppFramework\\Db\\QBMapper", "type": "->", "args": [ [ "OC\\DB\\QueryBuilder\\QueryBuilder" ] ] }, { "file": "/var/www/html/apps-extra/mail/lib/Db/LocalMessageMapper.php", "line": 264, "function": "findByLocalMessageId", "class": "OCA\\Mail\\Db\\RecipientMapper", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Service/DraftsService.php", "line": 155, "function": "updateWithRecipients", "class": "OCA\\Mail\\Db\\LocalMessageMapper", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/apps-extra/mail/lib/Controller/DraftsController.php", "line": 195, "function": "updateMessage", "class": "OCA\\Mail\\Service\\DraftsService", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 232, "function": "update", "class": "OCA\\Mail\\Controller\\DraftsController", "type": "->", "args": [ "*** sensitive parameters replaced ***" ] }, { "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php", "line": 138, "function": "executeController", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\DraftsController" ], "update" ] }, { "file": "/var/www/html/lib/private/AppFramework/App.php", "line": 184, "function": "dispatch", "class": "OC\\AppFramework\\Http\\Dispatcher", "type": "->", "args": [ [ "OCA\\Mail\\Controller\\DraftsController" ], "update" ] }, { "file": "/var/www/html/lib/private/Route/Router.php", "line": 315, "function": "main", "class": "OC\\AppFramework\\App", "type": "::", "args": [ "OCA\\Mail\\Controller\\DraftsController", "update", [ "OC\\AppFramework\\DependencyInjection\\DIContainer" ], [ "6", "mail.drafts.update" ] ] }, { "file": "/var/www/html/lib/base.php", "line": 1059, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/apps/mail/api/drafts/6" ] }, { "file": "/var/www/html/index.php", "line": 49, "function": "handleRequest", "class": "OC", "type": "::", "args": [] } ], "File": "/var/www/html/lib/private/DB/Connection.php", "Line": 285, "message": "dirty table reads: SELECT * FROM `*PREFIX*mail_recipients` WHERE `local_message_id` = :dcValue1", "tables": [ "oc_authtoken", "oc_mail_local_messages", "oc_mail_recipients" ], "reads": [ "oc_mail_recipients" ], "exception": {}, "CustomMessage": "dirty table reads: SELECT * FROM `*PREFIX*mail_recipients` WHERE `local_message_id` = :dcValue1" } } ```
ChristophWurst commented 8 months ago

\OCA\DAV\CalDAV\CalDavBackend::updateCalendar

That method suffers from the same bug as https://github.com/nextcloud/server/pull/43903. There is a transaction but it's effectively unused. Sabre executes the callback when the transaction is already closed.

ChristophWurst commented 8 months ago

Everything we decided to fix has been addressed. The rest is in server.