Bug 1021191

Summary: IDLE protocol don't use idled (idle method), but poll method; thousands forgotten {configdirectory}/socket/idle.<pid> files
Product: Red Hat Enterprise Linux 6 Reporter: Michal Michaláč <michal.michalac>
Component: cyrus-imapdAssignee: Pavel Zhukov <pzhukov>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4CC: boris, g.danti, seiichirou.hiraoka, sysadmin, thozza
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-19 09:29:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Michaláč 2013-10-20 09:31:54 UTC
Description of problem:
a)
Idled method is used only first time in imapd process live. Then poll method is used.
After starting, imapd process creates own unix socket {configdirectory}/socket/idle.<pid> (by call idle_enabled()). After e-mail client connect to it and issue IDLE command, imapd waits for notification of new mail (form lmtpd for example). 
After new mail arrives, lmtpd notifies imapd about it and imapd immediately notifies client. Ok so far.

But then imapd calls idle_done() which closes (and removes) {configdirectory}/socket/idle.<pid>. This is problem.
After client issue IDLE command again, imapd can't communicate with closed socket and use "poll" method to check updates to mailbox.
It means, client will be notified about next new mail after (max) 'imapidlepoll' time (default 60s).

b) 
In {configdirectory}/socket/ remains thousands of idle.<pid> files. If pop3d proces is started, it creates own idle.<pid> file (by call idle_enabled()), but this file is never removed. Neither after terminating of pop3d. 
Other cyrus-imapd processess (imapd, lmtpd) leaves idle.<pid> too. Only situation, where idle.<pid> is removed is described in (a).



Version-Release number of selected component (if applicable):
cyrus-imapd-2.3.16-6.el6_2.5

How reproducible:
Easy

Steps to Reproduce:
Will test on mailbox name 'johndoe'. /etc/imapd.conf:imapidlepoll setting is default (60s).

1) Clean idle.* sockets and restart.
$ service cyrus-imapd stop
$ rm /var/lib/imap/socket/idle.* -f
$ service cyrus-imapd start

2) Enable protocol debugging for johndoe.
$ cd /var/lib/imap/log/
$ mkdir johndoe
$ chown cyrus

3) Connect to imap by email-client (I use Mozilla Thunderbird)
$ tail -f johndoe/*
here you will see, Thunderbird issue IDLE command
$ ls -l /var/lib/imap/socket/idle.*
here you will see socket of our imapd process

4) Send first mail to johndoe's mailbox.
$ echo test | mail johndoe
at tail screen you will see immediately notification about new mail (and this mail is downloaded to Thunderbird). Ok so far.
$ ls -l /var/lib/imap/socket/idle.*
Here you will see socket of our imapd process disapeared.

5) Send second mail...
$ echo test | mail johndoe
at tail screen you will see notification about new mail appears after random delay (0 - 60s) because poll not idled.

6) Terminate cyrus-imapd and count imapd.* leaved
$ service cyrus-imapd stop
$ ls -l /var/lib/imap/socket/imap.*


Actual results:
a) after first IDLE notification using idled, next is deferred by poll mechanism
b) many imap.* files remains

Expected results:
a) every time use idled IDLE notifications 
b) at {configdirectory}/socket/ must be only idle.* sockets of running process, not of terminated

Additional info:
This problem was involved by idle* patch (last patch in cyrus-imapd-2.3.16-6.el6_2.5). Before that, processes communicate via single {configdirectory}/socket/idle socket. 

Thank you
Michal Michaláč

Comment 2 sysadmin 2014-02-28 14:53:19 UTC
I too get a /var/lib/imap/socket directory cluttered with idle.* files.  In addition, when restarting cyrus-imapd, I get many of these, not sure if related:

Feb 28 09:41:33 myhostname idled[9472]:  error sending to idled: 4

Comment 3 g.danti 2015-05-06 14:49:15 UTC
I have the same exact bug. Any suggestion on how to fix it?

Comment 4 seiichirou.hiraoka 2015-05-23 13:17:45 UTC
I use RHEL 7.1 and Cyrus-IMAPD 2.5.2 (source compile)

When I log in thunderbird to cyrus-imapd imap service,
I see following error message in my /var/log/messages.

May 23 22:04:35 servername imap[4280]: IDLE: error sending message INIT to idled for
mailbox user.username: No such file or directory. Falling back to polling every
60 seconds.

So I add my /etc/imapd.conf

imapidlepoll: 0

and message stopped.

I want to know...
1) Is my situation as same as this BUG?
2) Is my workaround cause another problem?

Any comments are welcome.

Thanks,

Comment 5 Pavel Šimerda (pavlix) 2015-12-01 16:10:06 UTC
Do we have any upstream information for that?

Comment 6 Boris Folgmann 2016-01-14 10:33:04 UTC
Sorry for clearing the flag. I wanted just to CC since I'm experiencing the same behaviour. Any news on this bug?

Comment 11 Pavel Zhukov 2017-04-13 10:13:21 UTC
(In reply to Pavel Šimerda (pavlix) from comment #5)
> Do we have any upstream information for that?
Looks like addressed in:
https://github.com/cyrusimap/cyrus-imapd/commit/c024aa361060ea3e3e18efd0ea056d953eb204c5

Comment 12 Pavel Zhukov 2017-07-19 09:29:55 UTC
Red Hat Enterprise Linux 6 transitioned to the Production 3 Phase on May 10, 2017.  During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:
http://redhat.com/rhel/lifecycle

This issue does not appear to meet the inclusion criteria for the Production Phase 3 and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification.  Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com