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

[tokumx] Handle int64 and replica connections #2390

Merged
merged 1 commit into from Apr 13, 2016
Merged

Conversation

JohnLZeller
Copy link
Contributor

Ran into a situation where some data points coming from mongo are of type int64 (ie 0L, or 2L). We should take these into account and then coerce them to floats.

Additionally, the integration panel for TokuMX mentions specifying a full MongoDB URI, but the yaml shows no examples.

@JohnLZeller
Copy link
Contributor Author

@olivielpeau could you take a quick pass? it's small

@JohnLZeller JohnLZeller changed the title [tokumx] Handle int64 and update yaml [tokumx] Handle int64 and replica connections Mar 31, 2016
@JohnLZeller
Copy link
Contributor Author

I just added an additional commit to this PR which fixes an issue around reading replica sets.

As of pymongo version 3.0, the read_preference attribute of MongoClient is read-only.
We set read_preference to secondary when reading replicas, causing an AttributeError.
This commit creates a new database connection instead.

Also, database connections are created in a pool with MongoClient, and are automatically closed up for you. So there should be no need to close the connection ourselves before opening this new one, as pymongo should reuse connections.

socketTimeoutMS=DEFAULT_TIMEOUT*1000,
read_preference=ReadPreference.SECONDARY,
**ssl_params)
db = conn[db.name]
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we don't handle the authentication on this connection. We should maybe extract the actual connection creation logic from the _get_connection method and use it here.

@olivielpeau
Copy link
Member

Thanks for the fix! Added in 2 comments.

@JohnLZeller
Copy link
Contributor Author

@olivielpeau okay this should be good

@olivielpeau
Copy link
Member

Looks good, feel free to squash and merge!

As of pymongo version 3.0, the 'read_preference' attribute of 'MongoClient' is read-only.
We set `read_preference` to secondary when reading replicas, causing an AttributeError.
This commit creates a new database connection instead.
@JohnLZeller JohnLZeller merged commit 3f3ab2c into master Apr 13, 2016
@JohnLZeller JohnLZeller deleted the zeller/tokumx branch April 13, 2016 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants