<div>Hi All,</div>
<div> </div>
<div>We are using dovecot 2.3.19.1<br />
We created a account with more than 1000 mail folders in Maildir format to reproduce the issue.<br />
After weeks of testing, we have found a logic that may cause dsync to encounter the error - no activity for 900 seconds....</div>
<div> </div>
<div>The function, dsync_ibc_stream_input, is the callback function after some data are ready for be read.</div>
<div>This is part of what it does.</div>
<div> </div>
<div><strong>o_stream_cork(ibc->output);</strong></div>
<div><strong>ibc->ibc.io_callback(ibc->ibc.io_context);</strong></div>
<div><strong>o_stream_uncork(ibc->output);</strong></div>
<div> </div>
<div> </div>
<div class="syno-mc-signature syno-mc-signature-id-1">
<div>Normally, ibc->ibc.io_callback(ibc->ibc.io_context) reads some data and then processes it.</div>
<div> </div>
<div>But when dsync connects over tcps,</div>
<div>it uses function implementations in lib-ssl-iostream to send and receive data.</div>
<div>And this simplified call stack would result in some data are read when calling o_stream_uncork<br />
<br /></div>
<div><strong>o_stream_uncork => o_stream_flush => o_stream_ssl_flush_buffer => openssl_iostream_bio_sync => openssl_iostream_bio_input</strong></div>
<div><br />
If some data arrive after <span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">ibc->ibc.io_callback(ibc->ibc.io_context) and before o_stream_uncork,</span></div>
<div><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">o_stream_uncork would read the data and then return.</span></div>
<div>After <span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">o_stream_uncork returns, dsync then waits for new data to be read or written.</span></div>
<div><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">But because the data had been read in o_stream_uncork</span><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">, and there may be no new data to be read,</span></div>
<div><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">dsync may then wait until timeout is met.</span></div>
<div> </div>
<div>It may happen, but it is hard to reproduce.</div>
<div>If you also encounter this situation, you may try to use dsync over tcp connection.<br />
It does not read data when calling <span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">o_stream_uncork.<br />
As a result, it may not stuck.</span></div>
<div> </div>
<div>Back to the error itself,</div>
<div>Maybe openssl-stream should not read data when doing uncork(flush)?</div>
<div> </div>
<div>Song-Lin Yang</div>
</div>