- Aug 04, 2022
-
-
Vladimir Davydov authored
This commit adds a function that retrieves the number of records stored in a light hash table and makes light users use it instead of accessing the light count directly. This gives us more freedom of refactoring the light internals without modifying the code using it. Needed for #7192 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
prbuf_check, which is called by prbuf_open, proceeds to scanning the buffer even if it's empty. On debug build, this results in prbuf_open reporting that the buffer is corrupted, because we trash the buffer in prbuf_create. On a release build, this may lead to a hang, in case the buffer is zeroed out. Let's fix this by returning success from prbuf_check if the buffer is empty. Note, prbuf_iterator_next doesn't call prbuf_first_record if the buffer is empty, either. Needed for https://github.com/tarantool/tarantool-ee/issues/187 NO_DOC=bug fix NO_CHANGELOG=will be added to EE
-
Alexander Turenko authored
The main decision made in this patch is how large the public `box_decimal_t` type should be. Let's look on some calculations. We're interested in the following values. * How much decimal digits is stored? * Size of an internal decimal type (`sizeof(decimal_t)`). * Size of a buffer to store a string representation of any valid `decimat_t` value. * Largest signed integer type fully represented in decimal_t (number of bits). * Largest unsigned integer type fully represented in decimal_t (number of bits). Now `decimal_t` is defined to store 38 decimal digits. It means the following values: | digits | sizeof | string | int???_t | uint???_t | | ------ | ------ | ------ | -------- | --------- | | 38 | 36 | 52 | 126 | 127 | In fact, decNumber (the library we currently use under the hood) allows to vary the 'decimal digits per unit' parameter, which is 3 by default, so we can choose density of the representation. For example, for given 38 digits the sizeof is 36 by default, but it may vary from 28 to 47 bytes: | digits | sizeof | string | int???_t | uint???_t | | ------ | ---------- | ------ | -------- | --------- | | 38 | 36 (28-47) | 52 | 126 | 127 | If we'll want to store `int128_t` and `uint128_t` ranges, we'll need 39 digits: | digits | sizeof | string | int???_t | uint???_t | | ------ | ---------- | ------ | -------- | --------- | | 39 | 36 (29-48) | 53 | 130 | 129 | If we'll want to store `int256_t` and `uint256_t` ranges: | digits | sizeof | string | int???_t | uint???_t | | ------ | ---------- | ------ | -------- | --------- | | 78 | 62 (48-87) | 92 | 260 | 259 | If we'll want to store `int512_t` and `uint512_t` ranges: | digits | sizeof | string | int???_t | uint???_t | | ------ | ------------ | ------ | -------- | --------- | | 155 | 114 (84-164) | 169 | 515 | 514 | The decision here is what we consdider as possible and what as unlikely. The patch freeze the maximum amount of bytes in `decimal_t` as 64. So we'll able to store 256 bit integers and will NOT able to store 512 bit integers in a future (without the ABI breakage at least). The script, which helps to calculate those tables, is at end of the commit message. Next, how else `box_decimal_*()` library is different from the internal `decimal_*()`? * Added a structure that may hold any decimal value from any current or future tarantool version. * Added `box_decimal_copy()`. * Left `strtodec()` out of scope -- we can add it later. * Left `decimal_str()` out of scope -- it looks dangerous without at least a good explanation when data in the static buffer are invalidated. There is `box_decimal_to_string()` that writes to an explicitly provided buffer. * Added `box_decimal_mp_*()` for encoding to/decoding from msgpack. Unlike `mp_decimal.h` functions, here we always have `box_decimal_t` as the first parameter. * Left `decimal_pack()` out of scope, because a user unlikely wants to serialize a decimal value piece-by-piece. * Exposed `decimal_unpack()` as `box_decimal_mp_decode_data()` to keep a consistent terminogoly around msgpack encoding/decoding. * More detailed API description, grouping by functionality. The script, which helps to calculate sizes around `decimal_t`: ```lua -- See notes in decNumber.h. -- DECOPUN: DECimal Digits Per UNit local function unit_size(DECOPUN) assert(DECOPUN > 0 and DECOPUN < 10) if DECOPUN <= 2 then return 1 elseif DECOPUN <= 4 then return 2 end return 4 end function sizeof_decimal_t(digits, DECOPUN) -- int32_t digits; -- int32_t exponent; -- uint8_t bits; -- <..padding..> -- <..units..> local us = unit_size(DECOPUN) local padding = us - 1 local unit_count = math.ceil(digits / DECOPUN) return 4 + 4 + 1 + padding + us * unit_count end function string_buffer(digits) -- -9.{9...}E+999999999# (# is '\0') -- ^ ^ ^^^^^^^^^^^^ return digits + 14 end function binary_signed(digits) local x = 1 while math.log10(2 ^ (x - 1)) < digits do x = x + 1 end return x - 1 end function binary_unsigned(digits) local x = 1 while math.log10(2 ^ x) < digits do x = x + 1 end return x - 1 end function digits_for_binary_signed(x) return math.ceil(math.log10(2 ^ (x - 1))) end function digits_for_binary_unsigned(x) return math.ceil(math.log10(2 ^ x)) end function summary(digits) print('digits', digits) local sizeof_min = math.huge local sizeof_max = 0 local DECOPUN_sizeof_min local DECOPUN_sizeof_max for DECOPUN = 1, 9 do local sizeof = sizeof_decimal_t(digits, DECOPUN) print('sizeof', sizeof, 'DECOPUN', DECOPUN) if sizeof < sizeof_min then sizeof_min = sizeof DECOPUN_sizeof_min = DECOPUN end if sizeof > sizeof_max then sizeof_max = sizeof DECOPUN_sizeof_max = DECOPUN end end print('sizeof min', sizeof_min, 'DECOPUN', DECOPUN_sizeof_min) print('sizeof max', sizeof_max, 'DECOPUN', DECOPUN_sizeof_max) print('string', string_buffer(digits)) print('int???_t', binary_signed(digits)) print('uint???_t', binary_unsigned(digits)) end ``` Part of #7228 @TarantoolBot document Title: Module API for decimals See the declarations in `src/box/decimal.h` in tarantool sources.
-
- Aug 02, 2022
-
-
Mergen Imeev authored
In most cases, NaN was treated as NULL. But in case NaN was returned as a result of a Lua or C user defined function, it was considered a double. After this patch, NaN will also be considered NULL in the specified cases. Closes #6374 Closes #6572 NO_DOC=bugfix
-
Mergen Imeev authored
This patch makes the is_res_neg flag false in the sql_rem_int() function if the left value is negative and the result is 0. Prior to this patch, the value of the flag was true, which resulted in an assertion during encoding 0 as MP_INT. Closes #6575 NO_DOC=bugfix
-
Mergen Imeev authored
The smallest positive double value is 2.225E-307, and the value before the exponent has a maximum of 15 digits after the decimal point. This means that double values cannot have more than 307 + 15 digits after the decimal point. After this patch, ROUND() will return its first argument unchanged if the first argument is DOUBLE and the second argument is INTEGER greater than 322. Closes #6650 NO_DOC=bugfix
-
- Aug 01, 2022
-
-
Andrey Saranchin authored
The patch introduces opportunity for user to reset slice of current fiber execution. It allows to limit iteration in space with SIGURG. NO_CHANGELOG=see later commits NO_DOC=see later commits
-
Andrey Saranchin authored
Currently, there is no way to interrupt a long execution of a request (such as s:select(nil)). This patch introduces this opportunity. Box will use fiber deadline timeout as a timeout for DML usage. Thus, when deadline of current fiber is up, all DML requests will end with a particular error. Closes #6085 NO_CHANGELOG=see later commits NO_DOC=see later commits
-
Andrey Saranchin authored
Part of #6085 NO_TEST=no behavior changes NO_CHANGELOG=no behavior changes NO_DOC=no behavior changes
-
Andrey Saranchin authored
This patch introduces execution time slice for fiber. Later, we will use this mechanism to limit iteration in space. Part of #6085 NO_CHANGELOG=see later commits NO_DOC=see later commits
-
Alexander Turenko authored
The Rust module [1] leans on several internal symbols. They were open in Tarantool 2.8 (see #2971 and #5932), but never were in the public API. Tarantool 2.10.0 hides the symbols and we need a way to get them back to use in the module. We have the following options: 1. Design and expose a module API for fiber channels. 2. Export the symbols with a prefix like `tnt_internal_` (to don't spoil the global namespace). 3. Provide a `dlsym()` alike function to get an address of an internal symbol for users who knows what they're doing. I think that the third way offers the best compromise between amount of effort, quality of the result and opportunities to extend. In this commit I hardcoded the list of functions to make the change as safe as possible. Later I'll return here to autogenerate the list. Exported the following function from the tarantool executable: ```c void * tnt_internal_symbol(const char *name); ``` I don't add it into the module API headers, because the function is to perform a dark magic and we don't suggest it for users. While I'm here, added `static` to a couple of fiber channel functions, which are only used within the compilation unit. [1]: https://github.com/picodata/tarantool-module Part of #7228 Related to #6372 NO_DOC=don't advertize the dangerous API NO_CHANGELOG=don't advertize the dangerous API
-
- Jul 27, 2022
-
-
Ilya Verbin authored
The valid range for thread_id is [0, iproto_threads_count - 1]. Closes #7196 NO_DOC=bugfix
-
Ilya Verbin authored
Add a missed check to on_replace_dd_truncate, similar to on_replace_dd_space and on_replace_dd_index. Closes #7309 NO_DOC=bugfix
-
Andrey Saranchin authored
The problem is that even if we block all signals on all threads except the main thread, the signals still can be delivered to other threads (#7206). And another problem is that user can spawn his own thread and not block signals. That is why the patch introduces tt_sigaction function that guarantees that all signals will be handled only by the main thread. We use this helper in clock_lowres module. This is supposed to solve the problem, described in #7408. NO_CHANGELOG=internal NO_DOC=internal
-
- Jul 26, 2022
-
-
Alexander Turenko authored
Added a function (see the API in the documentation request below), which reflects the `tuple[json_path]` Lua API (see #1285). Part of #7228 @TarantoolBot document Title: tuple: access a field using JSON path via module API The following function is added into the module API: ```c /** * Return a raw tuple field in the MsgPack format pointed by * a JSON path. * * The JSON path includes the outmost field. For example, "c" in * ["a", ["b", "c"], "d"] can be accessed using "[2][2]" path (if * index_base is 1, as in Lua). If index_base is set to 0, the * same field will be pointed by the "[1][1]" path. * * The first JSON path token may be a field name if the tuple * has associated format with named fields. A field of a nested * map can be accessed in the same way: "foo.bar" or ".foo.bar". * * The return value is valid until the tuple is destroyed, see * box_tuple_ref(). * * Return NULL if the field does not exist or if the JSON path is * malformed or invalid. Multikey JSON path token [*] is treated * as invalid in this context. * * \param tuple a tuple * \param path a JSON path * \param path_len a length of @a path * \param index_base 0 if array element indexes in @a path are * zero-based (like in C) or 1 if they're one-based (like * in Lua) * \retval a pointer to a field data if the field exists or NULL */ API_EXPORT const char * box_tuple_field_by_path(box_tuple_t *tuple, const char *path, uint32_t path_len, int index_base); ```
-
- Jul 25, 2022
-
-
Ilya Verbin authored
In Lua field's numbers are counted from base 1, however currently space:format() and space.foreign_key return zero-based foreign key fields, which leads to an error on space:format(space:format()). Closes #7350 NO_DOC=bugfix
-
Ilya Verbin authored
Currently a foreign_key field in the `format` argument, passed to normalize_format, can be changed inside normalize_foreign_key_one. Fix this by using a local copy of def.field. NO_DOC=bugfix NO_CHANGELOG=minor bug
-
- Jul 21, 2022
-
-
Ilya Verbin authored
It is inconvenient to create self-referencing FK constraints, as the space ID will only be generated during space creation. This is especially useful for SQL, since the format for the space is created at compile time, and the space ID is only obtained at run time. Closes #7200 @TarantoolBot document Title: Describe foreign keys referring to the same space Since: 2.11 Root document: https://www.tarantool.io/en/doc/latest/book/box/data_model/#foreign-keys It is possible to create a foreign key that refers to the same space (a child space equals to the parent space). To do that, omit `space` in the `foreign_key` parameter, or set it to the id or to the name of the current space.
-
Boris Stepanenko authored
According to man 3 exec: "The first argument, by convention, should point to the filename associated with the file being executed.". Using empty string as the first argument while calling `true` program, provided by coreutils led to error message being printed to stderr, which failed the test. This patch passes 'true' as the first argument. Closes #7452. NO_DOC=test NO_CHANGELOG=test
-
Nikita Zheleztsov authored
Currently net.box's methods doesn't check types of passed options. This can lead to Lua's internal errors, which are not self-explaining. Let's add this functionality and raise errors with meaningful messages in case of incorrect options. Closes #6063 Closes #6530 NO_DOC=Not a visible change
-
Nikita Zheleztsov authored
Test is needed to be updated every time net.box's internals are patched (e.g. in case of adding new functions of deleting old ones), as the order of suggested autocomplete options changes. Let's replace `assert_equals` with `assert_items_equals`, which is not order dependent. NO_DOC=test NO_CHANGELOG=test
-
- Jul 19, 2022
-
-
Timur Safin authored
Created simplistic unit test for checking boundary conditions for `datetime_unpack` function. NO_DOC=internal NO_CHANGELOG=internal
-
Timur Safin authored
Introduced fuzzing testing for datetime decoder. NO_DOC=internal NO_CHANGELOG=internal
-
Timur Safin authored
NO_DOC=refactoring NO_CHANGELOG=refactoring
-
Rianov Viacheslav authored
This patch fixes the ctrl+c behavior in multiline mode. The old behavior was ignoring sigint in this mode. The new behavior is quitting this mode and printing the new default prompt. Added a new test for covering the mentioned case. Follows up #2717 Closes #7109 NO_DOC=BUGFIX
-
- Jul 15, 2022
-
-
Vladimir Davydov authored
This commit replaces enter/leave_delayed_free_mode() MemtxAllocator methods with open/close_read_view(). The open_read_view() method returns a pointer to the new read view, which is supposed to be pssed to close_read_view() when the read view is no longer needed. The new API will allow us to optimize garbage collection, see #7185. Currently, open_read_view() always returns nullptr and both ReadView and memtx_read_view_opts are empty structs. We will extend them in the future. Closes #7364 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Vladimir Davydov authored
Checking #7185 with functional tests is complicated. Let's add a unit test for this. Needed for #7185 NO_DOC=test NO_CHANGELOG=test
-
- Jul 14, 2022
-
-
Nikolay Shirokovskiy authored
Now we can make interactive transactions like in case of local or txt remote consoles if peer supports streams. Closes #7413 NO_DOC=minor change
-
Nikolay Shirokovskiy authored
The issue is if in binary remote console a error is thrown in expression like "box.begin() error('something') box.commit()" then it is overwritten by iproto check for active transactions at the end of eval. The solution is to rollback active transaction in this case in console code before iproto check. Let's also assert in tests a behaviour that after successful transaction begin it stays active in next evaluations (successful or not) until explicit rollback. Closes #7288 NO_DOC=minor change
-
Nikolay Shirokovskiy authored
Starting server is failed after chdir(3) for example if we call box.cfg{} with work_dir set. NO_DOC=fix testing harness NO_TEST=fix testing harness NO_CHANGELOG=fix testing harness
-
Nikolay Shirokovskiy authored
We keep per server directories there too, not only socket files. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
Nikolay Shirokovskiy authored
The ; separator was missed after select (check the first hunk) and as a result the rollback was not executed. So the next test was failed merely due to the unfinished transaction of the previous test. We also need to fix the third test to use a different tuple. Also fix a couple of comments. NO_DOC=test fix NO_TEST=test fix NO_CHANGELOG=test fix
-
Ilya Verbin authored
If MP_ERROR contains an error message with invalid UTF-8 sequences, encode it in Base64 to obtain printable string. Closes #6781 Closes #6934 NO_DOC=bugfix
-
Serge Petrenko authored
The upgrade script first tries to determine if the node is booted from old snaps not recoverable on current Tarantool versions. If this is the case, it sets up special triggers so that snaps are automatically converted to a suitable format. This happens before box.cfg{}, so the workdir is not set at this point in time, and the upgrade script should take configured work_dir into account explicitly. Fix this. Closes #7232 NO_DOC=bugfix
-
- Jul 12, 2022
-
-
Mergen Imeev authored
Prior to this patch, some opcodes could use a pointer to struct space that was set during parsing. However, the pointer to struct space is not really something that defines spaces. A space can be identified by its ID or name. In most cases, specifying space by pointer works fine, but truncate() changes the pointer to space, resulting in a sigfault for prepared statements using the above opcodes. To avoid this problem, a new opcode has been introduced. This opcode uses the space ID to determine the pointer to the struct space at runtime and stores it in the MEM, which is later used in the mentioned opcodes. Closes #7358 NO_DOC=bugfix
-
Vladimir Davydov authored
Functional index keys are allocated and freed with MemtxAllocator's alloc and free methods. In contrast to tuples, which are allocated and freed with alloc_tuple and free_tuple, freeing a functional index key happens immediately, irrespective of whether there's a snapshot in progress or not. It's acceptable, because snapshot only uses primary indexes, which can't be functional. However, to reuse the snapshot infrastructure for creating general purpose user read views, we will need to guarantee that functional index keys stay alive until all read views using them are closed. To achieve that, this commit turns functional index keys into tuples, which automatically makes them linger if there's an open read view. We use the same global tuple format for allocating functional keys, because the key format is checked in key_list_iterator_next. Closes #7376 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
-
- Jul 11, 2022
-
-
Ilya Verbin authored
Currently the latch doesn't guarantee the order in which it is acquired by fibers, which requested it. E.g. it is possible to wake up spuriously a fiber which is yielding in the latch_lock, it will be removed from l->queue by fiber_make_ready, then it will be inserted to l->queue again, but for this time, to the head of the list instead of its original place in the queue. Fix this by using latch_waiter structure, which is linked into l->queue. Part of #7166 @TarantoolBot document Title: Update box_latch_lock description Since: 2.11 Add "Locks are acquired in the strict order as they were requested." to the box_latch_lock description in C API reference - Module latch.
-
- Jul 08, 2022
-
-
Yaroslav Lobankov authored
This patch fixes the following error while tarantool build on FreeBSD 13.1: [100%] Linking CXX executable watcher.test ld: error: undefined symbol: set_sigint_cb >>> referenced by console.c:261 (lua/console.c:261) >>> console.c.o:(lbox_console_readline) in archive ../../src/box/libbox.a >>> referenced by console.c:342 (lua/console.c:342) >>> console.c.o:(lbox_console_readline) in archive ../../src/box/libbox.a >>> referenced by console.c:352 (lua/console.c:352) >>> console.c.o:(lbox_console_readline) in archive ../../src/box/libbox.a >>> referenced 1 more times c++: error: linker command failed with exit code 1 (use -v to see invocation) gmake[2]: *** [test/unit/CMakeFiles/watcher.test.dir/build.make:152: test/unit/watcher.test] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:10528: test/unit/CMakeFiles/watcher.test.dir/all] Error 2 gmake: *** [Makefile:156: all] Error 2 NO_DOC=minor changes NO_TEST=minor changes NO_CHANGELOG=minor changes
-
Vladimir Davydov authored
The gh_6565 test doesn't stop the hot standby replica it started, because the replica should fail to initialize and exit eventually anyway. However, if the replica lingers until the next test due to https://github.com/tarantool/test-run/issues/345, the next test may successfully connect to it, which is likely to lead to a failure, because UNIX socket paths used by luatest servers are not randomized. For example, here gh_6568 test fails after gh_6565, because it uses the same alias for the test instance ('replica'): NO_WRAP [008] vinyl-luatest/gh_6565_hot_standby_unsupported_> [ pass ] [008] vinyl-luatest/gh_6568_replica_initial_join_rem> [ fail ] [008] Test failed! Output from reject file /tmp/t/rejects/vinyl-luatest/gh_6568_replica_initial_join_removal_of_compacted_run_files.reject: [008] TAP version 13 [008] 1..1 [008] # Started on Fri Jul 8 15:30:47 2022 [008] # Starting group: gh-6568-replica-initial-join-removal-of-compacted-run-files [008] not ok 1 gh-6568-replica-initial-join-removal-of-compacted-run-files.test_replication_compaction_cleanup [008] # builtin/fio.lua:242: fio.pathjoin(): undefined path part 1 [008] # stack traceback: [008] # builtin/fio.lua:242: in function 'pathjoin' [008] # ...ica_initial_join_removal_of_compacted_run_files_test.lua:43: in function 'gh-6568-replica-initial-join-removal-of-compacted-run-files.test_replication_compaction_cleanup' [008] # ... [008] # [C]: in function 'xpcall' [008] replica | 2022-07-08 15:30:48.311 [832856] main/103/default.lua F> can't initialize storage: unlink, called on fd 30, aka unix/:(socket), peer of unix/:(socket): Address already in use [008] # Ran 1 tests in 0.722 seconds, 0 succeeded, 1 errored NO_WRAP Let's fix this by explicitly killing the hot standby replica. Since it could have exited voluntarily, we need to use pcall, because server.stop fails if the instance is already dead. This issue is similar to the one fixed by commit 85040161 ("test: stop server started by vinyl-luatest/update_optimize test"). NO_DOC=test NO_CHANGELOG=test
-
Nikolay Shirokovskiy authored
Handle status header response like 'HTTP/2 200' with version without dot. Closes #7319 NO_DOC=bugfix
-