[GH-ISSUE #447] autoreply error when query on postfix_autoreply_arhistoric returns more than one item #432

Closed
opened 2026-02-27 11:11:44 +03:00 by kerem · 4 comments
Owner

Originally created by @tonioo on GitHub (Dec 4, 2013).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/447

Originally assigned to: @tonioo on GitHub.

Originally created by Fabrice Flore-Thébault on 2013-08-22T07:12:34Z

It seems when the query on postfix_autoreply_arhistoric returns more than one value, the autoreply script gets confused.

I believe we have 2 issues there:

is it normal that we have same sender twice with same armessage_id ? maybe this should be avoided ?

maybe we should have a query which will always return one value, even when we have same sender twice with same armessage_id.

for now i quickly fixed the issue by deleting the content of this table ...

Final-Recipient: rfc822; "user@domain.tld"@autoreply.domain.tld
Original-Recipient: rfc822;user@domain.tld
Action: failed
Status: 5.3.0
Diagnostic-Code: x-unix; Traceback (most recent call last): File
"/srv/modoboa/manage.py", line 11, in 
execute_manager(settings) File
"/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", line
459, in execute_manager utility.execute() File
"/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", line
382, in execute self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/dist-packages/django/core/management/base.py",
line 196, in run_from_argv self.execute(*args, **options.__dict__)
File "/usr/lib/python2.6/dist-packages/django/core/management/base.py",
line 232, in execute output = self.handle(*args, **options) File
"/usr/local/lib/python2.6/dist-packages/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py",
line 61, in handle send_autoreply(sender, mbox, armessage) File
"/usr/local/lib/python2.6/dist-packages/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py",
line 21, in send_autoreply lastar =
ARhistoric.objects.get(armessage=armessage.id, sender=sender) File
"/usr/lib/python2.6/dist-packages/django/db/models/manager.py", line 131,
in get return self.get_query_set().get(*args, **kwargs) File
"/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 368, in
get % (self.model._meta.object_name, num, kwargs))
modoboa.extensions.postfix_autoreply.models.MultipleObjectsReturned: get()
returned more than one ARhistoric -- it returned 2! Lookup parameters were {'sender': 'user@domain.tld', 'armessage': 17L}
mysql> SELECT *
    -> FROM `postfix_autoreply_arhistoric`
    -> WHERE sender LIKE 'user@domain.tld'
    -> ;
+--------------+-----+---------------------+-----------------+
| armessage_id | id  | last_sent           | sender          |
+--------------+-----+---------------------+-----------------+
|            3 |  26 | 2013-05-10 09:32:09 | user@domain.tld |
|            3 |  27 | 2013-05-10 09:32:09 | user@domain.tld |
|            7 |  28 | 2013-05-10 09:32:09 | user@domain.tld |
|            7 |  29 | 2013-05-10 09:32:09 | user@domain.tld |
|            5 |  30 | 2013-05-10 09:32:10 | user@domain.tld |
|            5 |  31 | 2013-05-10 09:32:10 | user@domain.tld |
|            8 |  61 | 2013-05-15 09:01:23 | user@domain.tld |
|            8 |  62 | 2013-05-15 09:01:23 | user@domain.tld |
|           10 | 134 | 2013-07-26 11:45:22 | user@domain.tld |
|           11 | 135 | 2013-07-31 15:26:50 | user@domain.tld |
|           12 | 136 | 2013-08-16 15:33:35 | user@domain.tld |
|           16 | 364 | 2013-08-14 11:55:11 | user@domain.tld |
|           19 | 419 | 2013-08-20 18:01:08 | user@domain.tld |
|           18 | 425 | 2013-08-20 12:50:37 | user@domain.tld |
+--------------+-----+---------------------+-----------------+

Originally created by @tonioo on GitHub (Dec 4, 2013). Original GitHub issue: https://github.com/modoboa/modoboa/issues/447 Originally assigned to: @tonioo on GitHub. **Originally created by Fabrice Flore-Thébault on 2013-08-22T07:12:34Z** It seems when the query on postfix_autoreply_arhistoric returns more than one value, the autoreply script gets confused. I believe we have 2 issues there: # is it normal that we have same sender twice with same armessage_id ? maybe this should be avoided ? # maybe we should have a query which will always return one value, even when we have same sender twice with same armessage_id. for now i quickly fixed the issue by deleting the content of this table ... <pre> Final-Recipient: rfc822; "user@domain.tld"@autoreply.domain.tld Original-Recipient: rfc822;user@domain.tld Action: failed Status: 5.3.0 Diagnostic-Code: x-unix; Traceback (most recent call last): File "/srv/modoboa/manage.py", line 11, in <module> execute_manager(settings) File "/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", line 459, in execute_manager utility.execute() File "/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.6/dist-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.6/dist-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.6/dist-packages/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py", line 61, in handle send_autoreply(sender, mbox, armessage) File "/usr/local/lib/python2.6/dist-packages/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py", line 21, in send_autoreply lastar = ARhistoric.objects.get(armessage=armessage.id, sender=sender) File "/usr/lib/python2.6/dist-packages/django/db/models/manager.py", line 131, in get return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.6/dist-packages/django/db/models/query.py", line 368, in get % (self.model._meta.object_name, num, kwargs)) modoboa.extensions.postfix_autoreply.models.MultipleObjectsReturned: get() returned more than one ARhistoric -- it returned 2! Lookup parameters were {'sender': 'user@domain.tld', 'armessage': 17L} </pre> <pre> mysql> SELECT * -> FROM `postfix_autoreply_arhistoric` -> WHERE sender LIKE 'user@domain.tld' -> ; +--------------+-----+---------------------+-----------------+ | armessage_id | id | last_sent | sender | +--------------+-----+---------------------+-----------------+ | 3 | 26 | 2013-05-10 09:32:09 | user@domain.tld | | 3 | 27 | 2013-05-10 09:32:09 | user@domain.tld | | 7 | 28 | 2013-05-10 09:32:09 | user@domain.tld | | 7 | 29 | 2013-05-10 09:32:09 | user@domain.tld | | 5 | 30 | 2013-05-10 09:32:10 | user@domain.tld | | 5 | 31 | 2013-05-10 09:32:10 | user@domain.tld | | 8 | 61 | 2013-05-15 09:01:23 | user@domain.tld | | 8 | 62 | 2013-05-15 09:01:23 | user@domain.tld | | 10 | 134 | 2013-07-26 11:45:22 | user@domain.tld | | 11 | 135 | 2013-07-31 15:26:50 | user@domain.tld | | 12 | 136 | 2013-08-16 15:33:35 | user@domain.tld | | 16 | 364 | 2013-08-14 11:55:11 | user@domain.tld | | 19 | 419 | 2013-08-20 18:01:08 | user@domain.tld | | 18 | 425 | 2013-08-20 12:50:37 | user@domain.tld | +--------------+-----+---------------------+-----------------+ </pre>
kerem 2026-02-27 11:11:44 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2013-08-25T14:47:53Z

Hi,

this behaviour is not normal. Only one record per ARmessage must exist into the ARhistoric table. The only explanation I see for your issue is that the autoreply script was called twice for the same message and at the same time...

<!-- gh-comment-id:29816528 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2013-08-25T14:47:53Z** Hi, this behaviour is not normal. Only one record per ARmessage must exist into the ARhistoric table. The only explanation I see for your issue is that the autoreply script was called twice for the same message and at the same time...
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2013-08-25T14:51:00Z

Applied in changeset commit:48f70e98cb47344835bf0ebe7507d78bc85d61b0.

<!-- gh-comment-id:29816529 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2013-08-25T14:51:00Z** Applied in changeset commit:48f70e98cb47344835bf0ebe7507d78bc85d61b0.
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2013-09-01T14:29:17Z

Applied in changeset commit:d1616f53077c7f13311be169357ea5b459bf63cc.

<!-- gh-comment-id:29816530 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2013-09-01T14:29:17Z** Applied in changeset commit:d1616f53077c7f13311be169357ea5b459bf63cc.
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2013-09-01T14:29:18Z

Applied in changeset commit:12dfcdc3f11f79664d669564ce8a5f42789c9738.

<!-- gh-comment-id:29816532 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2013-09-01T14:29:18Z** Applied in changeset commit:12dfcdc3f11f79664d669564ce8a5f42789c9738.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#432
No description provided.