+
Skip to content

Conversation

sergepetrenko
Copy link
Contributor

The function vshard.router.routeall is not marked as internal API, but it returns router.replicasets table, which is used by the router itself. And also vshard.router.route returns a replicaset object that is used internally. If user modifies the returned from routeall or route table, then router is broken and cannot continue to work properly after that.

Now routeall returns a new copy of the replicaset array to user on each call. So user can do whatever he wants with this array, without affecting the internal behavior of the router.
Also, each of the replicasets that are returned from routeall or route is a wrapper over the internal replicaset table. This wrapper contains the private field _replicaset, the value of which is the internal replicaset table. User should not touch this field. This wrapper only gives user access to the public replicaset methods: call, callrw, callro, callbro, callre, callbre.

Closes #502

NO_DOC=

The function `vshard.router.routeall` is not marked as internal API, but
it returns `router.replicasets` table, which is used by the router itself.
And also `vshard.router.route` returns a replicaset object that is used
internally. If user modifies the returned from `routeall` or `route`
table, then router is broken and cannot continue to work properly after
that.

Now `routeall` returns a new copy of the replicaset array to user on
each call. So user can do whatever he wants with this array, without
affecting the internal behavior of the router.
Also, each of the replicasets that are returned from `routeall` or `route`
is a wrapper over the internal replicaset table. This wrapper contains the
private field `_replicaset`, the value of which is the internal replicaset
table. User should not touch this field. This wrapper only gives user
access to the public replicaset methods: `call`, `callrw`, `callro`,
`callbro`, `callre`, `callbre`.

Closes #502

NO_DOC=<undocumented part>
@sergepetrenko sergepetrenko force-pushed the gh-502-protect-replicaset-from-modification branch from 5aaf32d to 3e0f75f Compare August 8, 2025 15:10
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.

router: protect routeall() and others from modification

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载