<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Hi all,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Because I think this is a race condition so instead of using only one <span style="font-family:monospace"><b>current_ioloop</b></span>:</div><ul><li><span style="font-family:verdana,sans-serif">I create ioloop for each Backend in the list of <span class="gmail_default" style="font-family:verdana,sans-serif"></span>Director</span></li><li><span style="font-family:verdana,sans-serif">I think connections from <span class="gmail_default" style="font-family:verdana,sans-serif">a </span>Director to same Backend are synchronous so I don't create ioloop for each connection</span></li><li><span style="font-family:verdana,sans-serif">I think ioloop must be destroyed in correct order so I use a linked list to manage them, create then push and pop then destroy (sorry, I don't know any existing structure in source of Dovecot that I can re-use)</span></li></ul><div class="gmail_default" style="font-family:verdana,sans-serif">I tested my patch with both "doveadm quota get -A" and "doveadm quota get -u xxx" many times. No error occurs (timeout leak, segment fault... etc).</div><div class="gmail_default" style="font-family:verdana,sans-serif">If you are interested in my patch, any comment is highly appreciated. I modified source files which might be shared with other doveadm commands so I'm not sure it's safe 100%.<br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Thanks,</div><div class="gmail_default" style="font-family:verdana,sans-serif">Anh Do<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 27 Jan 2021 at 16:20, Duc Anh Do <<a href="mailto:doducanh2710@gmail.com">doducanh2710@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Hi all,<br><br>I have one Dovecot Director, two Dovecot Backends and one LDAP server with about 500 users. I would like to run <b><span style="font-family:monospace">doveadm quota get -A</span></b> from the Director.<br>In each Backend, there is no problem when run the command:<br><span style="font-family:monospace"># doveadm quota get -A<br>user1 User quota STORAGE 0 1048576000000000 0<br>user1 User quota MESSAGE 0 - 0<br>…<br>user500 User quota STORAGE 0 1048576000000000 0<br>user500 User quota MESSAGE 0 - 0</span><br><br>However, when I run from the Director, the command might stuck in an infinity loop (I have to terminate to quit):<br><span style="font-family:monospace"># doveadm quota get -A<br>user1 User quota STORAGE 0 1048576000000000 0<br>user1 User quota MESSAGE 0 - 0<br>…<br>user49 User quota STORAGE 0 1048576000000000 0<br>user49 User quota MESSAGE 0 - 0<br>user66 User quota STORAGE 0 1048576000000000 0<br>user66 User quota MESSAGE 0 - 0<br>^Cdoveadm(user86): Error: doveadm server failure<br>doveadm: Error: Failed to iterate through some users<br>doveadm: Error: backend2.local:24245: Command quota get failed for user53: EOF<br>doveadm: Error: backend1.local:24245: Command quota get failed for user66: EOF<br>doveadm: Error: Aborted</span><br><br>This problem occurs in both Dovecot 2.2.36 and Dovecot 2.3.11, 2.3.13 (I build Dovecot from source). It's ok for me to get quota of one user from the Director:</div><div class="gmail_default"><span style="font-family:monospace"># doveadm quota get -u user1<br>Quota name Type Value Limit %<br>User quota STORAGE 0 1048576000000000 0<br>User quota MESSAGE 0 - 0</span></div><div class="gmail_default"><span style="font-family:monospace"><font face="verdana,sans-serif">And if there's only one Backend, </font><b><span style="font-family:monospace">doveadm quota get -A</span></b> <span style="font-family:verdana,sans-serif">from the Director works well too.</span><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">After investigating, I found the infinity loop:<br><span style="font-family:monospace">File src/doveadm/doveadm-mail-server.c:<br>static void doveadm_server_flush_one(struct doveadm_server *server)<br>{<br> unsigned int count = array_count(&server->queue);<br><br> do {<br> io_loop_run(current_ioloop);<br> } while (array_count(&server->queue) == count &&<br> doveadm_server_have_used_connections(server) &&<br> !DOVEADM_MAIL_SERVER_FAILED());<br>}</span><span style="font-family:monospace"></span><br><br>In case there're many Backends, I see only global variable <b><span style="font-family:monospace">current_ioloop</span></b> is used to notify in the callback function. Might this be a race condition?</div><div class="gmail_default" style="font-family:verdana,sans-serif">I understand there's a workaround to do my work:<br><ul><li>Run <b><span style="font-family:monospace">doveadm user '*'</span></b> to get all users</li><li>Loop through all users and run <span style="font-family:monospace"><b>doveadm quota get -u xxx</b></span></li></ul><div><br></div>Thanks,</div><div class="gmail_default" style="font-family:verdana,sans-serif">Anh Do<br></div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Thanks,<br>Duc Anh<br>----------------------------------------------------------------------------------------------------<br>Email: <a href="mailto:doducanh2710@gmail.com" target="_blank">doducanh2710@gmail.com</a><br>Skype: ducanh.do88<br></div>Mobile: +84975730526<br></div></div>