<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:59:56 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-3578] Avoiding MongoWaitQueueFullExceptions by overriding ObservableImplicits</title>
                <link>https://jira.mongodb.org/browse/JAVA-3578</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;We would like to apply some throttling on mongo queries to avoid hitting &lt;tt&gt;MongoWaitQueueFullExceptions&lt;/tt&gt; at runtime. We would also like to apply this non-invasively to our current mongo api usage.&lt;/p&gt;

&lt;p&gt;We have managed to do this by providing alternative implicit conversions, in the same way as those in `&lt;tt&gt;org.mongodb.scala.ObservableImplicits&lt;/tt&gt;`, where our version of `&lt;tt&gt;toFuture&lt;/tt&gt;` (and `&lt;tt&gt;toFutureOption&lt;/tt&gt;`) would evaluate the `&lt;tt&gt;observable: Observable&lt;/tt&gt;` on a fixed-size thread-pool.&lt;/p&gt;

&lt;p&gt;The observable, which the extra methods are added to, needs to be captured as a by-name parameter, in-order that we can evaluate it on our thread-pool, e.g. `&lt;tt&gt;implicit class ScalaObservable&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(observable: =&amp;gt; Observable&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;)&lt;/tt&gt;`.&lt;/p&gt;

&lt;p&gt;But since an implicit for a by-name parameter is picked up secondary to a by-value parameter, we are unable to override the predefined `&lt;tt&gt;toFuture&lt;/tt&gt;` function, and have to create a new function (e.g. `&lt;tt&gt;toFutureThrottled&lt;/tt&gt;`).&lt;/p&gt;

&lt;p&gt;If the provided implicit classes in `&lt;tt&gt;ObservableImplicits&lt;/tt&gt;`:&lt;/p&gt;

&lt;p&gt;&#160;&#160;`&lt;tt&gt;implicit class ScalaObservable&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(observable: Observable&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;)&lt;/tt&gt;`&lt;/p&gt;

&lt;p&gt;were changed to:&lt;br/&gt;
```&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;implicit class ScalaObservable[T](observable: =&amp;gt; Observable[T]) {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&#160; val obs = observable&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&#160;&#8230;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;```&lt;/p&gt;

&lt;p&gt;(and &lt;tt&gt;ScalaSingleObservable&lt;/tt&gt; similarly), then we could override them, such that `&lt;tt&gt;toFuture&lt;/tt&gt;` behaves as we intend.&lt;/p&gt;

&lt;p&gt;Is this worth a pull-request, to change the observable parameter from a by-value to a by-name parameter?&lt;/p&gt;

&lt;p&gt;Or is there an alternative recommendation for achieving this goal?&lt;/p&gt;</description>
                <environment></environment>
        <key id="1036022">JAVA-3578</key>
            <summary>Avoiding MongoWaitQueueFullExceptions by overriding ObservableImplicits</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="colin.fairless@digital.hmrc.gov.uk">Colin Fairless</reporter>
                        <labels>
                    </labels>
                <created>Wed, 4 Dec 2019 13:31:48 +0000</created>
                <updated>Sat, 28 Oct 2023 11:21:52 +0000</updated>
                            <resolved>Thu, 30 Jan 2020 10:31:29 +0000</resolved>
                                                    <fixVersion>4.0.0</fixVersion>
                                    <component>Scala</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2772451" author="xgen-internal-githook" created="Thu, 30 Jan 2020 10:25:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;rozza&apos;, &apos;name&apos;: &apos;Ross Lawley&apos;, &apos;email&apos;: &apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Scala: Use pass by name in implicits functions&lt;/p&gt;

&lt;p&gt;Allows the functions to be overridden by users&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-3578&quot; title=&quot;Avoiding MongoWaitQueueFullExceptions by overriding ObservableImplicits&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-3578&quot;&gt;&lt;del&gt;JAVA-3578&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/b8d844d3f9871a5c62045db2b483847ec0eec876&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/b8d844d3f9871a5c62045db2b483847ec0eec876&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2765651" author="ross@10gen.com" created="Mon, 27 Jan 2020 15:26:39 +0000"  >&lt;p&gt;PR: &lt;a href=&quot;https://github.com/rozza/mongo-java-driver/pull/355&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/rozza/mongo-java-driver/pull/355&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I think this change will be safe to backport to Scala 2.9.0&lt;/p&gt;</comment>
                            <comment id="2739492" author="colin.fairless@digital.hmrc.gov.uk" created="Fri, 17 Jan 2020 17:13:08 +0000"  >&lt;p&gt;Hi Ross Lawley,&lt;/p&gt;

&lt;p&gt;I think it&apos;s a case of naming the override the same as the one to be overriden.&lt;/p&gt;

&lt;p&gt;I have uploaded a simplified example.&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/attachment/243363/243363_Main.scala&quot; title=&quot;Main.scala attached to JAVA-3578&quot;&gt;Main.scala&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="2721472" author="ross@10gen.com" created="Mon, 13 Jan 2020 11:08:42 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=colin.fairless%40digital.hmrc.gov.uk&quot; class=&quot;user-hover&quot; rel=&quot;colin.fairless@digital.hmrc.gov.uk&quot;&gt;colin.fairless@digital.hmrc.gov.uk&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Apologies, I&apos;ve not been able to override the implicit ScalaObservable toFuture method without causing an ambiguity error: &quot;&lt;em&gt;implicit conversions are not applicable because they are ambiguous&lt;/em&gt;&quot;.&lt;/p&gt;

&lt;p&gt;Could you provide an example of how you&apos;d want to extend the implicit?&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="2712086" author="ross@10gen.com" created="Wed, 8 Jan 2020 15:59:18 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=colin.fairless%40digital.hmrc.gov.uk&quot; class=&quot;user-hover&quot; rel=&quot;colin.fairless@digital.hmrc.gov.uk&quot;&gt;colin.fairless@digital.hmrc.gov.uk&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Just to update this is now scheduled for the 4.0.0 release, which is now the next planned release of the scala driver.  Why a 4.0 release and not a 3.0 release? This is because the Scala code base has now been merged into Java driver repo ensuring the API&apos;s always stay aligned as development goes forward.  The 3.12 release of the Java driver which is used by the 2.8 Scala driver release, is the last planned release in the 3.x series.&lt;/p&gt;

&lt;p&gt;As these implicits are used through out userland code changing the implementation of them in a minor release maybe breaking the semver contract and as such changing in a major release seems more appropriate.  So unfortunately, until the 4.0 release is available, you&apos;ll have to continue to use your customised implicits.&lt;/p&gt;

&lt;p&gt;All the best,&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="2633539" author="ross@10gen.com" created="Mon, 16 Dec 2019 09:39:42 +0000"  >&lt;p&gt;Thanks for the feedback &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=colin.fairless%40digital.hmrc.gov.uk&quot; class=&quot;user-hover&quot; rel=&quot;colin.fairless@digital.hmrc.gov.uk&quot;&gt;colin.fairless@digital.hmrc.gov.uk&lt;/a&gt;, &lt;/p&gt;

&lt;p&gt;I&apos;ve scheduled this for the next release (2.9.0) which should be released early 2020.&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="2633537" author="colin.fairless@digital.hmrc.gov.uk" created="Mon, 16 Dec 2019 09:34:56 +0000"  >&lt;p&gt;Hi Ross Lawley,&lt;/p&gt;

&lt;p&gt;We have looked at increasing the wait pool size, although under load this can still be reached. We previously used reactive-mongo, which uses akka to throttle load to the database, and for backward compatibility want to preserve this behaviour.&lt;/p&gt;

&lt;p&gt;The &lt;tt&gt;observeOn&lt;/tt&gt; helper does not really help here, since, for the same reason, it is applied after evaluating the Observer.&lt;/p&gt;</comment>
                            <comment id="2596457" author="ross@10gen.com" created="Tue, 10 Dec 2019 15:21:10 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=colin.fairless%40digital.hmrc.gov.uk&quot; class=&quot;user-hover&quot; rel=&quot;colin.fairless@digital.hmrc.gov.uk&quot;&gt;colin.fairless@digital.hmrc.gov.uk&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for the ticket , for future reference the best place for questions would be the &lt;a href=&quot;https://groups.google.com/forum/#!forum/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongodb-user mailinglist&lt;/a&gt; or &lt;a href=&quot;http://stackoverflow.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;stackoverflow&lt;/a&gt; as you will reach a boarder audience there.  If your business requires an answer from MongoDB within a time frame then we do offer &lt;a href=&quot;https://www.mongodb.com/products/production-support&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;production support&lt;/a&gt; which has a different avenue for support questions.&lt;/p&gt;

&lt;p&gt;In general it may be worth looking at configuring the wait pool size and increase it via the &lt;tt&gt;MongoClientSettings&lt;/tt&gt; - is that something you have already tried?  &lt;br/&gt;
You certainly can throttle at a higher level and there is the &lt;tt&gt;observeOn&lt;/tt&gt; helper to set the execution context for the Observable, which you may already be using.&lt;/p&gt;

&lt;p&gt;I&apos;d need to consider the implications of the change to by value and see if there are any negatives before proceeding with the change.&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="243363" name="Main.scala" size="725" author="colin.fairless@digital.hmrc.gov.uk" created="Fri, 17 Jan 2020 17:12:19 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5002K00000je74IQAQ]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hw3373:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>