apache/seatunnel · warning
Collection does not appear to be sharded, fallback to…
Error message
Collection {} does not appear to be sharded, fallback to SampleSplitter. What it means
ShardedSplitStrategy.split first reads the collection's metadata from config.collections. If the metadata is missing or the collection is not marked sharded, it logs this warning and falls back to SampleBucketSplitStrategy (sampling-based splitting). Splits are still produced, just via sampling instead of chunk boundaries.
Solutions
- Shard the collection (sh.shardCollection) if chunk-based splitting is desired.
- Or explicitly configure the SampleSplitter/sampled split strategy for unsharded collections.
- Verify collection is sharded: db.collection.getShardVersion() or sh.status() in mongo shell.
- Ignore if fallback sampling is acceptable — this is only a warning.
Example fix
// config before (wrong for unsharded collection) split.strategy = SHARDED // after split.strategy = SAMPLED
Defensive patterns
Strategy: validation
Validate before calling
// mongosh: confirm sharded before choosing SHARDED strategy
const md = db.getSiblingDB('config').collections.findOne({_id: 'mydb.mycoll'});
if (!md || !md.sharded) print('NOT SHARDED -> use SampleSplitter'); Prevention
- Match split strategy to actual collection sharding state.
- Run sh.status() during environment setup to inventory sharded namespaces.
- Re-check sharding state after topology changes.
When it happens
Trigger: Calling split() on a collection whose config.collections entry is absent or whose 'sharded'/partitioned flag is false — i.e. an unsharded collection was assigned to the sharded split strategy.
Common situations: Configuring split.strategy=sharded (chunk-based) against a replica-set or unsharded collection; collection was unsharded after config was written; mongos routing to a non-sharded namespace.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Could not calculate standalone splits
- Read config.chunks collection failed
- Unauthorized to read config.collections or config.chunks
- Cannot extract clusterTime from change stream event…
- Change stream cursor has expired, trying to recreate cursor
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/52a70a1003df8df7.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mongodb/source/splitters/ShardedSplitStrategy.java:62
@Slf4j
public class ShardedSplitStrategy implements SplitStrategy {
public static final ShardedSplitStrategy INSTANCE = new ShardedSplitStrategy();
private ShardedSplitStrategy() {}
@Override
public Collection<SnapshotSplit> split(@Nonnull SplitContext splitContext) {
TableId collectionId = splitContext.getCollectionId();
MongoClient mongoClient = splitContext.getMongoClient();
List<BsonDocument> chunks;
BsonDocument collectionMetadata;
try {
collectionMetadata = readCollectionMetadata(mongoClient, collectionId);
if (!isValidShardedCollection(collectionMetadata)) {
log.warn(
"Collection {} does not appear to be sharded, fallback to SampleSplitter.",
collectionId);
return SampleBucketSplitStrategy.INSTANCE.split(splitContext);
}
chunks = readChunks(mongoClient, collectionMetadata);
} catch (MongoQueryException e) {
if (e.getErrorCode() == UNAUTHORIZED_ERROR) {
log.warn(
"Unauthorized to read config.collections or config.chunks: {}, fallback to SampleSplitter.",
e.getErrorMessage());
} else {
log.warn(
"Read config.chunks collection failed: {}, fallback to SampleSplitter",
e.getErrorMessage());
}
return SampleBucketSplitStrategy.INSTANCE.split(splitContext);
}
View on GitHub (pinned to cf67b549a7)