Uploaded image for project: 'Bookkeeper'
  1. Bookkeeper
  2. BOOKKEEPER-1065

OrderedSafeExecutor should only have 1 thread per bucket

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • 4.5.0
    • None
    • None

    Description

      In a earlier commit, "BOOKKEEPER-874: Explict LAC from Writer to Bookie", there was this change in the OrderedSafeExecutor implementation:

               for (int i = 0; i < numThreads; i++) {
      -            queues[i] = new LinkedBlockingQueue<Runnable>();
      -            threads[i] =  new ThreadPoolExecutor(1, 1,
      -                    0L, TimeUnit.MILLISECONDS, queues[i],
      +            threads[i] =  new ScheduledThreadPoolExecutor(1,
                           new ThreadFactoryBuilder()
                               .setNameFormat(name + "-orderedsafeexecutor-" + i + "-%d")
                               .setThreadFactory(threadFactory)
                               .build());
      +            threads[i].setMaximumPoolSize(1);
      

      Then, as part of "BOOKKEEPER-1013: Fix findbugs errors on latest master", the max pool size line has been removed.

      @@ -183,7 +183,6 @@ public class OrderedSafeExecutor {
                               .setNameFormat(name + "-orderedsafeexecutor-" + i + "-%d")
                               .setThreadFactory(threadFactory)
                               .build());
      -            threads[i].setMaximumPoolSize(1);
      
                   // Save thread ids
                   final int idx = i;
      

      Without that the thread pool would create multiple threads for the same bucket, breaking the ordering guarantee of the executor.

      Attachments

        Issue Links

          Activity

            People

              mmerli Matteo Merli
              mmerli Matteo Merli
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: