{"record":{"id":"301a8dc67e07ac1b","repo":"apache/seatunnel","slug":"illegal-argument-301a8d","errorCode":"ILLEGAL_ARGUMENT","errorMessage":"Execute snapshot read subtask for mongodb split %s fail","messagePattern":"Execute snapshot read subtask for mongodb split (.+?) fail","errorType":"error_code","errorClass":"MongodbConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mongodb/source/fetch/MongodbScanFetchTask.java","lineNumber":155,"sourceCode":"            final boolean streamBackfillRequired =\n                    dataBackfillSplit.getStopOffset().isAfter(dataBackfillSplit.getStartupOffset());\n\n            if (!streamBackfillRequired) {\n                changeEventQueue.enqueue(\n                        new DataChangeEvent(\n                                WatermarkEvent.create(\n                                        createWatermarkPartitionMap(collectionId.identifier()),\n                                        \"__mongodb_watermarks\",\n                                        dataBackfillSplit.splitId(),\n                                        WatermarkKind.END,\n                                        dataBackfillSplit.getStopOffset())));\n            } else {\n                MongodbStreamFetchTask dataBackfillTask =\n                        new MongodbStreamFetchTask(dataBackfillSplit);\n                dataBackfillTask.execute(taskContext);\n            }\n        } catch (Exception e) {\n            throw new MongodbConnectorException(\n                    ILLEGAL_ARGUMENT,\n                    String.format(\n                            \"Execute snapshot read subtask for mongodb split %s fail\",\n                            snapshotSplit),\n                    e);\n        } finally {\n            taskRunning = false;\n        }\n    }\n\n    @Nonnull\n    private MongoCursor<RawBsonDocument> getSnapshotCursor(\n            @Nonnull SnapshotSplit snapshotSplit,\n            MongodbSourceConfig sourceConfig,\n            MongoClient mongoClient) {\n        MongoCollection<RawBsonDocument> collection =\n                getMongoCollection(mongoClient, snapshotSplit.getTableId(), RawBsonDocument.class);\n        BsonDocument startKey = (BsonDocument) snapshotSplit.getSplitStart()[1];","sourceCodeStart":137,"sourceCodeEnd":173,"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/fetch/MongodbScanFetchTask.java#L137-L173","documentation":"A catch-all wrapper thrown by MongodbScanFetchTask.execute when executing a snapshot (or stream backfill) subtask for a MongoDB split fails with any exception. It preserves the root cause while labeling the failure with the split being read.","triggerScenarios":"Any exception inside snapshot split reading — MongoDB connection failure, query timeout, cursor exhaustion, authorization error, or failure executing the nested data-backfill stream task.","commonSituations":"MongoDB server restart or network partition mid-snapshot; replica set primary switch during a large collection scan; the embedded change-stream backfill task (error 424/425) failing underneath.","solutions":["Read the 'Caused by' exception to find the actual root cause (auth, timeout, network, change-stream failure)","Verify network connectivity and replica set health between SeaTunnel workers and MongoDB","Increase MongoDB socket/connection timeouts if the snapshot is large","Re-run the job — snapshot splits are checkpointable and will resume from the failed split"],"exampleFix":"// before\nMongoClientSettings.builder().applyToSocketSettings(b -> b.connectTimeout(10, SECONDS)).build();\n// after\nMongoClientSettings.builder().applyToSocketSettings(b -> b.connectTimeout(60, SECONDS).readTimeout(0, SECONDS)).build();","handlingStrategy":"retry","validationCode":"// verify connectivity before submitting the job\ntry (MongoClient c = MongoClients.create(uri)) { c.getDatabase(\"admin\").runCommand(new BsonDocument(\"ping\", new BsonInt32(1))); }","typeGuard":null,"tryCatchPattern":"try { runJob() } catch (MongodbConnectorException e) { /* 'Execute snapshot read subtask ... fail' — inspect cause, then resume job from checkpoint */ }","preventionTips":["Use a replica-set connection string with all hosts listed","Size snapshot parallelism and timeouts for the collection size","Monitor replica set health before and during snapshotting"],"tags":["mongodb","cdc","snapshot","task-failure"],"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-14T11:17:12.474Z"}