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

It seems that crud is doing two selects in one crud.get #413

Open
hackallcode opened this issue Jan 10, 2024 · 3 comments
Open

It seems that crud is doing two selects in one crud.get #413

hackallcode opened this issue Jan 10, 2024 · 3 comments

Comments

@hackallcode
Copy link

I call crud.get via go-tarantool using the primary key in this way:
client.Do(crud.MakeGetRequest("users").Key([]any{reqUser.Token}), pool.ANY)

As a result, I look at the tnt_stats_op_total metric and see that one call and two selects are made on storage, which is strange. It seems that there should be one select, since this is a point query based on the primary key

@DifferentialOrange
Copy link
Member

Original issue screenshots:
image
image

@DifferentialOrange
Copy link
Member

DifferentialOrange commented Jan 11, 2024

Initial thoughts based on ./doc/playground.lua: it's not clear whether crud or not is the reason.

  1. You can get +2 SELECTs on a single crud.get.
  2. You can get +1 SELECTs on a single crud.get.
  3. You can get +N SELECTs if you wait for a several seconds on a crud cluster (without running any data operations).
  4. You can get +2 SELECTs on a single vshard space:get call.
  5. You can get +N SELECTs if you wait for a several seconds on a vshard cluster (without running any data operations).

See examples below.
Beware that playground instance is a router and a storage at the same time, it also may affect the experiment.

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
257
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
259
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
260
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
261
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
262
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
263
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
264
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
265
---
...

tarantool> crud.get('customers', 1); print(box.stat()['SELECT']['total'])
266
---
...

tarantool> print(box.stat()['SELECT']['total'])
268
---
...

If CRUD not configured.

diff --git a/doc/playground.lua b/doc/playground.lua
index d4e547f..e42720b 100755
--- a/doc/playground.lua
+++ b/doc/playground.lua
@@ -146,8 +146,8 @@ box.once('developers', function()
 end)
 
 -- Initialize crud.
-crud.init_storage()
-crud.init_router()
+-- crud.init_storage()
+-- crud.init_router()
 
 -- Start a console.
 console.start()
tarantool> vshard.router.callrw(1, 'box.space.customers:get', {1}); print(box.stat()['SELECT']['total'])
185
---
...

tarantool> vshard.router.callrw(1, 'box.space.customers:get', {1}); print(box.stat()['SELECT']['total'])
188
---
...

tarantool> vshard.router.callrw(1, 'box.space.customers:get', {1}); print(box.stat()['SELECT']['total'])
190
---
...

tarantool> vshard.router.callrw(1, 'box.space.customers:get', {1}); print(box.stat()['SELECT']['total'])
192
---
...

tarantool> vshard.router.callrw(1, 'box.space.customers:get', {1}); print(box.stat()['SELECT']['total'])
194
---
...

@hackallcode
Copy link
Author

I noticed that for each crud replace in the metrics on the master, 1 select and 1 replace are added. It seems that this is the same select as in the get request.

I use the same query:

crud.MakeReplaceObjectRequest("users").Object(crud.MapObject{
    "token":   uuid.NewString(),
    "user_id": uuid.NewString(),
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants