Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sink): fix mogodb write error handling #19869

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xxhZs
Copy link
Contributor

@xxhZs xxhZs commented Dec 20, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

in doc https://www.mongodb.com/zh-cn/docs/manual/reference/method/db.collection.bulkWrite/#mongodb-method-db.collection.bulkWrite
The correct error is writeErrors and writeConcernErrors
And you shouldn't use n to check if the write was successful, because there are times when n will be 0.
Let's say we delete a piece of mongodb non-existent data

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

@github-actions github-actions bot added the type/fix Bug fix label Dec 20, 2024
@xxhZs xxhZs requested a review from hzxa21 December 20, 2024 02:56
@ly9chee
Copy link
Contributor

ly9chee commented Dec 20, 2024

And you shouldn't use n to check if the write was successful, because there are times when n will be 0.
Let's say we delete a piece of mongodb non-existent data

The initial implementation checks n > 0 becase we assumes ownership of the sinking collection. There should not be a case where n == 0, unless the user manually modified the collection.

Should we also check the ok status? Then we can expect the command is succeeded and without any write errors.
https://www.mongodb.com/docs/manual/reference/command/delete/#output

@xxhZs
Copy link
Contributor Author

xxhZs commented Dec 20, 2024

And you shouldn't use n to check if the write was successful, because there are times when n will be 0.
Let's say we delete a piece of mongodb non-existent data

The initial implementation checks n > 0 becase we assumes ownership of the sinking collection. There should not be a case where n == 0, unless the user manually modified the collection.

Should we also check the ok status? Then we can expect the command is succeeded and without any write errors. https://www.mongodb.com/docs/manual/reference/command/delete/#output

add ok, Please review if you have time, thanks!

)
})?;
if n < 1 {
if let Ok(write_concern_error) = result.get_array("writeConcernError") {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the MongoDB documentation, the field name should be writeConcernErrors (plural) rather than writeConcernError. This mismatch will prevent proper error detection.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@ly9chee
Copy link
Contributor

ly9chee commented Dec 20, 2024

And you shouldn't use n to check if the write was successful, because there are times when n will be 0.
Let's say we delete a piece of mongodb non-existent data

The initial implementation checks n > 0 becase we assumes ownership of the sinking collection. There should not be a case where n == 0, unless the user manually modified the collection.
Should we also check the ok status? Then we can expect the command is succeeded and without any write errors. https://www.mongodb.com/docs/manual/reference/command/delete/#output

add ok, Please review if you have time, thanks!

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants