{"record":{"id":"9230555e485eea7f","repo":"apache/seatunnel","slug":"execute-splitvector-command-failed-fallback-t","errorCode":null,"errorMessage":"Execute splitVector command failed: {}, fallback to SampleSplitter","messagePattern":"Execute splitVector command 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/SplitVectorSplitStrategy.java","lineNumber":71,"sourceCode":"\n    @Override\n    public Collection<SnapshotSplit> split(@Nonnull SplitContext splitContext) {\n        MongoClient mongoClient = splitContext.getMongoClient();\n        TableId collectionId = splitContext.getCollectionId();\n        int chunkSizeMB = splitContext.getChunkSizeMB();\n\n        BsonDocument keyPattern = new BsonDocument(ID_FIELD, new BsonInt32(1));\n\n        BsonDocument splitResult;\n        try {\n            splitResult = splitVector(mongoClient, collectionId, keyPattern, chunkSizeMB);\n        } catch (MongoCommandException e) {\n            if (e.getErrorCode() == UNAUTHORIZED_ERROR) {\n                log.warn(\n                        \"Unauthorized to execute splitVector command: {}, fallback to SampleSplitter\",\n                        e.getErrorMessage());\n            } else {\n                log.warn(\n                        \"Execute splitVector command failed: {}, fallback to SampleSplitter\",\n                        e.getErrorMessage());\n            }\n            return SampleBucketSplitStrategy.INSTANCE.split(splitContext);\n        }\n\n        if (!isCommandSucceed(splitResult)) {\n            log.warn(\n                    \"Could not calculate standalone splits: {}, fallback to SampleSplitter\",\n                    splitResult.getString(\"errmsg\"));\n            return SampleBucketSplitStrategy.INSTANCE.split(splitContext);\n        }\n\n        BsonArray splitKeys = splitResult.getArray(\"splitKeys\");\n        if (CollectionUtils.isEmpty(splitKeys)) {\n            // documents size is less than chunk size, treat the entire collection as single chunk.\n            return SingleSplitStrategy.INSTANCE.split(splitContext);\n        }","sourceCodeStart":53,"sourceCodeEnd":89,"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/SplitVectorSplitStrategy.java#L53-L89","documentation":"SplitVectorSplitStrategy caught a MongoCommandException whose error code is not 13 while executing the splitVector command. It logs this warning with the server's error message and falls back to SampleBucketSplitter. The command itself failed for a non-authorization reason (bad keyPattern, size limits, unsupported cluster).","triggerScenarios":"splitVector(mongoClient, collectionId, keyPattern, chunkSizeMB) throws MongoCommandException with code != 13 — e.g. code 2 (BadValue) for an invalid keyPattern, unsupported command on the topology, or invalid maxChunkSizeMB.","commonSituations":"Running splitVector against mongos in some versions (must target shards directly); wrong shard-key field in keyPattern config; chunkSizeMB set outside allowed bounds; standalone/replica-set deployment without sharding support.","solutions":["Read the logged server error message to identify the command failure reason.","Verify keyPattern matches the collection's actual shard/index key.","On sharded clusters, ensure splitVector is supported through your topology/driver version.","Switch to the SampleSplitter strategy if splitVector is unsupported in your environment."],"exampleFix":"// before: keyPattern field not part of shard key\nkeyPattern = new Document(\"nonIndexedField\", 1)\n// after: use the shard key\nkeyPattern = new Document(\"userId\", 1)","handlingStrategy":"validation","validationCode":"// verify keyPattern matches the shard key\nconst md = db.getSiblingDB('config').collections.findOne({_id: 'mydb.mycoll'});\nprintjson(md && md.key); // use exactly this in the split config","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always derive keyPattern from the collection's shard key metadata.","Keep chunkSizeMB within server-accepted bounds.","Confirm splitVector availability on your MongoDB version/topology before selecting the strategy."],"tags":["mongodb","cdc","command-error","splitvector"],"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"}