<div dir="ltr"><div class="gmail_extra">&quot;weights&quot; was my first choice, but I changed my mind because we were not using &quot;atrrs&quot; column neither. Anyway, I will keep in mind your suggestion.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Many Thanks!<br>
<br><div class="gmail_quote">On Wed, Aug 19, 2015 at 10:59 AM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <tt>Hi Federico,<br>
      <br>
      Well, it is a good workaround. As a hint, if you do not want to
      sacrifice the &quot;attrs&quot; column for ordering (attributes are really
      useful to have in many usage scenarios), you can better use the
      &quot;weights&quot; column.<br>
      <br>
      Regards,<br>
    </tt><span class="">
    <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
    </span><div><div class="h5"><div>On 18.08.2015 17:11, Federico Edorna
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_extra">In my table there is a priority
            column! ;) I don&#39;t know where did I get that schema...
            sorry, my mistake.</div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">Now, going back to the workarround
            (just in case someone has the same issue), since I&#39;m not
            using the attrs column value in the config file, I will use
            that column to order the set. To accomplish that, I tried
            with the following patch in modules/dispatcher/dispatch.c</div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">
            <div class="gmail_extra">
              <div class="gmail_extra">--- /tmp/dispatch.c<span style="white-space:pre-wrap"> </span>2015-08-18
                10:40:27.461325458 -0300</div>
              <div class="gmail_extra">+++ ./dispatch.c<span style="white-space:pre-wrap"> </span>2015-08-18
                10:39:45.941081837 -0300</div>
              <div class="gmail_extra">@@ -699,7 +699,7 @@</div>
              <div class="gmail_extra"> <span style="white-space:pre-wrap"> </span>memset( d_data, 0,
                sizeof(ds_data_t));</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra"> <span style="white-space:pre-wrap"> </span>/*select the whole
                table and all the columns*/</div>
              <div class="gmail_extra">-<span style="white-space:pre-wrap"> </span>if(ds_dbf.query(ds_db_handle,0,0,0,query_cols,0,6,0,&amp;res)
                &lt; 0) {</div>
              <div class="gmail_extra">+<span style="white-space:pre-wrap"> </span>if(ds_dbf.query(ds_db_handle,0,0,0,query_cols,0,6,&amp;ds_dest_attrs_col,&amp;res)
                &lt; 0) {</div>
              <div class="gmail_extra"> <span style="white-space:pre-wrap"> </span>LM_ERR(&quot;error while
                querying database\n&quot;);</div>
              <div class="gmail_extra"> <span style="white-space:pre-wrap"> </span>goto error;</div>
              <div class="gmail_extra"> <span style="white-space:pre-wrap"> </span>}</div>
            </div>
          </div>
        </div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">That is, ds_dbf.query sorts the table
          using &amp;ds_dest_attrs_col. Now the postgres log shows:</div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">2015-08-18 10:46:51 ART [9503]: [2-1]
          LOG:  duration: 0.224 ms  statement: select
          setid,destination,socket,state,weight,attrs from
          sbc.dispatcher <b> order by attrs</b><br>
          <br>
          I will try with this (at my own risk...) until we upgrade to
          2.x </div>
        <div class="gmail_extra"><br>
          Thanks!<br>
          <br>
          <br>
          <div class="gmail_quote">On Tue, Aug 18, 2015 at 8:45 AM,
            Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"> <tt>Federico,<br>
                  <br>
                  There is no &quot;priority&quot; field in the dispatcher table
                  in 1.11 :<br>
                      <a href="http://www.opensips.org/Documentation/Install-DBSchema-1-11#AEN4123" target="_blank">http://www.opensips.org/Documentation/Install-DBSchema-1-11#AEN4123</a><br>
                  <br>
                  wrong table ?<br>
                  <br>
                  Regards,<br>
                </tt><span>
                  <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
                </span>
                <div>
                  <div>
                    <div>On 17.08.2015 21:03, Federico Edorna wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div class="gmail_extra">Actually the table has
                          the priority column in ver 1.11. Anyway,
                          thanks for your response Bogdan, I will try to
                          find a workarround for this version until we
                          upgrade to 2.x.</div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra">Thanks &amp; Regards</div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra">Federico</div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra">
                          <div class="gmail_quote">On Mon, Aug 17, 2015
                            at 5:56 AM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>&gt;</span>
                            wrote:<br>
                            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                              <div text="#000000" bgcolor="#FFFFFF"> <tt>Hi
                                  Federico,<br>
                                  <br>
                                  This is an known issue with the older
                                  versions of OpenSIPS (not being able
                                  set an order for the records). In 2.1
                                  this was solved by having a priority
                                  column which dictates the oder of
                                  usage of records.<br>
                                  <br>
                                  For versions before 2.1, you have to
                                  rely on the oder provided by DB :(.<br>
                                  <br>
                                  Regards,<br>
                                </tt>
                                <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
                                <div>
                                  <div>
                                    <div>On 14.08.2015 20:49, Federico
                                      Edorna wrote:<br>
                                    </div>
                                  </div>
                                </div>
                                <blockquote type="cite">
                                  <div>
                                    <div>
                                      <div dir="ltr">Hello Guys,
                                        <div>
                                          <div style="font-size:12.8000001907349px">I&#39;m

                                            using dispatcher module with
                                            postgres database. The
                                            ds_select_dst function in
                                            the script file is used like
                                            this:</div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">ds_select_dst(&quot;$(var(ds_set){<a href="http://s.int/" target="_blank">s.int</a>})&quot;,&quot;8&quot;);<br>
                                          </div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">that

                                            is, using &quot;8&quot; algorithm
                                            (first entry in set is
                                            chosen) because I need to
                                            use always the same
                                            destination in the set while
                                            it is up. If not, then the
                                            backup destination (next in
                                            the set) is used.</div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">The

                                            problem I&#39;ve found is that
                                            when the sets are read from
                                            database (opensips restart
                                            or fifo ds_reload), the
                                            select hasn&#39;t a &quot;order&quot;
                                            directive  in the sql
                                            statement, so the order is
                                            defined depending of the
                                            last tuple update. The
                                            postgres log shows this when
                                            doing a fifo ds_reload:</div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">2015-08-14

                                            11:36:53 ART [23684]: [1-1]
                                            LOG:  duration: 0.582 ms
                                             statement: select
                                            setid,destination,socket,state,weight,attrs
                                            from sbc.dispatcher<br>
                                          </div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">And

                                            the syslog &amp; debug=6
                                            shows:</div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div><span style="font-size:12.8000001907349px">DBG:db_postgres:db_postgres_submit_query:


                                              0x7f4344987010
                                              PQsendQuery(select
                                              setid,destination,socket,state,weight,attrs
                                              from sbc.dispatcher )</span><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">So,

                                            any sql update in any column
                                            will change the order in the
                                            set because we don&#39;t have
                                            the &quot;order by priority&quot; for
                                            example.</div>
                                          <div style="font-size:12.8000001907349px"><br>
                                          </div>
                                          <div style="font-size:12.8000001907349px">Is

                                            there any way to use the
                                            weight, priority or the id
                                            to have a fixed order in the
                                            set(s) destination?</div>
                                        </div>
                                        <div><br>
                                        </div>
                                        <div><br>
                                        </div>
                                        <div>Many Thanks!</div>
                                        <div>Federico</div>
                                      </div>
                                      <br>
                                      <fieldset></fieldset>
                                      <br>
                                    </div>
                                  </div>
                                  <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                                </blockquote>
                                <br>
                              </div>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                      </div>
                    </blockquote>
                    <br>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div></div>