Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop if sending emails fails #1207

Open
reverendus7 opened this issue Mar 13, 2024 · 1 comment
Open

Infinite loop if sending emails fails #1207

reverendus7 opened this issue Mar 13, 2024 · 1 comment

Comments

@reverendus7
Copy link

Steps to reproduce

  1. Misconfigure your mail server
  2. Do some folder/file sharing (in order to accumulate emails to send)
  3. Launch the script for flushing emails

Expected behaviour

There should not be infinite tries in re-sending failed emails.

Actual behaviour

The infinite loop in trying to send emails is making log file huge. Using a cron for sending emails makes it even worse. It also has impact on cpu usage since the script never ends (and new scripts are launched every-time the cron requires).

Server configuration

ownCloud version: 2.7.2

No errors have been found.

Logs

ownCloud log (data/owncloud.log)

{"reqId":"***","level":3,"time":"2024-03-13T09:45:49+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"--","url":"--","message":"Caused by: {\"Exception\":\"Swift_IoException\",\"Message\":\"Connection to tcp:\\\/\\\/****:25 Timed Out\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/AbstractSmtpTransport.php(469): Swift_Transport_StreamBuffer->readLine()\\n#1 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/AbstractSmtpTransport.php(342): Swift_Transport_AbstractSmtpTransport->getFullResponse()\\n#2 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/EsmtpTransport.php(305): Swift_Transport_AbstractSmtpTransport->executeCommand()\\n#3 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/AbstractSmtpTransport.php(392): Swift_Transport_EsmtpTransport->executeCommand()\\n#4 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/AbstractSmtpTransport.php(499): Swift_Transport_AbstractSmtpTransport->doDataCommand()\\n#5 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/AbstractSmtpTransport.php(518): Swift_Transport_AbstractSmtpTransport->doMailTransaction()\\n#6 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/AbstractSmtpTransport.php(206): Swift_Transport_AbstractSmtpTransport->sendTo()\\n#7 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Mail\\\/Mailer.php(103): Swift_Transport_AbstractSmtpTransport->send()\\n#8 \\\/mnt\\\/data\\\/owncloud_data\\\/apps-external\\\/activity\\\/lib\\\/MailQueueHandler.php(305): OC\\\\Mail\\\\Mailer->send()\\n#9 \\\/mnt\\\/data\\\/owncloud_data\\\/apps-external\\\/activity\\\/lib\\\/MailQueueHandler.php(392): OCA\\\\Activity\\\\MailQueueHandler->sendMail()\\n#10 \\\/mnt\\\/data\\\/owncloud_data\\\/apps-external\\\/activity\\\/lib\\\/Command\\\/SendEmails.php(133): OCA\\\\Activity\\\\MailQueueHandler->sendAllEmailsToUser()\\n#11 \\\/mnt\\\/data\\\/owncloud_data\\\/apps-external\\\/activity\\\/lib\\\/Command\\\/SendEmails.php(90): OCA\\\\Activity\\\\Command\\\\SendEmails->sendBatch()\\n#12 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Command\\\/Command.php(255): OCA\\\\Activity\\\\Command\\\\SendEmails->execute()\\n#13 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Application.php(1021): Symfony\\\\Component\\\\Console\\\\Command\\\\Command->run()\\n#14 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Application.php(275): Symfony\\\\Component\\\\Console\\\\Application->doRunCommand()\\n#15 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/symfony\\\/console\\\/Application.php(149): Symfony\\\\Component\\\\Console\\\\Application->doRun()\\n#16 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Console\\\/Application.php(165): Symfony\\\\Component\\\\Console\\\\Application->run()\\n#17 \\\/var\\\/www\\\/owncloud\\\/console.php(116): OC\\\\Console\\\\Application->run()\\n#18 \\\/var\\\/www\\\/owncloud\\\/occ(11): require_once('\\\/var\\\/www\\\/ownclo...')\\n#19 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/swiftmailer\\\/swiftmailer\\\/lib\\\/classes\\\/Swift\\\/Transport\\\/StreamBuffer.php\",\"Line\":166}"}
{"reqId":"NP6AYAouxlR1NcfRJb7g","level":2,"time":"2024-03-13T09:45:52+00:00","remoteAddr":"","user":"--","app":"activity","method":"--","url":"--","message":"Couldn't send notification email to user ***** (Connection to tcp:\/\/*****:25 Timed Out})"}
@reverendus7
Copy link
Author

as a quick temporary fix, we modified the SendEmails.php file, in the execute method like this:

		//do {
			$users = $this->mqHandler->getAllUsers(self::BATCH_SIZE);
			$batchCount = \count($users);
			if ($batchCount === 0) {
				// queue is empty
				//break;
				return 0;
			}

			$this->sendBatch($users, $output);
			if ($progress !== null) {
				$progress->advance($batchCount);
			}
		//} while ($batchCount > 0);

In this way, we try to send emails only once per cron run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant