{"record":{"id":"7e1719da1aea4aff","repo":"apache/seatunnel","slug":"illegal-argument-7e1719","errorCode":"ILLEGAL_ARGUMENT","errorMessage":"Poll change stream records failed","messagePattern":"Poll change stream records failed","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/MongodbStreamFetchTask.java","lineNumber":230,"sourceCode":"\n                    // Reach the high watermark, the binlog fetcher should be finished\n                    if (currentOffset.isAtOrAfter(streamSplit.getStopOffset())) {\n                        // send watermark end event\n                        SourceRecord watermark =\n                                WatermarkEvent.create(\n                                        createWatermarkPartitionMap(descriptor.toString()),\n                                        \"__mongodb_watermarks\",\n                                        streamSplit.splitId(),\n                                        WatermarkKind.END,\n                                        currentOffset);\n\n                        queue.enqueue(new DataChangeEvent(watermark));\n                        break;\n                    }\n                }\n            }\n        } catch (Exception e) {\n            throw new MongodbConnectorException(\n                    ILLEGAL_ARGUMENT, \"Poll change stream records failed\");\n        } finally {\n            taskRunning = false;\n            if (changeStreamCursor != null) {\n                changeStreamCursor.close();\n            }\n        }\n    }\n\n    @Override\n    public boolean isRunning() {\n        return taskRunning;\n    }\n\n    @Override\n    public void shutdown() {\n        taskRunning = false;\n    }","sourceCodeStart":212,"sourceCodeEnd":248,"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/MongodbStreamFetchTask.java#L212-L248","documentation":"Wrapper thrown by MongodbStreamFetchTask.execute when polling the MongoDB change stream cursor raises any exception. The original cause is swallowed (not chained) in this message, so the underlying MongoDB error must be found in preceding logs.","triggerScenarios":"Any failure while iterating the change-stream cursor: connection drop, cursor timeout/idle, replica-set election invalidating the cursor, resume-token no longer valid, or deserialization errors.","commonSituations":"MongoDB replica set elections during deployments; network partitions; change stream left idle beyond server's cursor lifetime; oplog rolling over so the resume token expires.","solutions":["Check worker logs immediately before this error for the underlying MongoDB driver exception","Verify network stability and connection-string failover settings (replicaSet, multiple hosts)","Reduce time the stream is idle or ensure the oplog window covers the pause (oplog size)","From a checkpoint restart, the stream task will reopen with the last resume token; if the token expired, restart from a new snapshot"],"exampleFix":"// before: small oplog window loses resume tokens\n// after (mongod.conf): increase oplog size\nreplication:\n  oplogSizeMB: 20480","handlingStrategy":"retry","validationCode":"// pre-check: ensure replica set reachable and oplog window healthy\nMongoDatabase admin = client.getDatabase(\"admin\");\nDocument st = admin.runCommand(new Document(\"replSetGetStatus\", 1));","typeGuard":null,"tryCatchPattern":"try { pollRecords() } catch (MongodbConnectorException e) { if (\"Poll change stream records failed\".equals(e.getMessage())) { backoffAndReopenCursor(); } else { throw e; } }","preventionTips":["List multiple replica-set hosts in the URI for failover","Keep the oplog window much larger than the maximum possible idle/pause time","Monitor and restart from checkpoint — the stream reopens with the last resume token"],"tags":["mongodb","cdc","change-stream","poll-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-14T05:17:10.506Z"}