<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> 
        <base href="https://hibernate.atlassian.net"> 
        <title>Message Title</title> 
    </head> 
    <body class="jira" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429"> 
        <table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0" bgcolor="#f5f5f5"> 
            <!-- header here --> 
            <tbody>
                <tr> 
                    <td id="header-pattern-container" style="padding: 0; border-collapse: collapse; padding: 10px 20px"> 
                        <table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                            <tbody>
                                <tr> 
                                    <td id="header-avatar-image-container" valign="top" style="padding: 0; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px" width="32"> <img id="header-avatar-image" class="image_fix" src="cid:jira-generated-image-avatar-d6f3e871-c4d1-4a69-9af9-09e26d81fc66" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top"> </td> 
                                    <td id="header-text-container" valign="middle" style="padding: 0; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="yrodiere" id="email_yrodiere" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=yrodiere" style="color:#6c797f;; color: #3b73af; text-decoration: none">Yoann Rodière</a> <strong>commented</strong> on <a href="https://hibernate.atlassian.net/browse/HSEARCH-2282" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-05dc00c1-022a-4fc4-8570-28ead03b9105" height="16" width="16" border="0" align="absmiddle" alt="Improvement"> HSEARCH-2282</a> </td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
                <tr> 
                    <td id="email-content-container" style="padding: 0; border-collapse: collapse; padding: 0 20px"> 
                        <table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; border-spacing: 0; border-collapse: separate"> 
                            <tbody>
                                <tr> 
                                    <!-- there needs to be content in the cell for it to render in some clients --> 
                                    <td class="email-content-rounded-top mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 15px; background-color: #ffffff; border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly" height="10" bgcolor="#ffffff">&nbsp;</td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> 
                                        <table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <td style="vertical-align: top;; padding: 0; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HSEARCH-2282" style="color: #3b73af; text-decoration: none">Re: Need explicit flush and refresh indexes command</a> </span> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td id="text-paragraph-pattern-top" class="email-content-main mobile-expand  comment-top-pattern" style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; border-bottom: none; padding-bottom: 0" bgcolor="#ffffff"> 
                                        <table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px"> 
                                            <tbody>
                                                <tr> 
                                                    <td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0; border-collapse: collapse; padding: 0 0 10px"> <h2 style="margin: 10px 0 0; margin-top: 0; font-size: 20px; font-weight: normal; line-height: 1.500; margin: 40px 0 0; margin-top: 0"><a name="TD%3BDR" style="color: #3b73af; text-decoration: none"></a>TD;DR</h2> <p style="margin: 10px 0 0">I'm afraid that, if we want to do this cleanly, it will require additions or changes to the following SPIs:</p> 
                                                        <ul> 
                                                            <li><tt>org.hibernate.search.backend.spi.BackendQueueProcessor</tt> (in particular <tt>BackendQueueProcessor.applyWork(List&lt;LuceneWork&gt;, IndexingMonitor)</tt>)</li> 
                                                            <li><tt>org.hibernate.search.indexes.spi.IndexManager</tt> (in particular <tt>IndexManager.performOperations(List&lt;LuceneWork&gt;, IndexingMonitor)</tt>)</li> 
                                                        </ul> <p style="margin: 10px 0 0">The reason being that implementations of <tt>IndexManager</tt> don't have access to such thing as session-scoped settings. Which is normal, since sessions are an ORM concept. So we ought to pass those settings as method arguments.</p> <p style="margin: 10px 0 0">If we really need to get this done quickly, we may also take advantage of a thread local storing such session-scoped settings (in a <tt>Service</tt> for instance), but this solution seems less elegant to me (of course we can pass any argument through a thread local instead of the stack, but then the method signatures become less and less informative).</p> <p style="margin: 10px 0 0">So my questions are:</p> 
                                                        <ul> 
                                                            <li>am I completely wrong in my assessment?</li> 
                                                            <li>do we need this now or can it be pushed to 6.0?</li> 
                                                            <li>if we must do it now, is the threadlocal solution acceptable?</li> 
                                                        </ul> <h2 style="margin: 10px 0 0; font-size: 20px; font-weight: normal; line-height: 1.500; margin: 40px 0 0"><a name="Fullexplanation" style="color: #3b73af; text-decoration: none"></a>Full explanation</h2> <p style="margin: 10px 0 0">We have two concepts at play here:</p> 
                                                        <ol> 
                                                            <li>Whether operations are transmitted to the backend synchronously. If they are, and if a power failure (which does not affect the backend) happens just after returning from the request processing, we know the operations will be executed anyway.</li> 
                                                            <li>Whether operations are executed synchronously. If they are, and we query the index just after returning from the request processing, we know the results will be up-to-date (the effects of our operations will be visible).</li> 
                                                        </ol> <p style="margin: 10px 0 0">We implement, here and there, three modes of execution:</p> 
                                                        <ul> 
                                                            <li>Asynchronous, i.e. transmission-asynchronous and execution-asynchronous</li> 
                                                            <li>Transmission-synchronous only, i.e. transmission-synchronous and execution-asynchronous</li> 
                                                            <li>Synchronous, i.e. transmission-synchronous and execution-synchronous</li> 
                                                        </ul> <p style="margin: 10px 0 0">We want to offer the possibility for Search-orm users to switch the post-commit behavior between transmission-synchronous only and synchronous with a session-scoped setting.</p> <p style="margin: 10px 0 0">When a transaction ends, the message is propagated this way:</p> 
                                                        <ul> 
                                                            <li><tt>org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.afterCompletion(int)</tt> is called</li> 
                                                            <li>which calls <tt>org.hibernate.search.backend.impl.BatchedQueueingProcessor.performWorks(WorkQueue)</tt></li> 
                                                            <li>which calls {{org.hibernate.search.backend.impl.WorkQueuePerIndexSplitter.commitOperations(IndexingMonitor)}</li> 
                                                            <li>which calls <tt>org.hibernate.search.backend.spi.BackendQueueProcessor.applyWork(List&lt;LuceneWork&gt;, IndexingMonitor)</tt></li> 
                                                        </ul> <p style="margin: 10px 0 0">That last method is where the JMS/local distinction is made. Letting the JMS processor aside, when works are triggered locally, the processor calls <tt>org.hibernate.search.indexes.spi.IndexManager.performOperations(List&lt;LuceneWork&gt;, IndexingMonitor)</tt>, whose implementation may be synchronous, transmission-synchronous only or asynchronous depending on global configuration and implementation choices.</p> <p style="margin: 10px 0 0">Unless I'm mistaken, those <tt>IndexManager</tt> implementations do not have access to such thing as session-scoped settings, and obviously the method signature does not allow passing additional settings.</p> <p style="margin: 10px 0 0">For the record, here's what I noted when inspecting various <tt>IndexManager</tt> implementations:</p> 
                                                        <ul> 
                                                            <li><tt>DirectoryBasedIndexManager</tt> is synchronous or asynchronous depending on global (application-scoped) settings</li> 
                                                            <li><tt>NRTIndexManager</tt> seems to be synchronous, given that its documentation states "IndexReaders are able to inspect the unflushed changes still pending in the IndexWriter buffers"</li> 
                                                            <li><tt>ElasticsearchIndexManager</tt> is synchronous</li> 
                                                        </ul> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> 
                                        <table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> 
                                            <tbody>
                                                <tr> 
                                                    <td id="actions-pattern-container" valign="middle" style="padding: 0; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0"> 
                                                        <table align="left" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                                            <tbody>
                                                                <tr> 
                                                                    <td class="actions-pattern-action-icon-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HSEARCH-2282#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-c44875fc-b000-4a31-98e1-d8ec1d47bed0" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle"> </a> </td> 
                                                                    <td class="actions-pattern-action-text-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://hibernate.atlassian.net/browse/HSEARCH-2282#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a> </td> 
                                                                </tr> 
                                                            </tbody>
                                                        </table> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <!-- there needs to be content in the cell for it to render in some clients --> 
                                <tr> 
                                    <td class="email-content-rounded-bottom mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #ffffff; border-top: 0; border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly" height="5" bgcolor="#ffffff">&nbsp;</td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
                <tr> 
                    <td id="footer-pattern" style="padding: 0; border-collapse: collapse; padding: 12px 20px"> 
                        <table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                            <tbody>
                                <tr> 
                                    <td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> This message was sent by Atlassian JIRA <span id="footer-build-information">(v1000.383.2#100014-<span title="783d42561fdcfe98ce52c7c3d24c33d56126c5a5" data-commit-id="783d42561fdcfe98ce52c7c3d24c33d56126c5a5}">sha1:783d425</span>)</span> </td> 
                                    <td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0; border-collapse: collapse; padding-left: 20px; vertical-align: top"> 
                                        <table style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <td id="footer-pattern-logo-desktop-padding" style="padding: 0; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="cid:jira-generated-image-static-footer-desktop-logo-7e85dc9c-4647-4c2d-82ae-5749ccacba0a" alt="Atlassian logo" title="Atlassian logo" width="169" height="36" class="image_fix"> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
            </tbody>
        </table>   
    </body>
</html>