Error 500 on held_messages page
Hello all,
we now have at least one mailing list (there may be more affected) that generates a 500 error when calling the held_messages page. After looking at the held messages via the mailman shell, we have identified three mails that have neither a subject nor a message body. How can we remove these three mails from the database?
This is the mailman shell command we used:
mailman shell -l listname@lists.example.com
<removed>
Welcome to the GNU Mailman shell
Use commit() to commit changes.
Use abort() to discard changes since the last commit.
Exit with ctrl+D does an implicit commit() but exit() does not.
Die Variable 'm' ist die listname@lists.example.com Mailingliste
>>> msg_db = getUtility(IMessageStore)
>>> req_db = IListRequests(m)
>>> reqs = list(req_db.held_requests)
>>> for req in reqs:
... print('{}: {}'.format(req.id, req.request_type))
...
32598: 1
[...]
107656: 1
107737: 1
107758: 1
>>> from mailman.app.moderator import handle_message
>>> handle_message(m, 107758, Action.discard)
>>> reqs = list(req_db.held_requests)
>>> for req in reqs:
... print('{}: {}'.format(req.id, req.request_type))
...
32598: 1
[...]
107656: 1
107737: 1
>>> handle_message(m, 92927, Action.discard)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/app/moderator.py", line 112, in handle_message
key, msgdata = requestdb.get_request(id)
TypeError: 'NoneType' object is not iterable
>>>
On 2/3/22 08:01, Stephan Krinetzki wrote:
Hello all,
we now have at least one mailing list (there may be more affected) that generates a 500 error when calling the held_messages page. After looking at the held messages via the mailman shell, we have identified three mails that have neither a subject nor a message body. How can we remove these three mails from the database?
This shouldn't be an issue, at least with Mailman core 3.3.5, unless I don't understand.
Note that there are 3 tables involved. The request (IListRequests), the pendings (IPended and IPendedKeyValue), and the held message (IMessageStore).
This is the mailman shell command we used:
mailman shell -l listname@lists.example.com <removed> Welcome to the GNU Mailman shell Use commit() to commit changes. Use abort() to discard changes since the last commit. Exit with ctrl+D does an implicit commit() but exit() does not. Die Variable 'm' ist die listname@lists.example.com Mailingliste >>> msg_db = getUtility(IMessageStore) >>> req_db = IListRequests(m) >>> reqs = list(req_db.held_requests) >>> for req in reqs: ... print('{}: {}'.format(req.id, req.request_type)) ... 32598: 1 [...] 107656: 1 107737: 1 107758: 1
OK, you have requests.
>>> from mailman.app.moderator import handle_message >>> handle_message(m, 107758, Action.discard) >>> reqs = list(req_db.held_requests) >>> for req in reqs: ... print('{}: {}'.format(req.id, req.request_type)) ... 32598: 1 [...] 107656: 1 107737: 1
OK, you discarded the message held with request id 107758.
>>> handle_message(m, 92927, Action.discard) Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/app/moderator.py", line 112, in handle_message key, msgdata = requestdb.get_request(id) TypeError: 'NoneType' object is not iterable >>>
There is no request with id 92927. Why do you think there should be?
If by remove them from the database, you mean just from the messagestore, you can do (using your above)
msg_db.delete_message('the_message_id')
To delete a pending request for which there is no request id, e.g. the id 92927 above, you could do
pendings = getUtility(IPendings)
for token, data in pendings.find(pend_type='held message'):
if data and data['id'] == 92927:
pendings.confirm(token, expunge=True)
Mailman core 3.3.5 has a lot of changes to address this issue.
Also see https://gitlab.com/mailman/mailman/-/issues/946
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Hi Mark,
Mark Sapiro wrote:
Hello all, we now have at least one mailing list (there may be more affected) that generates a 500 error when calling the held_messages page. After looking at the held messages via the mailman shell, we have identified three mails that have neither a subject nor a message body. How can we remove these three mails from the database? This shouldn't be an issue, at least with Mailman core 3.3.5, unless I don't understand. Note that there are 3 tables involved. The request (IListRequests), the
On 2/3/22 08:01, Stephan Krinetzki wrote: pendings (IPended and IPendedKeyValue), and the held message (IMessageStore).
This is the mailman shell command we used: mailman shell -l listname@lists.example.com <removed> Welcome to the GNU Mailman shell Use commit() to commit changes. Use abort() to discard changes since the last commit. Exit with ctrl+D does an implicit commit() but exit() does not. Die Variable 'm' ist die listname@lists.example.com Mailingliste
msg_db = getUtility(IMessageStore) req_db = IListRequests(m) reqs = list(req_db.held_requests) for req in reqs: ... print('{}: {}'.format(req.id, req.request_type)) ... 32598: 1 [...] 107656: 1 107737: 1 107758: 1
OK, you have requests.
from mailman.app.moderator import handle_message handle_message(m, 107758, Action.discard) reqs = list(req_db.held_requests) for req in reqs: ... print('{}: {}'.format(req.id, req.request_type)) ... 32598: 1 [...] 107656: 1 107737: 1
OK, you discarded the message held with request id 107758.
handle_message(m, 92927, Action.discard) Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/app/moderator.py", line 112, in handle_message key, msgdata = requestdb.get_request(id) TypeError: 'NoneType' object is not iterable
There is no request with id 92927. Why do you think there should be?
Well, i truncated the list above (marked by [...]) but this message is there:
32598: 1
107788: 1
22449: 1
95736: 1
108279: 1
66937: 1
108367: 1
68261: 1
108379: 1
108411: 1
108587: 1
108596: 1
108723: 1
107881: 1
107891: 1
108814: 1
92927: 1
107963: 1
106486: 1
106488: 1
106526: 1
106577: 1
106682: 1
106818: 1
106857: 1
108076: 1
106926: 1
107044: 1
107146: 1
107152: 1
107153: 1
107204: 1
108199: 1
107210: 1
107329: 1
107394: 1
107447: 1
107531: 1
107562: 1
107594: 1
107656: 1
107737: 1
If by remove them from the database, you mean just from the messagestore, you can do (using your above) msg_db.delete_message('the_message_id')
Ok, thanks. With this code lines the message is deleted, right?
To delete a pending request for which there is no request id, e.g. the id 92927 above, you could do pendings = getUtility(IPendings) for token, data in pendings.find(pend_type='held message'): if data and data['id'] == 92927: pendings.confirm(token, expunge=True)
That didn't helped: mailman shell -l list@lists.example.com
Welcome to the GNU Mailman shell
Use commit() to commit changes.
Use abort() to discard changes since the last commit.
Exit with ctrl+D does an implicit commit() but exit() does not.
Die Variable 'm' ist die list@lists.example.com Mailingliste
>>> msg_db = getUtility(IMessageStore)
>>> req_db = IListRequests(m)
>>> reqs = list(req_db.held_requests)
>>> for req in reqs:
... print('{}: {}'.format(req.id, req.request_type))
...
32598: 1
107788: 1
22449: 1
95736: 1
108279: 1
66937: 1
108367: 1
68261: 1
108379: 1
108411: 1
108587: 1
108596: 1
108723: 1
107881: 1
107891: 1
108814: 1
92927: 1
107963: 1
106486: 1
106488: 1
106526: 1
106577: 1
106682: 1
106818: 1
106857: 1
108076: 1
106926: 1
107044: 1
107146: 1
107152: 1
107153: 1
107204: 1
108199: 1
107210: 1
107329: 1
107394: 1
107447: 1
107531: 1
107562: 1
107594: 1
107656: 1
107737: 1
>>> for req in reqs:
... print(req.key)
... for line in str(msg_db.get_message_by_id(req.key)).split("\n"):
... print(line)
... print('\n')
...
<1b35d982.85b92.16abbe857a6.Coremail.lusong@lsec.cc.ac.cn>
None
<08539546582c0560693f58ab0101bd83@airotrader.com>
<Mail Content, shorted out>
<1545090824.237969198@f452.i.mail.ru>
None
<tencent_41D5C02D27CAA4DD59BDF1A2@qq.com>
<Mail Content, shorted out>
<292716975.841376.1597725820301.JavaMail.zimbra@rri.res.in>
<Mail Content, shorted out>
<5d74c171c32303e88c9d8b86ac60ba48@blackroseradio.com>
<Mail Content, shorted out>
<DM6PR04MB38208B40539F3861A613098DB1260@DM6PR04MB3820.namprd04.prod.outlook.com>
<Mail Content, shorted out>
<eaefd169fb428442d9e3ce31b72bfdb4@wordenonwine.com>
<Mail Content, shorted out>
<2108728073.11037004.1643524877756.JavaMail.zimbra@caxias.rs.gov.br>
<Mail Content, shorted out>
<CANvwqssiPV7HgupqrYkgxGoFsKph=TW-mwNucs+NBwxs3Uw1bQ@mail.gmail.com>
<Mail Content, shorted out>
<c0b951ee190727163bce555a3a030f9f@optiboxes.com>
<Mail Content, shorted out>
<144a5727a850fea01910dfe9c427427e@licensedappraisal.com>
<Mail Content, shorted out>
<61ef2070.1c69fb81.f2f7e.23fc@mx.google.com>
<Mail Content, shorted out>
<b037941f4318324ab23a3ee7efcbf970@hollymillrun.com>
<Mail Content, shorted out>
<929ad585ea426a3835cf63058c22782c@airotrader.com>
<Mail Content, shorted out>
<180a36ee.2b.17afe0b825e.Coremail.carmark3@163.com>
None
<24abca1072b83535bbf2e39b6a825fc8@optiboxes.com>
<Mail Content, shorted out>
<CAK69=c9mFvOZq9ro7HavgYdOeo-oJ2_6h8SjQsBfcrxnpf_etA@mail.gmail.com>
<Mail Content, shorted out>
<5d7b548ab086bb47c0c6caacbff92c54@licensedappraisal.com>
<Mail Content, shorted out>
<062dfa1a2deb3ac136ecdfde1b4c6d74@optiboxes.com>
<Mail Content, shorted out>
<d517a99e8e9db94ddc8ecd1c6d226788@spiritsestates.com>
<Mail Content, shorted out>
<043051c1d7a64c04ce8c83c7a5e54eec@krswim.com>
<Mail Content, shorted out>
<2c42b1d628a43b1fc78471e873a0691d@totallyneat.com>
<Mail Content, shorted out>
<CALQ9jAcqu9yRj=EYn=DgA8unYRWkfUgFiL54bMiLxovc+JXcBw@mail.gmail.com>
<Mail Content, shorted out>
<1ffa446361bfdf49a71b8669165e6350@wordenonwine.com>
<Mail Content, shorted out>
<b9afc5d32f87320a8333093ffd0635f5@infnitsolutions.com>
<Mail Content, shorted out>
<f486ea12a6bcecec1b1e4a51f1be0719@penshaver.com>
<Mail Content, shorted out>
<CAPOYRqVmrwcdRQXwm56sM+0Ov1bcLqxFXFCrx5Rf3gVqj9nOgA@mail.gmail.com>
<Mail Content, shorted out>
<1412096130.6666950.1642348478679.JavaMail.zimbra@gorontaloprov.go.id>
<Mail Content, shorted out>
<40f51428847f7874d06b8b5ad50c745d@wordenonwine.com>
<Mail Content, shorted out>
<2a82c4a5e577658efc189f02fc13f520@nutriholding.com>
<Mail Content, shorted out>
[And a lot of more messages]
As you can see, there a some messages, that have no message body and i think that's the issue.
In the httpd.log of mailman:
2022-02-04 10:01:09 [FALCON] [ERROR] GET /3.1/lists/list@lists.example.com/held?count=10&page=1 => Traceback (most recent call last):
File "falcon/app.py", line 361, in falcon.app.App.__call__
File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/rest/post_moderation.py", line 182, in on_get
resource = self._make_collection(request)
File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/rest/helpers.py", line 182, in _make_collection
entries = [as_dict(resource) for resource in collection]
File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/rest/helpers.py", line 182, in <listcomp>
entries = [as_dict(resource) for resource in collection]
File "/opt/mailman/mailman-venv/lib64/python3.6/site-packages/mailman/rest/post_moderation.py", line 173, in _resource_as_dict
assert resource is not None, resource
AssertionError: None
[04/Feb/2022:10:01:09 +0100] "GET /3.1/lists/list@lists.example.com/held?count=10&page=1 HTTP/1.1" 500 38 "-" "GNU Mailman REST client v3.3.3"
Maybe that helps to identify the issue.
Mailman core 3.3.5 has a lot of changes to address this issue. Also see https://gitlab.com/mailman/mailman/-/issues/946
Hello again,
we have fixed the issue now:
mailman shell -l list@lists.example.com
Welcome to the GNU Mailman shell
Use commit() to commit changes.
Use abort() to discard changes since the last commit.
Exit with ctrl+D does an implicit commit() but exit() does not.
Die Variable 'm' ist die list@lists.example.com Mailingliste
>>> lr = IListRequests(m)
>>> for req in lr.held_requests:
... if lr.get_request(req.id) is None:
... print(req.id)
...
32598
22449
66937
68261
92927
>>>
With this IDs
DELETE FROM _request WHERE id IN (32598, 22449, 66937, 68261, 92927);
And the 500 error is gone.
On 2/4/22 04:57, Stephan Krinetzki wrote:
we have fixed the issue now:
Good.
mailman shell -l list@lists.example.com Welcome to the GNU Mailman shell Use commit() to commit changes. Use abort() to discard changes since the last commit. Exit with ctrl+D does an implicit commit() but exit() does not. Die Variable 'm' ist die list@lists.example.com Mailingliste >>> lr = IListRequests(m) >>> for req in lr.held_requests: ... if lr.get_request(req.id) is None: ... print(req.id) ... 32598 22449 66937 68261 92927 >>>
With this IDs
DELETE FROM _request WHERE id IN (32598, 22449, 66937, 68261, 92927);
And the 500 error is gone.
I'm glad you were able to fix it. Do you happen to have the content of those rows in the db before you deleted them? It would be interesting to know what that was to try to determine how that situation happened in the first place.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
Stephan Krinetzki