Invalid partitioner hashing when using Python 3

Bug #1743243 reported by Marat Sharafutdinov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tooz
Fix Released
Undecided
Julien Danjou

Bug Description

There is hashing function at the Partitioner class:

@staticmethod
def _hash_object(obj):
    if hasattr(obj, "__tooz_hash__"):
        return obj.__tooz_hash__()
    return str(hash(obj)).encode('ascii')

If an object does not have implemented "__tooz_hash__" method than builtin "hash" function is used.
If Python 2 is used then it is ok, but since Python 3.3 "hash" function has randomization enabled by default (https://docs.python.org/3/reference/datamodel.html#object.__hash__) the `Partitioner.members_for_object` method which uses this static method returns unexpected results.

description: updated
description: updated
summary: - Invalid partitioner hashing using Python 3
+ Invalid partitioner hashing when using Python 3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tooz (master)

Fix proposed to branch: master
Review: https://review.openstack.org/535280

Changed in python-tooz:
assignee: nobody → Julien Danjou (jdanjou)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tooz (master)

Reviewed: https://review.openstack.org/535280
Committed: https://git.openstack.org/cgit/openstack/tooz/commit/?id=62fd552e1e1f40e265e3bf781170b21bfb5f4626
Submitter: Zuul
Branch: master

commit 62fd552e1e1f40e265e3bf781170b21bfb5f4626
Author: Julien Danjou <email address hidden>
Date: Thu Jan 18 11:28:23 2018 +0100

    partitioner: do not use hash() to determine object identity

    The `hash` method is random on Python 3, so it's not consistent between. Just
    use the string representation of the object as a default.

    Change-Id: I84e2b19b64dc1641f9758429248dc6b928122b18
    Closes-Bug: #1743243

Changed in python-tooz:
status: In Progress → Fix Released
Revision history for this message
Marat Sharafutdinov (decaz) wrote :

Thanks! When it will be released at PyPI?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tooz (master)

Fix proposed to branch: master
Review: https://review.openstack.org/541185

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on tooz (master)

Change abandoned by Julien Danjou (<email address hidden>) on branch: master
Review: https://review.openstack.org/541185

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tooz (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.openstack.org/543591

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tooz (stable/queens)

Reviewed: https://review.openstack.org/543591
Committed: https://git.openstack.org/cgit/openstack/tooz/commit/?id=0a5df3d74b6d4ea9afe6b5038791928a55bb33c3
Submitter: Zuul
Branch: stable/queens

commit 0a5df3d74b6d4ea9afe6b5038791928a55bb33c3
Author: Julien Danjou <email address hidden>
Date: Thu Jan 18 11:28:23 2018 +0100

    partitioner: do not use hash() to determine object identity

    The `hash` method is random on Python 3, so it's not consistent between. Just
    use the string representation of the object as a default.

    Change-Id: I84e2b19b64dc1641f9758429248dc6b928122b18
    Closes-Bug: #1743243
    (cherry picked from commit 62fd552e1e1f40e265e3bf781170b21bfb5f4626)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tooz 1.61.0

This issue was fixed in the openstack/tooz 1.61.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tooz 1.60.1

This issue was fixed in the openstack/tooz 1.60.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.