Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4246

Sequence number mismatch on multiplexed clients

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 0.10.0
    • 0.11.0
    • Node.js - Library
    • None
    • Patch Available

    Description

      When performing calls using a multiplexed client and when having multiple connections and clients, the wrong sequence numbers are used which will often result in responses not being able to be delivered to the client. This is because every connection will make the client class (not instance) use the latest created multiplexer class to generate sequence numbers. The following example shows the problem:

      const thrift = require('thrift');
      const AlphaService = require('./gen-nodejs/AlphaService');
      const BetaService = require('./gen-nodejs/BetaService');
      
      let connection1 = thrift.createConnection('localhost', 9091, {
        transport: thrift.TFrameTransport,
        protocol: thrift.TCompactProtocol,
      });
      
      let multiplexer1 = new thrift.Multiplexer();
      
      let alpha1 = multiplexer1.createClient('alpha', AlphaService, connection1);
      let beta1 = multiplexer1.createClient('beta', BetaService, connection1);
      
      alpha1.echoAlpha("hello")
      
      let connection2 = thrift.createConnection('localhost', 9091, {
        transport: thrift.TFrameTransport,
        protocol: thrift.TCompactProtocol,
      });
      
      let multiplexer2 = new thrift.Multiplexer();
      
      let alpha2 = multiplexer2.createClient('alpha', AlphaService, connection2);
      let beta2 = multiplexer2.createClient('beta', BetaService, connection2);
      
      beta1.echoBeta("Hi")
      beta2.echoBeta("hello")
      
      console.log("alpha1 seqId", alpha1._seqid)
      console.log("beta1 seqId", beta1._seqid)
      console.log("beta2 seqId", beta2._seqid)
      
      console.log("multiplexer1 latest", multiplexer1.seqid)
      console.log("multiplexer2 latest", multiplexer2.seqid)
      
      console.log("connection1 mapping", connection1.seqId2Service)
      console.log("connection2 mapping", connection2.seqId2Service)
      

      Result:

      alpha1 seqId 1
      beta1 seqId 1
      beta2 seqId 2
      multiplexer1 latest 1
      multiplexer2 latest 2
      connection1 mapping { '1': 'beta' }
      connection2 mapping { '2': 'beta' }
      

      Connection1 should have mapping 1 > alpha, 2> beta

      Attachments

        Issue Links

          Activity

            People

              jking3 James E. King III
              vboivie Victor Boivie
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: