Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-20518

"IllegalStateException: Queue full" exception in the logs when too many emails to send

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 15.0-rc-1
    • 11.10
    • Mail
    • None
    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      The following can happen when there are more mails to send than the max queue size.

      2022-12-15 13:33:47,578 [Mail Prepare Thread] ERROR o.x.m.i.DatabaseMailListener   - Failure during preparation phase of thread [226f9aff-7fd4-409e-8fbd-0455ff1894fe]
      java.lang.IllegalStateException: Queue full
              at java.util.AbstractQueue.add(AbstractQueue.java:98)
              at org.xwiki.mail.internal.thread.AbstractMailQueueManager.addToQueue(AbstractMailQueueManager.java:53)
              at org.xwiki.mail.internal.thread.PrepareMailRunnable.prepareSingleMail(PrepareMailRunnable.java:190)
              at org.xwiki.mail.internal.thread.PrepareMailRunnable.prepareMail(PrepareMailRunnable.java:123)
              at org.xwiki.mail.internal.thread.PrepareMailRunnable.run(PrepareMailRunnable.java:78)
              at java.lang.Thread.run(Thread.java:748)
      

      Note that this behavior was not intended as the javadoc says:

       /**
           * @return the max size of the send queue. When this size is reached calls to put new elements on the queue will
           *         block
           * @since 11.6RC1
           */
          default int getSendQueueCapacity()
          {
              return 1000;
          }
      

      The reason is probably the usage of "add" at https://github.com/xwiki/xwiki-platform/blob/dbdb22e5815ce56331279cb2fcce2bf10665cdd2/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/src/main/java/org/xwiki/mail/internal/thread/AbstractMailQueueManager.java#L53

      Note that XWIKI-16309 introduced a new API:

          /**
           * Add a mail on the queue for processing, waiting a max of timeout.
           *
           * @param mailQueueItem the object representing the mail item to add to the queue
           * @param timeout how long to wait before giving up, in units of {@code unit}
           * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter
           * @throws InterruptedException if it times out i.e if the queue doesn't have any empty slot freed in the specified
           *         timeout time
           * @since 11.6RC1
           */
          default void addMessage(T mailQueueItem, long timeout, TimeUnit unit) throws InterruptedException
      

      But it's not used yet and "addtoQueue" is still used at https://github.com/xwiki/xwiki-platform/blob/9517ab02a48cbb6d07f535fdc43e84525c77c23b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/src/main/java/org/xwiki/mail/internal/thread/PrepareMailRunnable.java#L190

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: