Uploaded image for project: 'Apache AsterixDB'
  1. Apache AsterixDB
  2. ASTERIXDB-1220

Race condition in AObjectPrinter singleton instance

    XMLWordPrintableJSON

Details

    Description

      Hi,

      The bug appears clearly when two queries race to print their output using AObjectPrinter singleton in the same DataFormat.

                  public void print(byte[] b, int start, int l, PrintStream ps) throws AlgebricksException {
                      try {
                          listAccessor.set(b, start, l);
                          arg.first = ps;
                          listAccessor.accept(printVisitor, arg);
                      } catch (Exception ioe) {
                          throw new AlgebricksException(ioe);
                      }
                  }
      

      Since there's only one instance of AObjectPrinter, this will be a critical section and things will lose track (such as ps and listAccessor).

      I think new printer should be instantiated for each query.

      To produce the problem:
      Running the query in two clients:

      //As in runtimets/queries/open-closed/query-issue55.3.query.aql
      for $x in [[1,3],[4,5,2],[-1,-3,0],["a"]]
      return $x
      

      interchange the execution sequence in the two threads such as:
      Thread 1 run: listAccessor.set(b, start, l);
      Thread 2 run: listAccessor.set(b, start, l);
      Thread 1 resume running.
      Thread 2 resume running.

      Attachments

        Activity

          People

            tillw Till Westmann
            wyk Wail Y. Alkowaileet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: