quantranhong1999 commented on code in PR #2551:
URL: https://github.com/apache/james-project/pull/2551#discussion_r1875581536
##########
mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/dao/PostgresMailboxDAO.java:
##########
@@ -150,15 +151,34 @@ private Mono<MailboxId> update(Mailbox mailbox) {
.switchIfEmpty(Mono.error(new
MailboxNotFoundException(mailbox.getMailboxId())));
}
- public Mono<Void> upsertACL(MailboxId mailboxId, MailboxACL acl) {
+ public Mono<Void> upsertACL(MailboxId mailboxId, MailboxACL acl, Long
currentAclVersion) {
return postgresExecutor.executeReturnAffectedRowsCount(dslContext ->
Mono.from(dslContext.update(TABLE_NAME)
.set(MAILBOX_ACL, MAILBOX_ACL_TO_HSTORE_FUNCTION.apply(acl))
- .where(MAILBOX_ID.eq(((PostgresMailboxId) mailboxId).asUuid()))))
+ .set(MAILBOX_ACL_VERSION, currentAclVersion + 1)
+ .where(MAILBOX_ID.eq(((PostgresMailboxId) mailboxId).asUuid()))
+ .and(MAILBOX_ACL_VERSION.eq(currentAclVersion))))
.filter(count -> count > 0)
.switchIfEmpty(Mono.error(new RuntimeException("Upsert mailbox acl
failed with mailboxId " + mailboxId.serialize())))
.then();
}
+ public Mono<Void> upsertACL(MailboxId mailboxId, MailboxACL acl) {
+ return postgresExecutor.executeReturnAffectedRowsCount(dslContext ->
Mono.from(dslContext.update(TABLE_NAME)
+ .set(MAILBOX_ACL, MAILBOX_ACL_TO_HSTORE_FUNCTION.apply(acl))
+ .set(DSL.field(MAILBOX_ACL_VERSION.getName()), (Object)
DSL.field(MAILBOX_ACL_VERSION.getName() + " + 1"))
+ .where(MAILBOX_ID.eq(((PostgresMailboxId)
mailboxId).asUuid()))))
+ .filter(count -> count > 0)
+ .switchIfEmpty(Mono.error(new RuntimeException("Upsert mailbox acl
failed with mailboxId " + mailboxId.serialize())))
Review Comment:
IMO we should add retries. And BTW the error seems not clear about the root
cause to me.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]