-
Notifications
You must be signed in to change notification settings - Fork 209
Add details to the generic BulkWriteCommandException
message
#1821
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
Closed
GromNaN
wants to merge
1
commit into
mongodb:feature/client-bulk-write
from
GromNaN:bulk-write-exception
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--TEST-- | ||
MongoDB\Driver\BulkWriteCommandResult::isAcknowledged() with unacknowledged write concern | ||
--SKIPIF-- | ||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | ||
<?php skip_if_not_live(); ?> | ||
<?php skip_if_server_version('<', '8.0'); ?> | ||
<?php skip_if_not_clean(); ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . "/../utils/basic.inc"; | ||
|
||
$manager = create_test_manager(URI); | ||
|
||
$bulk = new MongoDB\Driver\BulkWriteCommand(['ordered' => false]); | ||
$bulk->insertOne(NS, ['_id' => 1]); | ||
$bulk->insertOne(NS, ['_id' => 1]); | ||
|
||
echo throws(function() use ($result) { | ||
$manager->executeBulkWriteCommand($bulk); | ||
}, MongoDB\Driver\Exception\BulkWriteCommandException::class), "\n"; | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
bool(false) | ||
OK: Got MongoDB\Driver\Exception\BulkWriteCommandException | ||
Bulk write failed with 0 write concern errors and 1 write errors | ||
===DONE=== |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alcaeus I don't know how to debug this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because of how the
mongoc_bulkwriteresult_t
is defined. Whilemongoc_bulkwriteresult_t
is defined in the .h file (which we include), it points to a struct that is defined in the .c file. This means that you can access members of a variable in the C file, but not outside of it, for example here as the internal_mongoc_bulkwriteresult_t
struct doesn't exist. This makes up for the fact that there are no visibilities for structural members in C, and this way libmongoc limits the scope of its external API.To access struct fields, libmongoc exposes some functions to extract data from a
mongoc_bulkwriteresult_t
, but notably it doesn't expose theerrorscount
field. Then_write_concern_errors
andn_write_errors
field don't exist in the struct at all.IMO, we should tell people to check the exception object for error details for the time being; we can then discuss whether the C team can add an API to expose the total number of errors.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
BulkWriteCommandException
class exposesgetWriteErrors
andgetWriteConcernErrors
. It should be possible to count this values to inject this counts in the exception message. Or maybe wrap this exception in PHPLIB to improve the message.