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

[0.19]: change value of parameter "w" from 0 to 1 in XHGui\Saver\MongoSaver.save #358

Draft
wants to merge 1 commit into
base: 0.19.x
Choose a base branch
from

Conversation

ym2048
Copy link

@ym2048 ym2048 commented Oct 23, 2020

change value of parameter "w" from 0 to 1 in XHGui\Saver\MongoSaver.save,so that function will return clear tip when insert data to mongodb failed.

@glensc
Copy link
Contributor

glensc commented Oct 23, 2020

does this change return value? does it make used call to throw on failure?

@glensc
Copy link
Contributor

glensc commented Oct 24, 2020

Seems the answer is "makes code to throw"

as the pipeline fails now with duplicate key errors:

1) XHGui\Test\Searcher\MongoTest::testCustomQuery
MongoDuplicateKeyException: E11000 duplicate key error collection: test_xhprof.results index: _id_ dup key: { : ObjectId('aaaaaaaaaaaaaaaaaaaaaaaa') }

@glensc glensc marked this pull request as draft October 24, 2020 08:18
@ym2048
Copy link
Author

ym2048 commented Nov 7, 2020

Sorry, the reply is a little late

The official document describes the value of the w parameter as follows:

https://www.php.net/manual/zh/mongo.writeconcerns.php
w=0: A write will not be followed up with a GLE call, and therefore not checked ("fire and forget")
w=1: The write will be acknowledged by the server (the primary on replica set configuration)

If mongodb fails to perform the insert operation, such as primary key conflict, in the case of w= 0, the program will directly return true, and the user will not get any error prompt.

I guess w = 0 is set for performance consideration, but in the debugging stage, it may cause some problems. Maybe the better choice is to parameterize. The value is 0 in debugging and 1 in production phase

@ym2048
Copy link
Author

ym2048 commented Nov 7, 2020

If you agree with me, I'll be happy to modify the code in this way. Thanks for your time.

@glensc glensc closed this Nov 7, 2020
@glensc glensc reopened this Nov 7, 2020
@glensc
Copy link
Contributor

glensc commented Nov 7, 2020

self::getLastProfilingId() makes no more sense and should be deleted. you can see the discussion here:

it should actually return new value each time when called so the import.php can work for missing id-s.

w=1 can't be used with current code, as the unit test will fail, the unit tests need to be fixed first. likely needs to have support code to check if id already exists, and skip

@glensc
Copy link
Contributor

glensc commented Nov 7, 2020

also, you need to rebase against current master this branch to catch up changes to CI

@glensc glensc closed this Feb 12, 2021
@glensc glensc deleted the branch perftools:0.19.x February 12, 2021 12:24
@glensc
Copy link
Contributor

glensc commented Feb 12, 2021

@glensc glensc reopened this Feb 12, 2021
@glensc glensc changed the base branch from master to 0.19.x February 12, 2021 12:35
@glensc glensc changed the title change value of parameter "w" from 0 to 1 in XHGui\Saver\MongoSaver.save [0.19]: change value of parameter "w" from 0 to 1 in XHGui\Saver\MongoSaver.save Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants