Skip to content

Conversation

apodelko
Copy link
Contributor

@apodelko apodelko commented Nov 9, 2021

A short-term fix for py-tpcc to allow it to run on Atlas. See details on PERF-2676.

@apodelko apodelko requested review from asya999 and dalyd November 9, 2021 22:14
self.result_doc.update(result_doc)
self.result_doc['after']=self.get_server_status()
self.client.test.results.save(self.result_doc)
self.client.test.results.save(self.result_doc, check_keys=False)
Copy link

Choose a reason for hiding this comment

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

It looks like save is deprecated. should this be an insert_one or replace_one?

@apodelko
Copy link
Contributor Author

Here is the variant with insert_one. Here is the patch. But we need new Pymongo 3.12.1 - otherwise we get the same error in Atlas with MongoDb 5.0 (we have currently 3.11.1 in workload_setup.common.yml). It appears that we officially need 3.12.1 to support MongoDB 5.0 - so it is probably the right thing to do. The suggestion is to use insert_one as advised by the Python driver team and update Pymongo to 3.12.1 (for which I will create another PR in dsi if we agree on this approach). Any thoughts?

@apodelko apodelko requested review from dalyd and jimoleary November 21, 2021 01:32
self.result_doc.update(result_doc)
self.result_doc['after']=self.get_server_status()
self.client.test.results.save(self.result_doc)
self.client.test.results.insert_one(self.result_doc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is correct, save is either an insert or a replace. The logic above only mimics the first part.

Should this be an upsert (see here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jimoleary That is correct, it does formally change the logic. The literal replacement would be with the whole code you linked above. However as far as I was looking into what is going on here, it appears that only insert happens here - there is nothing to update. Unless I missed something here, why we should process update_one logic here if it never happens?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not as familiar with this code so I'll defer to you. But can we add a comment to say that this is the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a comment - let me know if it helps

Copy link

Choose a reason for hiding this comment

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

Comment looks good. I don't believe we ever set an explicit _id field in result_doc, so this should always be an insert.

Copy link

Choose a reason for hiding this comment

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

I'm also not a fan of saving the results back into the database itself, but that's a separate issue.

@apodelko
Copy link
Contributor Author

Actually we have pymongo upgrade in another PR

@apodelko apodelko requested a review from jimoleary November 23, 2021 18:47
Copy link

@dalyd dalyd left a comment

Choose a reason for hiding this comment

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

Update to insert_one sounds good to me. LGTM.

self.result_doc.update(result_doc)
self.result_doc['after']=self.get_server_status()
self.client.test.results.save(self.result_doc)
self.client.test.results.insert_one(self.result_doc)
Copy link

Choose a reason for hiding this comment

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

Comment looks good. I don't believe we ever set an explicit _id field in result_doc, so this should always be an insert.

self.result_doc.update(result_doc)
self.result_doc['after']=self.get_server_status()
self.client.test.results.save(self.result_doc)
self.client.test.results.insert_one(self.result_doc)
Copy link

Choose a reason for hiding this comment

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

I'm also not a fan of saving the results back into the database itself, but that's a separate issue.

@apodelko apodelko merged commit ef64930 into mongodb-labs:master Nov 29, 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.

3 participants