Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-2183

memtable_flush_after_mins setting not working

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 0.7.3
    • None
    • None
    • Low

    Description

      We have observed the behavior that memtable_flush_after_mins setting not working occasionally. After some testing and code digging, we finally figured out what going on.
      The memtable_flush_after_mins won't work on certain condition with current implementation in Cassandra.

      In org.apache.cassandra.db.Table, the scheduled flush task is setup by the following code during construction.

      ------------------------------------------------------------------------------------------------------------------
      int minCheckMs = Integer.MAX_VALUE;

      for (ColumnFamilyStore cfs : columnFamilyStores.values())
      {
      minCheckMs = Math.min(minCheckMs, cfs.getMemtableFlushAfterMins() * 60 * 1000);
      }

      Runnable runnable = new Runnable()
      {
      public void run()
      {
      for (ColumnFamilyStore cfs : columnFamilyStores.values())

      { cfs.forceFlushIfExpired(); }

      }
      };
      flushTask = StorageService.scheduledTasks.scheduleWithFixedDelay(runnable, minCheckMs, minCheckMs, TimeUnit.MILLISECONDS);
      ------------------------------------------------------------------------------------------------------------------------------

      Now for our application, we will create a keyspacewithout without any columnfamily first. And only add needed columnfamily later depends on request.

      However, when keyspacegot created (without any columnfamily ), the above code will actually schedule a fixed delay flush check task with Integer.MAX_VALUE ms
      since there is no columnfamily yet.

      Later when you add columnfamily to this empty keyspace, the initCf() method in Table.java doesn't check whether the scheduled flush check task interval need
      to be updated or not. To fix this, we'd need to restart the Cassandra after columnfamily added into the keyspace.

      I would suggest that add additional logic in initCf() method to recreate a scheduled flush check task if needed.

      Attachments

        1. 2183.txt
          1 kB
          Jonathan Ellis

        Activity

          People

            jbellis Jonathan Ellis
            chenyy Ching-cheng
            Jonathan Ellis
            Peter Schuller
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified