You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Robert Metzger (Jira)" <ji...@apache.org> on 2026/04/01 18:20:00 UTC
[jira] [Commented] (FLINK-39334) flink-connector-mongodb fails when write concern is set to zero
[ https://issues.apache.org/jira/browse/FLINK-39334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18070407#comment-18070407 ]
Robert Metzger commented on FLINK-39334:
----------------------------------------
Yes, Jacob, I'll assign you.
[~jiabaosun] can you review the change?
> flink-connector-mongodb fails when write concern is set to zero
> ---------------------------------------------------------------
>
> Key: FLINK-39334
> URL: https://issues.apache.org/jira/browse/FLINK-39334
> Project: Flink
> Issue Type: Bug
> Components: Connectors / MongoDB
> Affects Versions: 1.20.3
> Reporter: Jacob Jona Fahlenkamp
> Priority: Minor
>
> When specifying write concern zero, the mongo sink fails. This is because [it always sets the bypassDocumentValidation option.|https://github.com/apache/flink-connector-mongodb/blob/main/flink-connector-mongodb/src/main/java/org/apache/flink/connector/mongodb/sink/writer/MongoWriter.java#L221]. But if the write concern is set to zero this is not allowed by the mongo driver. The fix would be to set the bypassDocumentValidation option only if it's true.
> Reproduction:
> {code:java}
> @Container
> private static final MongoDBContainer MONGO_CONTAINER =
> MongoTestUtil.createMongoDBContainer();
> @Test
> void writeConcernZero() throws Exception {
> MongoSink<BsonDocument> sink = MongoSink.<BsonDocument>builder()
> .setUri(MONGO_CONTAINER.getConnectionString() + "/?w=0")
> .setDatabase("database")
> .setCollection("collection")
> .setSerializationSchema((doc, context) -> new InsertOneModel<>(doc))
> .build();
> StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
> env.fromData(new BsonDocument("hello", new BsonString("world")))
> .sinkTo(sink);
> env.execute();
> } {code}
> this throws:
> {code:java}
> com.mongodb.MongoClientException: Specifying bypassDocumentValidation with an unacknowledged WriteConcern is not supported{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)