Commit c04e95f9 authored by Levin Zimmermann's avatar Levin Zimmermann Committed by Kirill Smelkov

lib/zodb: Insure NEO with > 1 master always normalizes to same URI

If a NEO cluster has multiple master nodes, there is no agreed
on order in which the master node addresses appear in the URI.
In order to insure we always get the same normalized URI among different
clients of a NEO cluster with more than one master node, we explicitly
sort the master node address order with this patch.

/reviewed-by @kirr
/reviewed-on !17
parent f5275f82
......@@ -551,6 +551,9 @@ def test_zstor_2zurl(tmpdir, neo_ssl_dict):
("zeo://localhost:9001", "zeo://localhost:9001"),
# NEO
("neo://127.0.0.1:1234/cluster", "neo://127.0.0.1:1234/cluster"),
# > 1 master nodes \w different order
("neo://abc:1,def:2/cluster", "neo://abc:1,def:2/cluster"),
("neo://def:2,abc:1/cluster", "neo://abc:1,def:2/cluster"),
# Different SSL paths
("neos://ca=a&key=b&cert=c@xyz:1/cluster", "neos://xyz:1/cluster"),
("neos://ca=α&key=β&cert=γ@xyz:1/cluster", "neos://xyz:1/cluster"),
......
......@@ -483,6 +483,12 @@ def _znormalize_neo(scheme, netloc, path, query, frag):
# instance.
if "@" in netloc:
netloc = netloc[netloc.index("@") + 1 :]
# Sort multiple master nodes: if a NEO cluster has multiple master
# nodes, there is no agreed on order in which the master node
# addresses appear in the netloc. In order to insure we always
# get the same mountpoint among different clients we explicitly
# sort the master node addr order.
netloc = ",".join(sorted(netloc.split(',')))
return (scheme, netloc, path, query, frag)
_znormalizer('neo', _znormalize_neo)
_znormalizer('neos', _znormalize_neo)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment