freescout-help-desk / freescout

FreeScout — Free self-hosted help desk & shared mailbox (Zendesk / Help Scout alternative)
https://freescout.net
GNU Affero General Public License v3.0
2.92k stars 482 forks source link

Fetch doesn't work until cache clear #2823

Closed afawaz2 closed 1 year ago

afawaz2 commented 1 year ago

We are getting a new issue where freescout does not fetch emails until we go and clear cache or force fetch. We don't see any stuck job in the queue but we have many processes doing fetch running for a long time.

image

freescout-helpdesk commented 1 year ago

Are you using Cloudron?

afawaz2 commented 1 year ago

No, I am using docker-compose from https://github.com/tiredofit/docker-freescout/blob/main/examples/docker-compose.yml

freescout-helpdesk commented 1 year ago

Are you using a modern Microsoft OAuth IMAP authentication or regular IMAP authentication?

You'll need to debug this: https://github.com/freescout-helpdesk/freescout/blob/dist/app/Console/Kernel.php#L105

afawaz2 commented 1 year ago

I have a mix, some use modern Microsoft oauth imap and one uses regular imap using Amazon. We are still suffering from the empty emails problem, so we are migrating to another provider.

I'll add some print statements for the $fetch_command_pids, how do you recommend I log the variable?

freescout-helpdesk commented 1 year ago

Try to figure out why this line does not kill existing fetch-emails processes: https://github.com/freescout-helpdesk/freescout/blob/dist/app/Console/Kernel.php#L118

afawaz2 commented 1 year ago

Will do, does this give you a hint? After killing the process I got the following laravel errors:

The process has been signaled with signal "9". {"exception":"[object] (Symfony\Component\Process\Exception\RuntimeException(code: 0): The process has been signaled with signal \"9\". at /www/html/overrides/symfony/process/Process.php:434) [stacktrace]

0 /www/html/overrides/symfony/process/Process.php(212): Symfony\Component\Process\Process->wait()

1 /www/html/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Event.php(201): Symfony\Component\Process\Process->run()

2 /www/html/vendor/laravel/framework/src/Illuminate/Console/Scheduling/Event.php(176): Illuminate\Console\Scheduling\Event->runCommandInForeground(Object(Illuminate\Foundation\Application))

3 /www/html/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php(59): Illuminate\Console\Scheduling\Event->run(Object(Illuminate\Foundation\Application))

4 [internal function]: Illuminate\Console\Scheduling\ScheduleRunCommand->handle()

5 /www/html/overrides/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)

6 /www/html/overrides/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

7 /www/html/overrides/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

8 /www/html/overrides/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

9 /www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)

10 /www/html/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

11 /www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

12 /www/html/vendor/symfony/console/Application.php(992): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

13 /www/html/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Console\Scheduling\ScheduleRunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

14 /www/html/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

15 /www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

16 /www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

17 /www/html/artisan(62): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

18 {main}

"}

freescout-helpdesk commented 1 year ago

Add the following logging to the line 112 https://github.com/freescout-helpdesk/freescout/blob/dist/app/Console/Kernel.php#L112:

\Log::error('fetch_command_pids: '.count($fetch_command_pids));
\Log::error('mutex: '.\Cache::get($mutex_name));

Wait till you'll have fetch_command_pids and mutex values in Manage > Logs > App Logs and post them here.

afawaz2 commented 1 year ago

I am not getting logs, I am not experienced with laravel should/how I reload the php to get the updated code to see the change?

freescout-helpdesk commented 1 year ago

There is no need to do anything else. Just wait till there will be multiple fetch-emails processes running and check logs.

afawaz2 commented 1 year ago

This is what I got; I will wait for the issue to reoccur and update the ticket

image
freescout-helpdesk commented 1 year ago

Killing processes that get stuck in Docker has been fixed in FreeScout v1.8.69