Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-1045

Deadlock in BigdataTriplePatternMaterializer

    Details

      Description

      [just changes|This] the queue from a bounded ArrayBlockingQueue to an unbounded ConcurrentLinkedQueue (and changed the interface from BlockingQueue to Queue). Concurrency is only between the producers, so a blocking queue doesn?t really seem necessary. A LinkedBlockingQueue would also work just as well though. Main thing was to use an unbounded queue since a producer may output more than 1 chunk.

      Index: bigdata-rdf/src/java/com/bigdata/rdf/store/BigdataTriplePatternMaterializer.java
      ===================================================================
      --- bigdata-rdf/src/java/com/bigdata/rdf/store/BigdataTriplePatternMaterializer.java	(revision 8478)
      +++ bigdata-rdf/src/java/com/bigdata/rdf/store/BigdataTriplePatternMaterializer.java	(working copy)
      @@ -28,6 +28,8 @@
       import java.util.List;
       import java.util.concurrent.ArrayBlockingQueue;
       import java.util.concurrent.BlockingQueue;
      +import java.util.Queue;
      +import java.util.concurrent.ConcurrentLinkedQueue;
       import java.util.concurrent.Callable;
       import java.util.concurrent.CountDownLatch;
       import java.util.concurrent.ExecutionException;
      @@ -124,8 +126,8 @@
                * in the data will be dropped and will not put anything into this
                * output queue.
                */
      -        final BlockingQueue<ISPO[]> out = new ArrayBlockingQueue<ISPO[]>(
      -                chunk.length);
      +        final Queue<ISPO[]> out = new ConcurrentLinkedQueue<ISPO[]>(
      +                /*chunk.length*/);
       
               final List<FutureTask<Long>> tasks = new LinkedList<FutureTask<Long>>();
       
      @@ -223,10 +225,10 @@
           private class ResolveTriplePatternTask implements Callable<Long> {
       
               private final BigdataTriplePattern stmt;
      -        private final BlockingQueue<ISPO[]> out;
      +        private final Queue<ISPO[]> out;
       
               public ResolveTriplePatternTask(final BigdataTriplePattern stmt,
      -                final BlockingQueue<ISPO[]> out) {
      +                final Queue<ISPO[]> out) {
                   this.stmt = stmt;
                   this.out = out;
               }
      @@ -273,7 +275,9 @@
       //                                throw new AssertionError(Arrays.toString(a));
       //                        }
       //                    }
      -                    out.put(a);
      +//                  // this will never fail for a ConcurrentLinkedQueue
      +                    boolean result = out.offer(a);
      +                    assert result : "insertion failed - expects an unbounded queue";
                           n += a.length;
                       }
                       return n;
      

        Activity

        Hide
        bryanthompson bryanthompson added a comment -

        Bug fix for deadlock that could arise in the BigdataTriplePatternMaterializer if an input chunk produced more than one output chunk. The fix changes the queue type from blocking (fixed capacity) to linked (no fixed capacity).

        Note: This could create a problem if the caller fails to drain the output queue and fails to cancel the operation since a high cardinality result could cause the output queue to grow without bound.

        Committed revision r8513.

        Show
        bryanthompson bryanthompson added a comment - Bug fix for deadlock that could arise in the BigdataTriplePatternMaterializer if an input chunk produced more than one output chunk. The fix changes the queue type from blocking (fixed capacity) to linked (no fixed capacity). Note: This could create a problem if the caller fails to drain the output queue and fails to cancel the operation since a high cardinality result could cause the output queue to grow without bound. Committed revision r8513.

          People

          • Assignee:
            bryanthompson bryanthompson
            Reporter:
            bryanthompson bryanthompson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: