{"record":{"id":"52a70a1003df8df7","repo":"apache/seatunnel","slug":"collection-does-not-appear-to-be-sharded-fallb","errorCode":null,"errorMessage":"Collection {} does not appear to be sharded, fallback to SampleSplitter.","messagePattern":"Collection (.+?) does not appear to be sharded, fallback to SampleSplitter\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mongodb/source/splitters/ShardedSplitStrategy.java","lineNumber":62,"sourceCode":"\n@Slf4j\npublic class ShardedSplitStrategy implements SplitStrategy {\n\n    public static final ShardedSplitStrategy INSTANCE = new ShardedSplitStrategy();\n\n    private ShardedSplitStrategy() {}\n\n    @Override\n    public Collection<SnapshotSplit> split(@Nonnull SplitContext splitContext) {\n        TableId collectionId = splitContext.getCollectionId();\n        MongoClient mongoClient = splitContext.getMongoClient();\n\n        List<BsonDocument> chunks;\n        BsonDocument collectionMetadata;\n        try {\n            collectionMetadata = readCollectionMetadata(mongoClient, collectionId);\n            if (!isValidShardedCollection(collectionMetadata)) {\n                log.warn(\n                        \"Collection {} does not appear to be sharded, fallback to SampleSplitter.\",\n                        collectionId);\n                return SampleBucketSplitStrategy.INSTANCE.split(splitContext);\n            }\n            chunks = readChunks(mongoClient, collectionMetadata);\n        } catch (MongoQueryException e) {\n            if (e.getErrorCode() == UNAUTHORIZED_ERROR) {\n                log.warn(\n                        \"Unauthorized to read config.collections or config.chunks: {}, fallback to SampleSplitter.\",\n                        e.getErrorMessage());\n            } else {\n                log.warn(\n                        \"Read config.chunks collection failed: {}, fallback to SampleSplitter\",\n                        e.getErrorMessage());\n            }\n            return SampleBucketSplitStrategy.INSTANCE.split(splitContext);\n        }\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mongodb/source/splitters/ShardedSplitStrategy.java#L44-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// config before (wrong for unsharded collection)\nsplit.strategy = SHARDED\n// after\nsplit.strategy = SAMPLED","handlingStrategy":"validation","validationCode":"// mongosh: confirm sharded before choosing SHARDED strategy\nconst md = db.getSiblingDB('config').collections.findOne({_id: 'mydb.mycoll'});\nif (!md || !md.sharded) print('NOT SHARDED -> use SampleSplitter');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["mongodb","cdc","sharding","fallback"],"backgroundTag":"invalid-config-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}