View Issue Details

IDProjectCategoryView StatusLast Update
0005872SOGoActiveSyncpublic2026-10-26 22:25
ReporterSilvanNagl Assigned Toqhivert  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Version5.8.4 
Summary0005872: high cpu load and some looping behavior of apple devices connecting to sogo / mailcow
Description

https://github.com/mailcow/mailcow-dockerized/issues/5045

Steps To Reproduce

Connect some Apple devices to mailcow.

TagsNo tags attached.

Activities

SilvanNagl

SilvanNagl

2023-09-28 07:13

reporter   ~0017317

2023-09-28-091318_grim.png (113,126 bytes)   
2023-09-28-091318_grim.png (113,126 bytes)   
SilvanNagl

SilvanNagl

2023-09-28 07:49

reporter   ~0017318

For months this problem now eats our resources.
We would really appreciate to find a solution for this.

qhivert

qhivert

2023-09-28 10:00

administrator   ~0017320

Hello,

SilvanNagl

SilvanNagl

2023-10-25 12:50

reporter   ~0017400

Yes, the bug is identically to mentioned comment.

mailcowdockerized-sogo-mailcow-1       | Oct 25 14:49:47 4991662df76e sogod [57]: <0x0x56383afe8b40[SOGoActiveSyncDispatcher]> EAS - request for device 72T5A34GMH0MP16ASAC83JT8UG: <?xml version="1.0"?>
mailcowdockerized-sogo-mailcow-1       | Oct 25 14:49:47 4991662df76e syslog-ng[11]: Error processing log message: <!DOCTYPE ActiveSync PUBLIC "-//MICROSOFT//DTD ActiveSync//EN" "http://www.microsoft.com/">
mailcowdockerized-sogo-mailcow-1       | <Sync xmlns="AirSync:">
mailcowdockerized-sogo-mailcow-1       |  <Collections>
mailcowdockerized-sogo-mailcow-1       |   <Collection>
mailcowdockerized-sogo-mailcow-1       |    <SyncKey>0</SyncKey>
mailcowdockerized-sogo-mailcow-1       |    <CollectionId>mail%2FShared</CollectionId>
SilvanNagl

SilvanNagl

2023-12-07 11:26

reporter   ~0017491

Any news?

SilvanNagl

SilvanNagl

2023-12-15 09:17

reporter   ~0017504

I really would appreciate some collaboration.
This Problem eats basically 600% CPU on an 8 Core mailcow docker server only because some people connect with their IOS-Devices.
Connecting IOS Devices basically limits down the whole server for everyone causing not only really high power consumption but also killing the user experience.

If there is anything I can provide to speed up the debug process please tell.
If this is not a SoGo bug please also tell.
The mail server runs for months now on maximum load.

https://github.com/mailcow/mailcow-dockerized/issues/5045#issuecomment-1615833182

qhivert

qhivert

2023-12-15 09:54

administrator   ~0017505

Hello,

SilvanNagl

SilvanNagl

2024-01-09 16:12

reporter   ~0017530

For privacy reasons I can not give you the full log but like already mentioned the logs are as follow:

Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: Jan  9 16:53:11 6454ffe7fa29 syslog-ng[10]: Error processing log message: <Ping xmlns="Ping:">
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  <Status>1</Status>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Ping>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: /HeartbeatInterval>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  <Folders>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>mail%2F349e8a121fa0d4611b200000eb6a2ee8</Id>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Email</Class>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>mail%2F9c212839e01dd76126310000eb6a2ee8</Id>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Email</Class>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>mail%2Fd05fcc211fa0d4611b200000eb6a2ee8</Id>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Email</Class>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>vevent%2Fpersonal</Id>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Calendar</Class>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  </Folders>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Ping>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: s>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Collection>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  </Collections>
Jan 09 16:53:11 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Sync>

