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

map_callrw can't find c stored procedure #436

Closed
vol0n opened this issue Sep 6, 2023 · 4 comments · Fixed by #437
Closed

map_callrw can't find c stored procedure #436

vol0n opened this issue Sep 6, 2023 · 4 comments · Fixed by #437
Assignees
Labels
bug Something isn't working storage

Comments

@vol0n
Copy link

vol0n commented Sep 6, 2023

Problem

We have a c stored procedure execute, earlier we called it via replicaset api like this:

replica:callbre(
                'execute',
                args,
                { is_async = true }
)

Now we've started to use map_callrw router api, which gives us an error saying it is not defined:

router.map_callrw('execute', args)

---
- null
- code: 33
  base_type: ClientError
  type: ClientError
  message: Procedure 'execute' is not defined
  trace: [{'file': './src/box/lua/call.c', 'line': 112}]
- 5bb12a3c-4de8-4059-8172-8c926d6a6bc2
...

The function was created like this:

box.schema.func.create(
            'execute',
            { if_not_exists = true, language = 'C' }
        )

And it is callable through box.func api:

box.func['execute']:call()
---
- error: 'Failed to decode dispatched data: Invalid(Tuple, Some("expected
    tuple of 2 elements, got 0"))'
...

Tarantool version: 2.11.0
Vshard version: latest

Hint

After digging a bit in the code I found that map_callrw(f, args) calls storage_map(f, args), the latter calls net.box.self.call(f, args) and this internally in tarantool calls box_lua_find which tries to find the function in lua globals.

On the other hand, replica:callbre(f, args) calls net.box.conn.call, the latter first checks whether the function is in cache and only then uses box_lua_find.

So the problem seems to be in using self.call inside storage_map

@Serpentian
Copy link
Contributor

Thank you for digging! The issue is blocked by tarantool/tarantool#9131

@Serpentian Serpentian self-assigned this Sep 12, 2023
@Serpentian Serpentian added the blocked Not ready to be implemented label Sep 12, 2023
@Gerold103
Copy link
Collaborator

Can we just always use box.func? netbox.self is used because in the old times it was the only way to call a local function without requiring its Lua or C module.

@Serpentian
Copy link
Contributor

Sure, we can. But it doesn't change the fact, that netbox.self doesn't work.

@Gerold103
Copy link
Collaborator

It does mean that the ticket is not blocked though. I suggest we drop the 'blocked' label.

@Gerold103 Gerold103 removed the blocked Not ready to be implemented label Sep 14, 2023
Serpentian added a commit to Serpentian/vshard that referenced this issue Sep 18, 2023
Currently, if function was created as C stored procedure with
box.schema.func.create, all types of router.call and router.map_callrw
cannot find it and return `Procedure 'name' is not defined` error.
This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call, which doesn't currently work with
C stored procedures due to the bug.

Let's use box.func, where it's possible instead of net_box.self.call
in local_call.

Closes tarantool#436

NO_DOC=bugfix
NO_TEST=<already tested>
Serpentian added a commit to Serpentian/vshard that referenced this issue Sep 18, 2023
Currently, if function was created as C stored procedure with
box.schema.func.create, all types of router.call and router.map_callrw
cannot find it and return `Procedure 'name' is not defined` error.
This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call, which doesn't currently work with
C stored procedures due to the bug.

Let's use box.func, where it's possible instead of net_box.self.call
in local_call.

Closes tarantool#436

NO_DOC=bugfix
NO_TEST=<already tested>
Serpentian added a commit to Serpentian/vshard that referenced this issue Sep 25, 2023
Currently, if function was created as C stored procedure with
box.schema.func.create, all types of router.call and router.map_callrw
cannot find it and return `Procedure 'name' is not defined` error.
This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call, which doesn't currently work with
C stored procedures due to the bug.

Let's use box.func, where it's possible instead of net_box.self.call
in local_call.

Closes tarantool#436

NO_DOC=bugfix
NO_TEST=<already tested>
Serpentian added a commit to Serpentian/vshard that referenced this issue Nov 21, 2023
Currently, if function was created as C stored procedure or as Lua
persistent function (with body argument) via box.schema.func.create,
all types of router.call and router.map_callrw cannot find it and
return `Procedure 'name' is not defined` error.

This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call, which doesn't currently work with
C stored procedures due to the bug. Let's use box.func, where it's
possible instead of net_box.self.call in local_call.

Closes tarantool#436

NO_DOC=bugfix
Serpentian added a commit to Serpentian/vshard that referenced this issue Nov 28, 2023
Currently, if function was created as C stored procedure or as Lua
persistent function (with body argument) via box.schema.func.create,
all types of router.call and router.map_callrw cannot find it and
return `Procedure 'name' is not defined` error.

This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call. It didn't work with these type of
functions before Tarantool 3.0.0-beta1-18. Let's use box.func, where
it's needed instead of net_box.self.call in local_call.

Closes tarantool#436

NO_DOC=bugfix
Gerold103 pushed a commit that referenced this issue Dec 6, 2023
Currently, if function was created as C stored procedure or as Lua
persistent function (with body argument) via box.schema.func.create,
all types of router.call and router.map_callrw cannot find it and
return `Procedure 'name' is not defined` error.

This is cased by the fact that both of these function use local_call,
which invokes net_box.self.call. It didn't work with these type of
functions before Tarantool 3.0.0-beta1-18. Let's use box.func, where
it's needed instead of net_box.self.call in local_call.

Closes #436

NO_DOC=bugfix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working storage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants