{"record":{"id":"a2984334295bb171","repo":"apache/seatunnel","slug":"unauthorized-to-execute-splitvector-command-f","errorCode":null,"errorMessage":"Unauthorized to execute splitVector command: {}, fallback to SampleSplitter","messagePattern":"Unauthorized to execute splitVector command: (.+?), 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":67,"sourceCode":"\n@Slf4j\npublic enum SplitVectorSplitStrategy implements SplitStrategy {\n    INSTANCE;\n\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\");","sourceCodeStart":49,"sourceCodeEnd":85,"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#L49-L85","documentation":"SplitVectorSplitStrategy runs the splitVector command to compute chunk-sized split keys. If MongoDB rejects the command with error code 13 (Unauthorized) via MongoCommandException, the strategy logs this warning and falls back to SampleBucketSplitter. The user lacks privileges to execute splitVector on the collection.","triggerScenarios":"split() calls splitVector(...) and the server responds with MongoCommandException errorCode == 13, e.g. user without splitVector privilege on the target namespace.","commonSituations":"Minimal-privilege users that can read data but not run admin/diagnostic commands; splitVector requires specific privileges often missing for app users; restricted deployments (Atlas, managed services) blocking splitVector.","solutions":["Grant the connector user privileges to run splitVector (e.g. clusterManager role or a custom role with splitVector action).","Or select the SampleSplitter strategy explicitly instead of splitVector.","Test manually: db.runCommand({splitVector: \"db.coll\", keyPattern: {...}, maxChunkSizeBytes: N}).","Note some managed services disallow splitVector entirely — use sampling there."],"exampleFix":"// mongosh: grant splitVector-capable role\nuse admin\ndb.grantRolesToUser(\"seaTunnelUser\", [{role: \"clusterManager\", db: \"admin\"}])","handlingStrategy":"validation","validationCode":"// mongosh: probe splitVector privilege upfront\nconst r = db.runCommand({splitVector: 'mydb.mycoll', keyPattern: {userId: 1}, maxChunkSizeBytes: 64*1024*1024});\nprint('ok=' + r.ok + ' errmsg=' + (r.errmsg || ''));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grant splitVector privilege (or clusterManager role) to the CDC user.","On managed services that block splitVector, choose the SampleSplitter strategy by default.","Pre-flight the command in mongosh with the exact keyPattern/chunk size."],"tags":["mongodb","cdc","authorization","splitvector"],"backgroundTag":"permission-denied","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"}