follwed by the xml content with private data. Than it repeats again with the line "Error processing log message".

Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: Jan  9 17:05:17 6454ffe7fa29 syslog-ng[10]: Error processing log message: <!DOCTYPE ActiveSync PUBLIC "-//MICROSOFT//DTD ActiveSync//EN" "http://www.microsoft.com/">
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: <Ping xmlns="Ping:">
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  <Status>1</Status>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Ping>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: ", "mail%2Fdb6b2903b25d7864adf923003b3b2f75")
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  '{DAV:}write-content' already exists in DAV permissions table
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: s>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>mail%2F9c212839e01dd76126310000eb6a2ee8</Id>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Email</Class>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>mail%2Fd05fcc211fa0d4611b200000eb6a2ee8</Id>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Email</Class>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   <Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Id>vevent%2Fpersonal</Id>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:    <Class>Calendar</Class>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Folder>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  </Folders>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Ping>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Options>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:   </Collection>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  </Collections>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Sync>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Collection>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]:  </Collections>
Jan 09 17:05:17 mail-host docker/mailcowdockerized-sogo-mailcow-1[959]: </Sync>
SilvanNagl

SilvanNagl

2024-01-09 16:13

reporter   ~0017531

This repeats probably as fast as the TLS handshake can get.
Again and again, no more error logs in the debug lvl.

SilvanNagl

SilvanNagl

2024-02-14 11:02

reporter   ~0017587

The information needed can be seen in
https://github.com/mailcow/mailcow-dockerized/issues/5045#issuecomment-1912275247

SilvanNagl

SilvanNagl

2024-04-18 13:40

reporter   ~0017711

Any news?

qhivert

qhivert

2024-04-29 12:26

administrator   ~0017717

Hello,
We haven't forget about this but our (Alinto's) hands are full for now.

tfu

tfu

2024-04-30 19:09

reporter   ~0017720

Maybe it helps to find out what request is hammering the server... check logs for fast repeating requests:
POST /SOGo/Microsoft-Server-ActiveSync?User=...&DeviceId=....&DeviceType=...&Cmd=... HTTP/1.1" 200

Maybe you can identify a specific DeviceId= and Cmd= causing the load.

Then it might help to see the some examples of the payload of such repeating requests:
EAS - request for device ...: <?xml
and its
EAS - response for device ....: <?xml

SilvanNagl

SilvanNagl

2024-05-28 09:38

reporter   ~0017741

May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: May 28 11:31:59 fadc6a0236ba sogod [63]: <0x0x5560b2b0d430[SOGoActiveSyncDispatcher]> EAS - request for device XXX: <?xml version="1.0"?>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: May 28 11:31:59 fadc6a0236ba syslog-ng[10]: Error processing log message: <!DOCTYPE ActiveSync PUBLIC "-//MICROSOFT//DTD ActiveSync//EN" "http://www.microsoft.com/&quot;>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <Sync xmlns="AirSync:">
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <Collections>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <Collection>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <SyncKey>0</SyncKey>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <CollectionId>mail%2FShared</CollectionId>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <Options>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <FilterType>5</FilterType>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <MIMETruncation>1</MIMETruncation>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <MIMESupport>0</MIMESupport>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <BodyPreference xmlns="AirSyncBase:">
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <Type>1</Type>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <TruncationSize>500</TruncationSize>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </BodyPreference>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Options>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Collection>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Collections>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Sync>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: <Class>Calendar</Class>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Folder>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Folders>
May 28 11:31:59 mail-host docker/mailcowdockerized-sogo-mailcow-1[971]: </Ping>

No response this request just comes over and over.

POST /Microsoft-Server-ActiveSync?User=XXX@XXX.com&DeviceId=XXX&DeviceType=iPhone&Cmd=Sync HTTP/2.0" 200 0 "-" "Apple-iPhone16C1/2105.236

This spams over and over again.
With direct disconnect after it than it connects back again and disconnects directly after it.
Again and again and again and again.

SilvanNagl

SilvanNagl

2024-10-17 14:18

reporter   ~0017916

maild on apple phone says:

"Folder item sync task 0x500988280 is using key (null) for folder mail%2FShared"

This aligns to the above error message.

jorgeavlobo

jorgeavlobo

2026-10-26 17:06

reporter   ~0018594

Still reproducible on SOGo 5.12.12 (mailcow-dockerized 2026-10, image ghcr.io/mailcow/sogo:5.12.12-1), iOS ActiveSync (Apple-iPhone Mail, EAS via /Microsoft-Server-ActiveSync).

Setup: users have full access (ACL) to a shared mailbox exposed by Dovecot's shared namespace (prefix "Shared/%u/", subscriptions=no, list=children). In the EAS folder list the device sees the virtual parent "Shared" and "Shared/<shared-mailbox>" plus its four real subfolders.

Symptom: affected iPhones send Cmd=Sync at 0000082:0000050-170 requests/min per device (no Ping), each answered HTTP 200 with an empty body. With EASDebug enabled, 0000113:0000100% of these requests are initial syncs for the two non-selectable parents only:

&lt;Sync>&lt;Collections>&lt;Collection>
  &lt;SyncKey>0&lt;/SyncKey>
  &lt;CollectionId>mail%2FShared&lt;/CollectionId>
&lt;/Collection>&lt;/Collections>&lt;/Sync>

... same with &lt;CollectionId>mail%2FShared%2F&lt;shared-mailbox>&lt;/CollectionId>

SOGo never returns a new SyncKey or a Status for them, so the client retries every ~0.4 s. The real folders (Inbox, Sent, subfolders of the shared mailbox, etc.) sync normally with advancing SyncKeys. nginx access log excerpt (placeholders):

&lt;ip> - &lt;user> [&lt;time>] &quot;POST /Microsoft-Server-ActiveSync?User=&lt;user>&DeviceId=&lt;id>&DeviceType=iPhone&Cmd=Sync HTTP/2.0&quot; 200 0 &quot;-&quot; &quot;Apple-iPhone&lt;model>/&lt;build>&quot;

(repeated ~100x per minute). The iOS-side message matches the original report: "using key (null) for folder mail%2FShared".

What we checked: sogo-tool manage-eas listfolders &lt;user> &lt;device> lists both "Shared" and "Shared/<shared-mailbox>" (and the subfolders) for the affected device. The loop is network/device dependent (not all devices of the same user loop at the same time) and a SOGo restart pauses it temporarily. Removing the share stops it, which is not an option for us.

Hypothesis (NOT confirmed): in ActiveSync/SOGoActiveSyncDispatcher+Sync.m, processSyncCollection, when no folderMetadata exists for a folder the code asks for FolderSync (Status 12), except for roots of shared mailboxes (SOGoMailNamespace), where it returns without writing anything ("We skip root-folders for shared mailboxes", from the change for 0003460). That would yield exactly a 200 response with no <Collection>, SyncKey or Status. We did not see the log line "no folderMetadata found" in our debug output, so this may be a different code path, and "Shared/<shared-mailbox>" is a SOGoMailFolder rather than a namespace root, so it may not be the same branch.

Suggestion: either do not advertise these non-selectable virtual parents in FolderSync, or answer their initial Sync with a valid empty Collection (SyncKey 1, Status 1) so clients stop retrying.

Happy to provide more debug output (sanitized) if useful.

jorgeavlobo

jorgeavlobo

2026-10-26 22:25

reporter   ~0018595

Still reproducible on SOGo 5.12.12 (mailcow-dockerized 2026-10, image ghcr.io/mailcow/sogo:5.12.12-1), iOS ActiveSync (Apple-iPhone Mail, EAS via /Microsoft-Server-ActiveSync).

ENVIRONMENT

