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