Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
69c82a3c
Commit
69c82a3c
authored
6 months ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
fix: used to fail sdk rpc in case target was self
parent
ecc4e2c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1282
fix: used to fail sdk rpc in case target was self
Pipeline
#51104
passed
5 months ago
Stage: test
Stage: docker
Stage: stress-test
Stage: front-deploy
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugin/rpc/client.rs
+4
-4
4 additions, 4 deletions
src/plugin/rpc/client.rs
test/int/test_plugin.py
+30
-0
30 additions, 0 deletions
test/int/test_plugin.py
with
34 additions
and
4 deletions
src/plugin/rpc/client.rs
+
4
−
4
View file @
69c82a3c
...
...
@@ -389,8 +389,8 @@ fn resolve_rpc_target(
// XXX: this shouldn't be a problem if replicasets aren't too big,
// but if they are we might want to construct a HashSet from candidates
for
instance_id
in
replicas
{
if
my_instance_id
==
instance_id
{
//
Don't want to call
self
if
my_instance_id
==
instance_id
&&
candidates
.len
()
>
1
{
//
Prefer someone else instead of
self
continue
;
}
if
candidates
.contains
(
&
instance_id
)
{
...
...
@@ -406,8 +406,8 @@ fn resolve_rpc_target(
// TODO: find a better strategy then just the random one
let
random_index
=
rand
::
random
::
<
usize
>
()
%
candidates
.len
();
let
mut
instance_id
=
std
::
mem
::
take
(
&
mut
candidates
[
random_index
]);
if
instance_id
==
my_instance_id
{
//
Don't want to call
self
if
instance_id
==
my_instance_id
&&
candidates
.len
()
>
1
{
//
Prefer someone else instead of
self
let
index
=
(
random_index
+
1
)
%
candidates
.len
();
instance_id
=
std
::
mem
::
take
(
&
mut
candidates
[
index
]);
}
...
...
This diff is collapsed.
Click to expand it.
test/int/test_plugin.py
+
30
−
0
View file @
69c82a3c
...
...
@@ -2477,6 +2477,36 @@ cluster:
# TODO: check calling to poisoned service
def
test_plugin_rpc_sdk_single_instance
(
cluster
:
Cluster
):
i1
=
cluster
.
add_instance
(
wait_online
=
True
,
init_replication_factor
=
1
)
plugin_name
=
_PLUGIN_W_SDK
service_name
=
SERVICE_W_RPC
install_and_enable_plugin
(
i1
,
plugin_name
,
[
service_name
],
migrate
=
True
)
# Check sending request with `master = false` when there's ony one instance
context
=
make_context
()
input
=
dict
(
service_info
=
(
plugin_name
,
service_name
,
_PLUGIN_VERSION_1
),
path
=
"
/ping
"
,
input
=
"
by-bucket-id
"
,
bucket_id
=
13
,
to_master
=
False
,
)
i1
.
call
(
"
.proc_rpc_dispatch
"
,
"
/proxy
"
,
msgpack
.
dumps
(
input
),
context
)
# Check sending request with `master = false` when there's ony one instance
context
=
make_context
()
input
=
dict
(
service_info
=
(
plugin_name
,
service_name
,
_PLUGIN_VERSION_1
),
path
=
"
/ping
"
,
input
=
"
by-replicaset-id
"
,
replicaset_id
=
i1
.
call
(
"
.proc_instance_info
"
)[
"
replicaset_id
"
],
to_master
=
False
,
)
i1
.
call
(
"
.proc_rpc_dispatch
"
,
"
/proxy
"
,
msgpack
.
dumps
(
input
),
context
)
def
test_sdk_internal
(
cluster
:
Cluster
):
[
i1
]
=
cluster
.
deploy
(
instance_count
=
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment