How to delete large numbers of held messages
We had a mail loop on one of our lists and ended up with over 51k messages in pending (held due to post not form a list member)
Trying to delete them from the web UI will take forever, as the largest pagination you can view is 200 at a time.
Tried to delete them from the Python interactive shell, but it looks like the API times out after a while.
Is there another way to delete all these unwanted held posts?
The problem comes after executing:
<block> reqs = list(adminlist.held) </block>
After a couple of minutes it comes back with:
<block> Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 445, in _make_request six.raise_from(e, None) File "<string>", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse response.begin() File "/usr/lib/python3.9/http/client.py", line 307, in begin version, status, reason = self._read_status() File "/usr/lib/python3.9/http/client.py", line 276, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen retries = retries.increment( File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/lib/python3/dist-packages/six.py", line 718, in reraise raise value.with_traceback(tb) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 445, in _make_request six.raise_from(e, None) File "<string>", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse response.begin() File "/usr/lib/python3.9/http/client.py", line 307, in begin version, status, reason = self._read_status() File "/usr/lib/python3.9/http/client.py", line 276, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/mailmanclient/restbase/connection.py", line 107, in call response = request( File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request resp = self.send(prep, **send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/lib/python3/dist-packages/mailmanclient/restobjects/mailinglist.py", line 123, in held response, content = self._connection.call( File "/usr/lib/python3/dist-packages/mailmanclient/restbase/connection.py", line 135, in call raise MailmanConnectionError( mailmanclient.restbase.connection.MailmanConnectionError: ('Could not connect to Mailman API: ', "ConnectionError(ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))")
</block>
On 4/21/22 14:56, Chris via Mailman-users wrote:
We had a mail loop on one of our lists and ended up with over 51k messages in pending (held due to post not form a list member)
Trying to delete them from the web UI will take forever, as the largest pagination you can view is 200 at a time.
Tried to delete them from the Python interactive shell, but it looks like the API times out after a while.
Is there another way to delete all these unwanted held posts?
I suggest the following in mailman shell
$ bin/mailman shell -l list.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.
The variable 'm' is the list.example.com mailing list
>>> from mailman.app.moderator import handle_message
>>> requestdb = IListRequests(m)
>>> for id, type in requestdb.held_requests:
... if type == RequestType.held_message:
... handle_message(m, id, Action.discard)
...
>>> commit()
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mark Sapiro wrote:
On 4/21/22 14:56, Chris via Mailman-users wrote:
We had a mail loop on one of our lists and ended up with over 51k messages in pending (held due to post not form a list member) Trying to delete them from the web UI will take forever, as the largest pagination you can view is 200 at a time. Tried to delete them from the Python interactive shell, but it looks like the API times out after a while. Is there another way to delete all these unwanted held posts? I suggest the following in mailman shell $ bin/mailman shell -l list.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. The variable 'm' is the list.example.com mailing list
from mailman.app.moderator import handle_message requestdb = IListRequests(m) for id, type in requestdb.held_requests: ... if type == RequestType.held_message: ... handle_message(m, id, Action.discard) ... commit()
Thanks for the reply, unfortunately that gives an error: Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: cannot unpack non-iterable _Request object
On 4/22/22 02:11, Chris via Mailman-users wrote:
Mark Sapiro wrote:
I suggest the following in mailman shell
>> $ bin/mailman shell -l list.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.
>> The variable 'm' is the list.example.com mailing list
>> >>> from mailman.app.moderator import handle_message
>> >>> requestdb = IListRequests(m)
>> >>> for id, type in requestdb.held_requests:
>> ... if type == RequestType.held_message:
>> ... handle_message(m, id, Action.discard)
>> ...
>> >>> commit()
Thanks for the reply, unfortunately that gives an error: Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: cannot unpack non-iterable _Request object
Sorry, my mistake.
Try this:
$ bin/mailman shell -l list.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.
The variable 'm' is the list.example.com mailing list
>>> from mailman.app.moderator import handle_message
>>> requestdb = IListRequests(m)
>>> for req in requestdb.held_requests:
... if req.request_type == RequestType.held_message:
... handle_message(m, req.id, Action.discard)
...
>>> commit()
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mark Sapiro wrote:
On 4/22/22 02:11, Chris via Mailman-users wrote:
Mark Sapiro wrote: I suggest the following in mailman shell
$ bin/mailman shell -l list.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. The variable 'm' is the list.example.com mailing list
from mailman.app.moderator import handle_message requestdb = IListRequests(m) for id, type in requestdb.held_requests: ... if type == RequestType.held_message: ... handle_message(m, id, Action.discard) ... commit()
Thanks for the reply, unfortunately that gives an error: Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: cannot unpack non-iterable _Request object Sorry, my mistake. Try this: $ bin/mailman shell -l list.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. The variable 'm' is the list.example.com mailing list
from mailman.app.moderator import handle_message requestdb = IListRequests(m) for req in requestdb.held_requests: ... if req.request_type == RequestType.held_message: ... handle_message(m, req.id, Action.discard) ... commit()
Perfect - thank you
Chris
participants (2)
-
lists@g1fef.co.uk
-
Mark Sapiro