{"record":{"id":"e8b8b20cfa4998d2","repo":"apache/seatunnel","slug":"read-config-chunks-collection-failed-fallback","errorCode":null,"errorMessage":"Read config.chunks collection failed: {}, fallback to SampleSplitter","messagePattern":"Read config\\.chunks collection failed: (.+?), 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":74,"sourceCode":"\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\n        if (chunks.isEmpty()) {\n            log.warn(\n                    \"Collection {} does not appear to be sharded, fallback to SampleSplitter.\",\n                    collectionId);\n            return SampleBucketSplitStrategy.INSTANCE.split(splitContext);\n        }\n\n        BsonDocument splitKeys = collectionMetadata.getDocument(SHARD_KEY_FIELD);\n        SeaTunnelRowType rowType = shardKeysToRowType(splitKeys);\n\n        List<SnapshotSplit> snapshotSplits = new ArrayList<>(chunks.size());\n        for (int i = 0; i < chunks.size(); i++) {","sourceCodeStart":56,"sourceCodeEnd":92,"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#L56-L92","documentation":"ShardedSplitStrategy caught a MongoQueryException other than code 13 while reading config.chunks. It logs this warning with the server error message and falls back to SampleBucketSplitter. Chunk boundaries could not be read, so sampling is used to generate splits.","triggerScenarios":"readChunks(mongoClient, collectionMetadata) issues a query on config.chunks that fails with a non-authorization MongoQueryException (e.g. query failure on the config database, mongos routing error, stale metadata).","commonSituations":"Transient cluster issues (balancer moving chunks, config server primary changes); shard cluster metadata inconsistencies; network hiccups between connector and mongos.","solutions":["Inspect the logged server error message for the underlying cause.","Retry the job — many causes (balancer churn) are transient.","Verify mongos connectivity and config server health (sh.status()).","Use the SampleSplitter explicitly if chunk reads are persistently unreliable."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// wrap split planning with retry on MongoQueryException\ntry {\n    return shardedStrategy.split(ctx);\n} catch (MongoQueryException e) {\n    log.warn(\"chunk read failed, retrying or falling back\", e);\n    return sampleStrategy.split(ctx);\n}","preventionTips":["Retry transient config.chunks read failures before falling back.","Keep mongos/config-server connectivity healthy and monitored.","Avoid running splits during heavy balancer activity if possible."],"tags":["mongodb","cdc","sharding","query-error"],"backgroundTag":"database-query-failed","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"}