SOGo 5.12.12, mailcow-dockerized 2026-10, Dovecot as IMAP server. Users have full access (ACL) to a shared mailbox exposed by Dovecot's shared namespace (prefix "Shared/%u/", subscriptions=no, list=children). In the EAS folder list the device sees the virtual parent "Shared" and "Shared/<shared-mailbox>" plus its four real subfolders. Clients: iPhone (native Mail, EAS).

SYMPTOM

Affected iPhones send Cmd=Sync at 0000082:0000050-170 requests/min per device (no Ping), each answered HTTP 200 with an empty body. With EASDebug enabled, 0000113:0000100% of these requests are initial syncs for the two non-selectable parents only:

&lt;Sync>&lt;Collections>&lt;Collection>
  &lt;SyncKey>0&lt;/SyncKey>
  &lt;CollectionId>mail%2FShared&lt;/CollectionId>
&lt;/Collection>&lt;/Collections>&lt;/Sync>

... same with &lt;CollectionId>mail%2FShared%2F&lt;shared-mailbox>&lt;/CollectionId>

SOGo never returns a new SyncKey or a Status for them, so the client retries every ~0.4 s. The real folders (Inbox, Sent, subfolders of the shared mailbox, etc.) sync normally with advancing SyncKeys. nginx access log excerpt (placeholders):

&lt;ip> - &lt;user> [&lt;time>] &quot;POST /Microsoft-Server-ActiveSync?User=&lt;user>&DeviceId=&lt;id>&DeviceType=iPhone&Cmd=Sync HTTP/2.0&quot; 200 0 &quot;-&quot; &quot;Apple-iPhone&lt;model>/&lt;build>&quot;

(repeated ~100x per minute). The iOS-side message matches the original report: "using key (null) for folder mail%2FShared".

WHAT WE CHECKED

"sogo-tool manage-eas listfolders <user> <device>" lists both "Shared" and "Shared/<shared-mailbox>" (and the subfolders) for the affected device. The loop is network/device dependent (not all devices of the same user loop at the same time) and a SOGo restart pauses it temporarily. Removing the share stops it, which is not an option for us. We did not see the debug line "EAS - processSyncCollection: no folderMetadata found" for these requests.

ANALYSIS (source read: tag SOGo-5.12.12, line numbers refer to that tag)

CONFIRMED from reading the source (not from a runtime trace):

  1. ActiveSync/SOGoActiveSyncDispatcher+Sync.m, -processSync:inResponse: (ends at ~line 2715-2718) only writes a <Collections> body if changeDetected is YES or MS-ASProtocolVersion is 2.5/12.0. Otherwise the response body stays empty, i.e. HTTP 200 with Content-Length 0, which is exactly what nginx logs.

  2. In -processSyncCollection:inBuffer:changeDetected:maxSyncResponseSize: (line 1872), a normal initial request (SyncKey 0) on an existing folder always sets *changeDetected = YES (the "if ([syncKey isEqualToString: @"0"])" branch) and appends a <Collection> with Status. So an empty 200 for SyncKey 0 can only come from one of the early "return;" statements that leave changeDetected untouched:
    a) line 1897, "if (collection == nil)": the code returns silently ("Collection not found - next folderSync will do the cleanup"; the Status 8 response is commented out because Outlook doesn't like it);
    b) line 1918-1925, empty folderMetadata and collection is a SOGoMailNamespace: returns silently ("We skip root-folders for shared mailboxes", the 0003460 change).

  3. FolderSync does advertise these virtual parents. SoObjects/Mailer/SOGoMailAccount.m, -imapFolderGUIDs (line 968, GUID fallback at lines 0000162:0001013-1027) deliberately assigns the folder name as "GUID" for the "Shared"/"Other users" namespace folders and for IMAP folders flagged \NonExistent or \Noselect together with \HasChildren (the Dovecot mail_shared_explicit_inbox case, see the code comment there). ActiveSync/SOGoActiveSyncDispatcher.m, -processFolderSync: (line 821) then emits an <Add> for them as normal mail folders (ServerId mail/<name>), so the device is told to sync a folder that is not selectable.

  4. ActiveSync/SOGoActiveSyncDispatcher.m, -collectionFromId:type: (line 313) returns nil for mail folders when "[collection exists]" is NO. SoObjects/Mailer/SOGoMailFolder.m -exists (line 1215) calls -doesMailboxExistAtURL: from SOPE (NGImap4Connection), which, if the folder is not in its hierarchy cache, does an IMAP STATUS (UIDVALIDITY) on the mailbox.

HYPOTHESIS (not confirmed at runtime):

For the Dovecot shared-namespace parents ("Shared", "Shared/<shared-mailbox>", LIST flags \NonExistent/\Noselect), the IMAP STATUS fails, -exists returns NO, collectionFromId: returns nil and processSyncCollection takes branch (a) above. This fits our observations: no "no folderMetadata found" log line (that line is only reached when collection != nil, i.e. it is not branch (b)) and an empty HTTP 200 for SyncKey 0. We have not verified the IMAP STATUS result or the branch taken with a debugger/extra logging; if the SOPE hierarchy cache happens to report these folders as existing, the flow would be different (collection != nil, folderMetadata present from FolderSync) and this patch would not apply to that case. Please correct us if the flow is not what we describe. Note that the earlier hypothesis about the SOGoMailNamespace branch ("We skip root-folders...") alone does not explain "Shared/<shared-mailbox>", because that one is looked up as a SOGoMailFolder, not a SOGoMailNamespace (SOGoMailAccount.m -lookupName:inContext:acquire: only returns SOGoMailNamespace for the namespace prefixes reported by IMAP NAMESPACE); branch (a) covers both.

PROPOSED FIX

Smallest change we could think of: when the collection cannot be opened but the folder is currently listed by -imapFolderGUIDs (i.e. FolderSync advertises it), answer the initial Sync (SyncKey 0) with a valid, empty <Collection> (Class Email, SyncKey 1, CollectionId, Status 1, no commands) and set *changeDetected so the response is actually written. All other cases keep the previous behaviour (stale/deleted folders that are not in the current listing still return silently, so the "next folderSync will do the cleanup" logic and the Outlook behaviour are untouched). The patch is against tag SOGo-5.12.12:

diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m
index 57fae8b..1ef3d16 100644
--- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m
+++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m
@@ -1904,6 +1904,24 @@ FIXME
       //[theBuffer appendFormat: @&quot;&lt;CollectionId>%@&lt;/CollectionId>&quot;, collectionId];
       //[theBuffer appendFormat: @&quot;&lt;Status>%d&lt;/Status>&quot;, 8];
       //[theBuffer appendString: @&quot;&lt;/Collection>&quot;];
+
+      // Non-selectable parents of shared mailboxes (e.g. Dovecot &quot;Shared&quot; or &quot;Shared/jdoe@example.com&quot;
+      // flagged \NonExistent or \Noselect) are advertised by FolderSync (see -imapFolderGUIDs) but
+      // can't be opened, so collectionFromId:type: returns nil. Answer the initial Sync with an empty
+      // collection instead of an empty HTTP response, otherwise some clients retry endlessly.
+      if ([syncKey isEqualToString: @&quot;0&quot;] && folderType == ActiveSyncMailFolder &&
+          [imapFolderGUIDS objectForKey: [NSString stringWithFormat: @&quot;folder%@&quot;, realCollectionId]])
+        {
+          [theBuffer appendString: @&quot;&lt;Collection>&quot;];
+          [theBuffer appendString: @&quot;&lt;Class>Email&lt;/Class>&quot;];
+          [theBuffer appendString: @&quot;&lt;SyncKey>1&lt;/SyncKey>&quot;];
+          [theBuffer appendFormat: @&quot;&lt;CollectionId>%@&lt;/CollectionId>&quot;, collectionId];
+          [theBuffer appendFormat: @&quot;&lt;Status>%d&lt;/Status>&quot;, 1];
+          [theBuffer appendString: @&quot;&lt;/Collection>&quot;];
+
+          *changeDetected = YES;
+        }
+
       return;
     }

The same file is attached as sogo-bug5872-proposed.patch (git apply, -p1 from the source root).

VALIDATION

What was done: the diff was generated against a fresh checkout of tag SOGo-5.12.12 and "git apply --check" on a clean tree succeeds. The relevant functions were read in full.
What was NOT done: the patch was not compiled and not runtime-tested (no GNUstep build environment and no SOGo test instance with a Dovecot shared namespace here); the IMAP STATUS behaviour in the hypothesis was not traced. Please treat it as a proposal to review, not as a tested fix.

RISKS / ALTERNATIVES

  • Only the initial request (SyncKey 0) is answered. If a client then sends Sync with SyncKey 1 for the same folder, the code still returns silently as before for that follow-up; whether iOS does that is unknown to us. If it does, the same early return could echo the received SyncKey with Status 1 (probably only when no HeartbeatInterval was sent, to avoid a tight loop for heartbeat clients).
  • Alternative A: do not advertise non-selectable virtual parents in FolderSync (skip them in -processFolderSync: and re-parent their children to the nearest advertised ancestor or to "0"). Cleaner for clients but a bigger behaviour change (folder tree shown on devices changes, cache cleanup of already-synced devices).
  • Alternative B: return Status 12 (FolderSync required) or Status 8 for unopenable collections. We did not propose this because FolderSync would simply advertise the folder again (possible new loop) and the Status 8 response is explicitly commented out in the source because of Outlook.
  • The new code relies on the ivar imapFolderGUIDS, which -globallyUniqueIDToIMAPFolderName:type: has already populated a few lines before in the same method.

WORKAROUND

None that is acceptable for us so far. Removing the share stops the loop, and restarting SOGo only pauses it temporarily.

Happy to provide more debug output (sanitized) or to test a build with the patch if someone can point us to the preferred way for the mailcow image.

Issue History

Date Modified Username Field Change
2023-09-20 12:09 SilvanNagl New Issue
2023-09-28 07:13 SilvanNagl Note Added: 0017317
2023-09-28 07:13 SilvanNagl File Added: 2023-09-28-091318_grim.png
2023-09-28 07:49 SilvanNagl Note Added: 0017318
2023-09-28 10:00 qhivert Note Added: 0017320
2023-09-28 10:00 qhivert Assigned To => qhivert
2023-09-28 10:00 qhivert Status new => feedback
2023-10-25 12:50 SilvanNagl Note Added: 0017400
2023-10-25 12:50 SilvanNagl Status feedback => assigned
2023-12-07 11:26 SilvanNagl Note Added: 0017491
2023-12-15 09:17 SilvanNagl Note Added: 0017504
2023-12-15 09:54 qhivert Note Added: 0017505
2023-12-15 09:55 qhivert Status assigned => feedback
2024-01-09 16:12 SilvanNagl Note Added: 0017530
2024-01-09 16:12 SilvanNagl Status feedback => assigned
2024-01-09 16:13 SilvanNagl Note Added: 0017531
2024-02-14 11:02 SilvanNagl Note Added: 0017587
2024-04-18 13:40 SilvanNagl Note Added: 0017711
2024-04-29 12:26 qhivert Note Added: 0017717
2024-04-30 19:09 tfu Note Added: 0017720
2024-05-28 09:38 SilvanNagl Note Added: 0017741
2024-10-17 14:18 SilvanNagl Note Added: 0017916
2026-10-26 17:06 jorgeavlobo Note Added: 0018594
2026-10-26 22:25 jorgeavlobo Note Added: 0018595