Commit 5fe44d8
committed
box: implement Lua call/eval over iproto for application threads
This commit lets a network client specify a thread id to forward
a call/eval request to. To achieve that, we have to initialize
a minimal Lua state in each application threads. We do that by making
the tarantool_L global variable thread-local and factoring out
tarantool_lua_init_minimal() from tarantool_lua_init() for use in
application threads. The minimal initialization includes setting
ctype ids for all our custom Lua types, such as decimal and datetime,
because we need them for MsgPack serialization. These ctype ids are
made thread-local as well. The only exception is tuple because
tuple formats can't be used in any thread except tx. We explicitly
override the tuple decoder to return a plain table instead of a tuple
object if used in a non-tx thread, see luamp_decode_extension_box().
To safely use the box Lua call/eval infrastructure in any thread,
we have to fix a few things:
1. execute_lua_refs and call_serializer_no_ext have to be made
thread-local because they depend on the Lua state.
2. Apart from setting execute_lua_refs and call_serializer_no_ext,
box_lua_call_init() registers an internal box library and sets
a trigger on alter of the _func system space. Apparently, we can't
do that in application threads.
3. get_call_serializer() uses current_session(), which creates a new
session object if the current fiber doesn't have a session. Sessions
aren't thread-safe and we don't set them for fibers running in
application threads so we switch to fiber_get_session(). We also
add an explicit check that this is an IPROTO session because for
other sessions IPROTO feature bits are undefined. The latter is
merely for code clarity because Lua call/eval are executed only
from IPROTO.
This commit completes the core part of the application threads
infrastructure.
Closes #12259
NO_DOC=internal
NO_CHANGELOG=internal1 parent 4cf2b86 commit 5fe44d8
File tree
23 files changed
+402
-91
lines changed- src
- box
- lua
- lua
- test/box-luatest
23 files changed
+402
-91
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| 36 | + | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| |||
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
35 | 50 | | |
36 | 51 | | |
37 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
180 | | - | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| |||
1940 | 1941 | | |
1941 | 1942 | | |
1942 | 1943 | | |
1943 | | - | |
| 1944 | + | |
| 1945 | + | |
1944 | 1946 | | |
1945 | 1947 | | |
1946 | 1948 | | |
| |||
1990 | 1992 | | |
1991 | 1993 | | |
1992 | 1994 | | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
1993 | 1998 | | |
1994 | 1999 | | |
1995 | 2000 | | |
| |||
2054 | 2059 | | |
2055 | 2060 | | |
2056 | 2061 | | |
2057 | | - | |
| 2062 | + | |
2058 | 2063 | | |
2059 | 2064 | | |
2060 | 2065 | | |
| |||
2772 | 2777 | | |
2773 | 2778 | | |
2774 | 2779 | | |
2775 | | - | |
| 2780 | + | |
2776 | 2781 | | |
2777 | 2782 | | |
2778 | 2783 | | |
| |||
2810 | 2815 | | |
2811 | 2816 | | |
2812 | 2817 | | |
2813 | | - | |
| 2818 | + | |
2814 | 2819 | | |
2815 | 2820 | | |
2816 | 2821 | | |
| |||
2885 | 2890 | | |
2886 | 2891 | | |
2887 | 2892 | | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
2888 | 2947 | | |
2889 | 2948 | | |
2890 | 2949 | | |
| |||
3879 | 3938 | | |
3880 | 3939 | | |
3881 | 3940 | | |
3882 | | - | |
3883 | | - | |
3884 | 3941 | | |
3885 | 3942 | | |
3886 | 3943 | | |
| |||
3897 | 3954 | | |
3898 | 3955 | | |
3899 | 3956 | | |
3900 | | - | |
3901 | 3957 | | |
3902 | 3958 | | |
3903 | 3959 | | |
3904 | 3960 | | |
3905 | 3961 | | |
3906 | | - | |
3907 | | - | |
3908 | | - | |
3909 | 3962 | | |
3910 | | - | |
3911 | | - | |
3912 | | - | |
3913 | | - | |
3914 | | - | |
3915 | | - | |
3916 | | - | |
3917 | 3963 | | |
3918 | 3964 | | |
3919 | 3965 | | |
3920 | 3966 | | |
3921 | 3967 | | |
3922 | 3968 | | |
3923 | 3969 | | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
| 3977 | + | |
3924 | 3978 | | |
3925 | 3979 | | |
3926 | 3980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments