/** * Check the collection of families for valid timestamps * @param familyMap * @param now current timestamp * @throws FailedSanityCheckException */ public void checkTimestamps(final Map<byte[], List<Cell>> familyMap, long now) throws FailedSanityCheckException { if (timestampSlop == HConstants.LATEST_TIMESTAMP) { return; } long maxTs = now + timestampSlop; for (List<Cell> kvs : familyMap.values()) { // Optimization: 'foreach' loop is not used. See: // HBASE-12023 HRegion.applyFamilyMapToMemstore creates too many iterator objects assert kvs instanceof RandomAccess; int listSize = kvs.size(); for (int i=0; i < listSize; i++) { Cell cell = kvs.get(i); // see if the user-side TS is out of range. latest = server-side long ts = cell.getTimestamp(); if (ts != HConstants.LATEST_TIMESTAMP && ts > maxTs) { throw new FailedSanityCheckException("Timestamp for KV out of range " + cell + " (too.new=" + timestampSlop + ")"); } } } }
final String msg = "Batch Mutation did not pass sanity check. "; if (observedExceptions.hasSeenFailedSanityCheck()) { LOG.warn(msg + fsce.getMessage()); } else { LOG.warn(msg, fsce); OperationStatusCode.SANITY_CHECK_FAILURE, fsce.getMessage()); if (isAtomic()) { throw fsce;
@Override public Result preAppend(ObserverContext<RegionCoprocessorEnvironment> e, Append append) throws IOException { // If authorization is not enabled, we don't care about reserved tags if (!authorizationEnabled) { return null; } for (CellScanner cellScanner = append.cellScanner(); cellScanner.advance();) { if (!checkForReservedVisibilityTagPresence(cellScanner.current())) { throw new FailedSanityCheckException("Append contains cell with reserved type tag"); } } return null; }
LOG.warn("Batch Mutation did not pass sanity check", fsce); batchOp.retCodeDetails[lastIndexExclusive] = new OperationStatus( OperationStatusCode.SANITY_CHECK_FAILURE, fsce.getMessage()); lastIndexExclusive++; continue;
@Override public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> e, Increment increment) throws IOException { // If authorization is not enabled, we don't care about reserved tags if (!authorizationEnabled) { return null; } for (CellScanner cellScanner = increment.cellScanner(); cellScanner.advance();) { if (!checkForReservedVisibilityTagPresence(cellScanner.current())) { throw new FailedSanityCheckException("Increment contains cell with reserved type tag"); } } return null; }
private void doBatchMutate(Mutation mutation) throws IOException { // Currently this is only called for puts and deletes, so no nonces. OperationStatus[] batchMutate = this.batchMutate(new Mutation[]{mutation}); if (batchMutate[0].getOperationStatusCode().equals(OperationStatusCode.SANITY_CHECK_FAILURE)) { throw new FailedSanityCheckException(batchMutate[0].getExceptionMsg()); } else if (batchMutate[0].getOperationStatusCode().equals(OperationStatusCode.BAD_FAMILY)) { throw new NoSuchColumnFamilyException(batchMutate[0].getExceptionMsg()); } else if (batchMutate[0].getOperationStatusCode().equals(OperationStatusCode.STORE_TOO_BUSY)) { throw new RegionTooBusyException(batchMutate[0].getExceptionMsg()); } }
e = new FailedSanityCheckException(codes[i].getExceptionMsg()); builder.addResultOrException(getResultOrException(e, index)); break;
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { byte[] errorType = get.getAttribute(SHOULD_ERROR_ATTRIBUTE); if (errorType != null) { ErrorType type = ErrorType.valueOf(Bytes.toString(errorType)); switch (type) { case CALL_QUEUE_TOO_BIG: throw new CallQueueTooBigException("Failing for test"); case MULTI_ACTION_RESULT_TOO_LARGE: throw new MultiActionResultTooLarge("Failing for test"); case FAILED_SANITY_CHECK: throw new FailedSanityCheckException("Failing for test"); case NOT_SERVING_REGION: throw new NotServingRegionException("Failing for test"); case REGION_MOVED: throw new RegionMovedException(e.getEnvironment().getServerName(), 1); case SCANNER_RESET: throw new ScannerResetException("Failing for test"); case UNKNOWN_SCANNER: throw new UnknownScannerException("Failing for test"); case REGION_TOO_BUSY: throw new RegionTooBusyException("Failing for test"); case OUT_OF_ORDER_SCANNER_NEXT: throw new OutOfOrderScannerNextException("Failing for test"); default: throw new DoNotRetryIOException("Failing for test"); } } }
@Override public void checkTimestamps(final Map<byte[], List<Cell>> familyMap, long now) throws FailedSanityCheckException { if (timestampSlop == HConstants.LATEST_TIMESTAMP) { return; } long maxTs = now + timestampSlop; for (List<Cell> kvs : familyMap.values()) { assert kvs instanceof RandomAccess; int listSize = kvs.size(); for (int i=0; i < listSize; i++) { Cell cell = kvs.get(i); // see if the user-side TS is out of range. latest = server-side long ts = cell.getTimestamp(); if (ts != HConstants.LATEST_TIMESTAMP && ts > maxTs) { throw new FailedSanityCheckException("Timestamp for KV out of range " + cell + " (too.new=" + timestampSlop + ")"); } } } }
@Override public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> e, Increment increment) throws IOException { // If authorization is not enabled, we don't care about reserved tags if (!authorizationEnabled) { return null; } for (CellScanner cellScanner = increment.cellScanner(); cellScanner.advance();) { if (!checkForReservedVisibilityTagPresence(cellScanner.current())) { throw new FailedSanityCheckException("Increment contains cell with reserved type tag"); } } return null; }
@Override public Result preAppend(ObserverContext<RegionCoprocessorEnvironment> e, Append append) throws IOException { // If authorization is not enabled, we don't care about reserved tags if (!authorizationEnabled) { return null; } for (CellScanner cellScanner = append.cellScanner(); cellScanner.advance();) { if (!checkForReservedVisibilityTagPresence(cellScanner.current())) { throw new FailedSanityCheckException("Append contains cell with reserved type tag"); } } return null; }
private void doBatchMutate(Mutation mutation) throws IOException { // Currently this is only called for puts and deletes, so no nonces. OperationStatus[] batchMutate = this.batchMutate(new Mutation[]{mutation}); if (batchMutate[0].getOperationStatusCode().equals(OperationStatusCode.SANITY_CHECK_FAILURE)) { throw new FailedSanityCheckException(batchMutate[0].getExceptionMsg()); } else if (batchMutate[0].getOperationStatusCode().equals(OperationStatusCode.BAD_FAMILY)) { throw new NoSuchColumnFamilyException(batchMutate[0].getExceptionMsg()); } }
e = new FailedSanityCheckException(codes[i].getExceptionMsg()); builder.addResultOrException(getResultOrException(e, index)); break;
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { byte[] errorType = get.getAttribute(SHOULD_ERROR_ATTRIBUTE); if (errorType != null) { ErrorType type = ErrorType.valueOf(Bytes.toString(errorType)); switch (type) { case CALL_QUEUE_TOO_BIG: throw new CallQueueTooBigException("Failing for test"); case MULTI_ACTION_RESULT_TOO_LARGE: throw new MultiActionResultTooLarge("Failing for test"); case FAILED_SANITY_CHECK: throw new FailedSanityCheckException("Failing for test"); case NOT_SERVING_REGION: throw new NotServingRegionException("Failing for test"); case REGION_MOVED: throw new RegionMovedException(e.getEnvironment().getServerName(), 1); case SCANNER_RESET: throw new ScannerResetException("Failing for test"); case UNKNOWN_SCANNER: throw new UnknownScannerException("Failing for test"); case REGION_TOO_BUSY: throw new RegionTooBusyException("Failing for test"); case OUT_OF_ORDER_SCANNER_NEXT: throw new OutOfOrderScannerNextException("Failing for test"); default: throw new DoNotRetryIOException("Failing for test"); } } }
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { byte[] errorType = get.getAttribute(SHOULD_ERROR_ATTRIBUTE); if (errorType != null) { ErrorType type = ErrorType.valueOf(Bytes.toString(errorType)); switch (type) { case CALL_QUEUE_TOO_BIG: throw new CallQueueTooBigException("Failing for test"); case MULTI_ACTION_RESULT_TOO_LARGE: throw new MultiActionResultTooLarge("Failing for test"); case FAILED_SANITY_CHECK: throw new FailedSanityCheckException("Failing for test"); case NOT_SERVING_REGION: throw new NotServingRegionException("Failing for test"); case REGION_MOVED: throw new RegionMovedException(e.getEnvironment().getServerName(), 1); case SCANNER_RESET: throw new ScannerResetException("Failing for test"); case UNKNOWN_SCANNER: throw new UnknownScannerException("Failing for test"); case REGION_TOO_BUSY: throw new RegionTooBusyException("Failing for test"); case OUT_OF_ORDER_SCANNER_NEXT: throw new OutOfOrderScannerNextException("Failing for test"); default: throw new DoNotRetryIOException("Failing for test"); } } }