Wail Alkowaileet created ASTERIXDB-1220:
-------------------------------------------

             Summary: Race condition in AObjectPrinter singleton instance
                 Key: ASTERIXDB-1220
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1220
             Project: Apache AsterixDB
          Issue Type: Bug
          Components: AsterixDB, Data Formats
            Reporter: Wail Alkowaileet


Hi,

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

{noformat}
            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);
                }
            }
{noformat}

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:
{noformat}
//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
{noformat}

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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to