Exemplo n.º 1
0
  private String getSlicesInfo(ColumnFamily container) {
    StringBuilder sb = new StringBuilder();
    CellNameType type = container.metadata().comparator;
    for (ColumnSlice sl : slices) {
      assert sl != null;

      sb.append('[');
      sb.append(type.getString(sl.start));
      sb.append('-');
      sb.append(type.getString(sl.finish));
      sb.append(']');
    }
    return sb.toString();
  }
Exemplo n.º 2
0
  public void collectReducedColumns(
      ColumnFamily container,
      Iterator<Cell> reducedColumns,
      DecoratedKey key,
      int gcBefore,
      long now) {
    columnCounter = columnCounter(container.getComparator(), now);
    DeletionInfo.InOrderTester tester = container.deletionInfo().inOrderTester(reversed);

    while (reducedColumns.hasNext()) {
      Cell cell = reducedColumns.next();

      if (logger.isTraceEnabled())
        logger.trace(
            "collecting {} of {}: {}",
            columnCounter.live(),
            count,
            cell.getString(container.getComparator()));

      // An expired tombstone will be immediately discarded in memory, and needn't be counted.
      // Neither should be any cell shadowed by a range- or a partition tombstone.
      if (cell.getLocalDeletionTime() < gcBefore || !columnCounter.count(cell, tester)) continue;

      if (columnCounter.live() > count) break;

      if (respectTombstoneThresholds()
          && columnCounter.tombstones() > DatabaseDescriptor.getTombstoneFailureThreshold()) {
        Tracing.trace(
            "Scanned over {} tombstones; query aborted (see tombstone_failure_threshold); slices={}",
            DatabaseDescriptor.getTombstoneFailureThreshold(),
            getSlicesInfo(container));

        throw new TombstoneOverwhelmingException(
            columnCounter.tombstones(),
            count,
            container.metadata().ksName,
            container.metadata().cfName,
            container.getComparator().getString(cell.name()),
            getSlicesInfo(container));
      }

      container.appendColumn(cell);
    }

    boolean warnTombstones =
        logger.isWarnEnabled()
            && respectTombstoneThresholds()
            && columnCounter.tombstones() > DatabaseDescriptor.getTombstoneWarnThreshold();
    if (warnTombstones) {
      String msg =
          String.format(
              "Read %d live and %d tombstone cells in %s.%s for key: %1.512s (see tombstone_warn_threshold). %d columns were requested, slices=%1.512s",
              columnCounter.live(),
              columnCounter.tombstones(),
              container.metadata().ksName,
              container.metadata().cfName,
              container.metadata().getKeyValidator().getString(key.getKey()),
              count,
              getSlicesInfo(container));
      ClientWarn.warn(msg);
      logger.warn(msg);
    }
    Tracing.trace(
        "Read {} live and {} tombstone cells{}",
        columnCounter.live(),
        columnCounter.tombstones(),
        warnTombstones ? " (see tombstone_warn_threshold)" : "");
  }