xhgui icon indicating copy to clipboard operation
xhgui copied to clipboard

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

Open ym2048 opened this issue 4 years ago • 7 comments

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.

ym2048 avatar Oct 23 '20 09:10 ym2048

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

glensc avatar Oct 23 '20 09:10 glensc

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 avatar Oct 24 '20 08:10 glensc

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 avatar Nov 07 '20 08:11 ym2048

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

ym2048 avatar Nov 07 '20 09:11 ym2048

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

  • https://github.com/perftools/php-profiler/issues/39

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 avatar Nov 07 '20 09:11 glensc

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

glensc avatar Nov 07 '20 09:11 glensc

Revert unintended close:

  • https://github.com/perftools/xhgui/pull/415#issuecomment-778168929

glensc avatar Feb 12 '21 12:02 glensc