You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "prosgarz35 (via GitHub)" <gi...@apache.org> on 2026/09/24 09:02:55 UTC
[PR] [IMPROVEMENT] PostgresMessageMapper: save body content before UID allocation and cleanup move [james-project]
prosgarz35 opened a new pull request, #3202:
URL: https://github.com/apache/james-project/pull/3202
### Rationale & Context
Currently, in `PostgresMessageMapper.addReactive`, `setNewUidAndModSeq(message)` was invoked before calling `saveBodyContent(message)`.
`setNewUidAndModSeq` immediately commits an increment to `mailbox_last_uid` and `mailbox_highest_modseq` in PostgreSQL.
If the subsequent external blob storage save fails (e.g. S3 timeout, transient disk failure, quota exceeded), the operation terminates with an error, but the allocated UID/ModSeq in PostgreSQL has already been committed. This
creates gaps in the mailbox UID sequence (`UID gap`), which may cause strict IMAP clients to report synchronization issues or trigger cache invalidation.
Furthermore, `move` and `move(Mailbox, List<MailboxMessage>)` in `PostgresMessageMapper` contained redundant blocking overrides when default reactive implementations in `MessageMapper` already handle batch moves cleanly.
### Changes
1. **Reorder storage steps in `PostgresMessageMapper.addReactive`**:
- Save body content to `BlobStore` *first*.
- Only allocate and increment `UID`/`ModSeq` once blob persistence succeeds.
- If blob upload fails, no UID gaps or database modifications are left behind.
2. **Clean up `move` contract in `PostgresMessageMapper`**:
- Delegate single-message blocking `move` via `MailboxReactorUtils.block(moveReactive(mailbox, original))`.
- Remove redundant `move(Mailbox, List<MailboxMessage>)` override to let the default interface method handle batch processing reactively.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] [IMPROVEMENT] PostgresMessageMapper: save body content before UID allocation and cleanup move [james-project]
Posted by "prosgarz35 (via GitHub)" <gi...@apache.org>.
prosgarz35 closed pull request #3202: [IMPROVEMENT] PostgresMessageMapper: save body content before UID allocation and cleanup move
URL: https://github.com/apache/james-project/pull/3202
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] [IMPROVEMENT] PostgresMessageMapper: save body content before UID allocation and cleanup move [james-project]
Posted by "prosgarz35 (via GitHub)" <gi...@apache.org>.
prosgarz35 commented on PR #3202:
URL: https://github.com/apache/james-project/pull/3202#issuecomment-5825124296
Thanks for the clarification @chibenwa, that makes complete sense!
I agree that gaps in UID/ModSeq sequences are standard and expected IMAP behavior (e.g. concurrent expunges or systems like Cyrus with global modseqs), rather than an issue that requires reordering storage persistence steps.
Closing this PR accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org