Github user sumanth-pasupuleti commented on a diff in the pull request: https://github.com/apache/cassandra/pull/277#discussion_r227077676 --- Diff: src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java --- @@ -307,6 +320,55 @@ public static void setViewRemoved(String keyspaceName, String viewName) forceBlockingFlush(VIEW_BUILD_STATUS); } + /** + * Reads blacklisted partitions from system_distributed.blacklisted_partitions table. + * Stops reading partitions upon exceeding the cache size limit by logging a warning. + * @return + */ + public static Set<BlacklistedPartition> getBlacklistedPartitions() + { + String query = "SELECT keyspace_name, columnfamily_name, partition_key FROM %s.%s"; + UntypedResultSet results; + try + { + results = QueryProcessor.execute(format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, BLACKLISTED_PARTITIONS), + ConsistencyLevel.ONE); + } + catch (Exception e) + { + logger.error("Error querying blacklisted partitions", e); + return Collections.emptySet(); + } + + Set<BlacklistedPartition> blacklistedPartitions = new HashSet<>(); + int cacheSize = 0; + for (UntypedResultSet.Row row : results) + { + try + { + BlacklistedPartition blacklistedPartition = new BlacklistedPartition(row.getString("keyspace_name"), row.getString("columnfamily_name"), row.getString("partition_key")); + + // check if adding this blacklisted partition would increase cache size beyond the set limit. + cacheSize += blacklistedPartition.unsharedHeapSize(); + if (cacheSize / (1024 * 1024) > DatabaseDescriptor.getBlackListedPartitionsCacheSizeLimitInMB()) + { + logger.warn("BlacklistedPartitions cache size limit of {} MB reached. Unable to load more blacklisted partitions. BlacklistedPartitions cache working in degraded mode.", DatabaseDescriptor.getBlackListedPartitionsCacheSizeLimitInMB()); --- End diff -- done
--- --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org