Skip to content
Snippets Groups Projects
  1. Aug 16, 2022
    • Ilya Verbin's avatar
      cmake: detect changes in source files upon static build · a1f554bd
      Ilya Verbin authored
      Currently `make` in `static-build` doesn't rebuild Tarantool when source
      files are changed. Fix this by setting BUILD_ALWAYS option, which forces
      rescan for changes of the external project [1]:
      
      > This option is not normally needed unless developers are expected to
      > modify something the external project's build depends on in a way that
      > is not detectable via the step target dependencies (e.g. SOURCE_DIR is
      > used without a download method and developers might modify the sources
      > in SOURCE_DIR).
      
      It is available since CMake 3.1, so update cmake_minimum_required, as we
      already require it (fa8d70ca).
      
      [1] https://cmake.org/cmake/help/latest/module/ExternalProject.html
      
      Part of #7536
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=minor
      a1f554bd
  2. Aug 15, 2022
  3. Aug 12, 2022
    • Yaroslav Lobankov's avatar
      ci: add workaround for LuaJIT profiling tests · 5f8cbfff
      Yaroslav Lobankov authored
      This patch adds a temporary workaround for LuaJIT profiling tests to
      avoid runners shutdown due to no space left on the disk. The profiling
      tests may produce profiles until fully fill up the runner [1].
      
      The workaround is based on implementing disk quotas.
      
      In two words, it creates a 1GB file (disk image), formats this file as
      an ext4 filesystem, mounts this filesystem to some mount pont and sets
      `LUAJIT_TEST_VARDIR=<mount point>`. In this case LuaJIT tests will use
      this dir for storing various test data/profiles and not be able to fill
      up the runner.
      
      [1] https://github.com/tarantool/tarantool/issues/7472
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      5f8cbfff
  4. Aug 11, 2022
    • Vladimir Davydov's avatar
      index: refactor snapshot iterator API · 7572b5c6
      Vladimir Davydov authored
      To make a memtx snapshot, we use the create_snapshot_iterator index
      method. The method creates a 'frozen' iterator over an index - changes
      done to the index after the iterator was created don't affect the
      iterator output. Also, the iterator is safe to use from any thread.
      This API works just fine for snapshots, but it's too limited to allow
      creation of user read views so we need to rework it.
      
      To make the existing snapshot infrastructure suitable for user read
      views, this commit replaces the create_snapshot_iterator method with
      create_read_view. The new method returns an index_read_view object,
      which has the API similar to the read-only API of an index. A read view
      object may only be created and destroyed in the tx thread, but it may be
      used in any thread.
      
      Currently, index_read_view has the only method - create_iterator, which
      takes iterator type and key and returns an index_read_view_iterator
      object. The iterator type and key arguments are ignored and we always
      assume the iterator type to be ITER_ALL (asserted), but later on we will
      fix this and also add a method to look up a tuple by key.
      
      Closes #7194
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      7572b5c6
    • Vladimir Davydov's avatar
      sequence: get rid of sequence_data_iterator::tuple · f1e7a91d
      Vladimir Davydov authored
      Since commit f167c1af ("memtx: decompress tuples in snapshot
      iterator") a snapshot iterator may allocate the result tuple on the
      fiber region - the caller is supposed to clean the region after usage.
      So we don't need to store the tuple in sequence_data_iterator anymore -
      we can allocate it on the fiber region instead, which is simpler and
      more straightforward.
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      f1e7a91d
    • Vladimir Davydov's avatar
      vinyl: drop vinyl_index_create_snapshot_iterator · 4e277eb5
      Vladimir Davydov authored
      The create_snapshot_iterator index callback is used by the memtx engine
      to create a consistent read view of data stored in memtx so that it can
      be written to a snapshot or sent to a remote replica. We also define and
      use this callback internally in vinyl to implement initial join.
      
      Actually, there's no need to have this code wrapped in a callback in
      vinyl, because it's never called from outside the vinyl internals. Let's
      inline it and drop the callback for vinyl. This will simplify further
      refactoring of the internal index read view API.
      
      Needed for #7194
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      4e277eb5
    • Vladimir Davydov's avatar
      index: rename get_raw to get_internal · a7722dad
      Vladimir Davydov authored
      'get_raw' is a misleading name, because usually we append the '_raw'
      suffix to functions that work with raw MsgPack while 'get_raw' actually
      returns a formatted tuple. The function is used internally in memtx to
      implement tuple compression. Let's call it 'get_internal' to emphasize
      that.
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      a7722dad
    • Boris Stepanenko's avatar
      raft: add strict fencing · 64ae9a08
      Boris Stepanenko authored
      With current leader fencing implementation old leader doesn't resign
      it's leadership before new leader may be elected. Because of this
      several "leaders" might coexist in replicaset for some time.
      
      This commit changes replication_disconnect_timeout that it is twice
      as short for current raft leader (2*replication_timeout) if strict
      fencing is enabled. Assuming that replication_timeout is the same for
      every replica in replicaset this makes it less probable that new
      leader can be elected before old one resigns it's leadership.
      
      Old fencing behaviour can be enabled by setting fencing to soft mode.
      This is useful when connection death timeouts shouldn't be affected
      (e.g. different replication_timeouts are set to prioritize some
      replicas as leader over the others).
      
      Closes #7110
      
      @TarantoolBot document
      Title: Strict fencing
      
      In `box.cfg` option `election_fencing_enabled` is deprecated in favor
      of `election_fencing_mode`. `election_fencing_mode` can be set to one
      of the following values:
      'off' - fencing turned off (same as `election_fencing_enabled` set to
      false before).
      Connection death timeout is 4*replication_timeout for all nodes.
      
      'soft' (default) - fencing turned on, but connection death timeout is
      the same for leader and followers in replicaset. This is enough to
      solve cluster being readonly and not being to elect a new leader in
      some situations because of pre-vote.
      Connection death timeout is 4*replication_timeout for all nodes.
      
      'strict' - fencing turned on. In this mode leader tries its best to
      resign leadership before new leader can be elected. This is achived
      by halving death timeout on leader.
      Connection death timeout is 4*replication_timeout for followers and
      2*replication_timout for current leader.
      64ae9a08
    • Boris Stepanenko's avatar
      raft: return NULL from box_raft when raft isn't initialized · 0da98773
      Boris Stepanenko authored
      Currently box_raft asserts that raft is initialized when it is called.
      For strict fencing box_raft will be called in
      replication_disconnect_timeout to set different timeouts for leader and
      follower. Sometimes replication_disconnect_timeout is called before raft
      is initialized.
      
      This commit changes box_raft behaviour, removing the assertion and
      returning NULL instead of pointer to global raft state, if raft isn't
      initialized. This makes it possible to call box_raft even before raft
      has been initialized, checking that return value isn't NULL.
      
      Assuming that this assertion didn't trigger anywhere
      else, there is no need to check for box_raft returning NULL anywhere
      except new calls. Even if in future this will change it will trigger
      segmentation fault and the problem could be easily localized.
      
      Part of #7110
      
      NO_DOC=internal changes
      NO_TEST=internal changes
      NO_CHANGELOG=internal changes
      0da98773
    • Boris Stepanenko's avatar
      luatest_helpers: add replication proxy · b907e726
      Boris Stepanenko authored
      Before, we used to modify box.cfg.replication to reproduce network
      problems in our test. This worked fine in most situations, but doesn't
      work in others: when instance gets disconnected by modifying
      box.cfg.replication, it closes its connection immediately (in terms of
      realtime), and this is noticed almost immediately by its neighbours in
      replica set (because they receive EOF). This made it impossible to test
      some things, that rely on specific timeouts in our code (e.g. strict
      fencing).
      
      This commits adds helper, which acts as UNIX socket proxy, and can block
      connection transparently for tarantool instances. It makes it possible
      to write some tests, that were not possible before. It is also possible
      to inject arbitrary packets between instance, which are interconnected
      via proxy.
      
      Usage:
      
                        +-------------------+
                        |tarantool server 1 |
                        +-------------------+
                                  |
                                  |
                                  |
                         .-----------------.
                        (   /tmp/test-out   )
                         `-----------------'
                                  |
                                  |
                                  |
                        +-------------------+
                        |       proxy       |
                        +-------------------+
                                  |
                                  |
                                  |
                         .-----------------.
                +-------(   /tmp/test-in    )--------+
                |        `-----------------'         |
                |                                    |
                |                                    |
                |                                    |
      +-------------------+                +-------------------+
      |tarantool server 2 |                |tarantool server 3 |
      +-------------------+                +-------------------+
      
      tarantool server 1 init.lua:
      box.cfg{listen = '/tmp/test-out'}
      box.once("schema", function()
          box.schema.user.grant('guest', 'super')
      end)
      
      tarantool server 2 and tarantool server 3 init.lua:
      box.cfg{replication = '/tmp/test-in'}
      
      proxy init.lua:
      -- Import proxy helper
      Proxy = require('test.luatest_helpers.proxy.proxy')
      
      -- Create proxy, which will (when started) listen on client_socket_path
      -- and accept connection when client tries to connect. The accepted
      -- socket connection is then passed to new Connection instance.
      proxy = Proxy:new({
          -- Path to UNIX socket, where proxy will await new connections.
          client_socket_path = '/tmp/test-in',
      
          -- Path to UNIX socket where tarantool server is listening.
          server_socket_path = '/tmp/test-out',
      
          -- Table, describing how to process client socket. Optional.
          -- Defaults used and described:
          process_client = {
              -- function(connection) which, if not nil, will be called once
              -- before client socket processing loop.
              pre = nil,
      
              -- function(connection, data) which, if not nil, will be called
              -- in loop, when new data is received from client socket.
              -- Connection.forward_to_server(connection, data) will:
              -- 1) Connect server socket to server_socket_path, if server
              --    socket is not connected.
              -- 2) Write data to server socket, if connected and writable.
              func = Connection.forward_to_server,
      
              -- function(connection) which, if not nil, will be called once
              -- after client socket processing loop.
              -- Connection.close_client_socket(connection) will shutdown and
              -- close client socket, if it is connected.
              post = Connection.close_client_socket,
          },
      
          -- Table, describing how to process server socket. Optional.
          -- Defaults used and described:
          process_server = {
              -- function(connection) which, if not nil, will be called once
              -- before server socket processing loop.
              pre = nil,
      
              -- function(connection, data) which, if not nil, will be called
              -- in loop, when new data is received from server socket.
              -- Connection.forward_to_client(connection, data) will write data
              -- to client socket, if it is connected and writable
              func = Connection.forward_to_client,
      
              -- function(connection) which, if not nil, will be called once
              -- after server socket processing loop.
              -- Connection.close_server_socket(connection) will shutdown and
              -- close server socket, if it is connected.
              post = Connection.close_server_socket,
          }
      
      })
      
      -- Bind client socket (defined by proxy.client_socket_path) and start
      -- accepting connections on it in a new fiber. If opts.force is set to
      -- true, it will remove proxy.client_socket_path file before binding to
      -- it. After proxy is started it will accept client connections and
      -- create Connection instance for each connection.
      proxy:start({force = false})
      
      -- Stop accepting new connetions on client socket and join the fiber,
      -- created by proxy:start(), and close client socket. Also stop all
      -- active connections (see Connection:stop()).
      proxy:stop()
      
      -- Pause accepting new connections and pause all active connections (see
      -- Connection:pause()).
      proxy:pause()
      
      -- Resume accepting new connections and resume all paused connections
      -- (see Connection:resume())
      proxy:resume()
      
      -- Connection class:
      Connection:new({
          {
              -- Socket which is already created (by Proxy class for example).
              -- Optional, may be nil.
              client_socket = '?table',
      
              -- Path to connect server socket to. Will try to connect on
              -- initialization, and in Connection.forward_to_server.
              -- Can connect manually by calling
              -- Connection:connect_server_socket().
              server_socket_path = 'string',
      
              -- See Proxy:new()
              process_client = '?table',
      
                -- See Proxy:new()
              process_server = '?table',
          },
      })
      
      -- Start processing client socket, using functions from
      -- Connection:process_client.
      Connection:start()
      
      -- Connect server socket to Connection.server_socket_path (if not
      -- connected already). Start processing server socket, if successfully
      -- connected (using functions from Connection.process_server).
      Connection:connect_server_socket()
      
      -- Pause processing packets (both incoming from client socket and server
      -- socket).
      Connection:pause()
      
      -- Resume processing packets (both incoming from client socket and
      -- server socket).
      Connection:resume()
      
      -- Close server socket, if open.
      Connection:close_server_socket()
      
      -- Close client socket, if open.
      Connection:close_client_socket()
      
      -- Close client and server sockets, if open, and wait for processing
      -- fibers to die.
      Connection:stop()
      
      NO_DOC=test helpers
      NO_CHANGELOG=test helpers
      b907e726
  5. Aug 10, 2022
    • Anna Balaeva's avatar
      ci: VK Teams instead of Telegram for notifications · f2d23b4e
      Anna Balaeva authored
      This patch introduces the new `report-job-status` action that is used
      for sending notifications to the VK Teams messenger on the job failure.
      It replaces the old `send-telegram-notify` action sending similar text
      notifications to the Telegram messenger.
      
      The new action selects the corresponding chat for the notification on
      failure and uses the `tarantool/actions/report-job-status` action [1]
      for sending it to:
      
      * the team chat (Tarantool CI/CD reports) - if the job started on any
        event in the master or release branch (1.10, 2.10, etc);
      
      * a personal chat (created by the committer) – if the job started on
        creating/updating a pull request or any event in other branches.
      
      [1] https://github.com/tarantool/actions/tree/master/report-job-status
      
      Resolves tarantool/tarantool-qa#258
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      f2d23b4e
    • Sergey Bronnikov's avatar
      ci: fix workflow with publishing doxygen documentation · f8208a5f
      Sergey Bronnikov authored
      - Fix checkout with submodules
      - Fix publish action version
      
      NO_CHANGELOG=ci
      NO_DOC=ci
      NO_TEST=ci
      f8208a5f
  6. Aug 09, 2022
    • Gleb Kashkin's avatar
      console: fix -i being overruled by !isatty() · 9965e3fe
      Gleb Kashkin authored
      The interactive mode has been ignored when stdin was not a tty and is no
      more. Now results of another command can be handled by tarantool.
      Before the patch:
      ```
      $ echo 42 | tarantool -i
      LuajitError: stdin:1: unexpected symbol near '42'
      fatal error, exiting the event loop
      ```
      
      After the patch:
      ```
      $ echo 42 | tarantool -i
      Tarantool 2.5.0-130-ge3cf64a6c
      type 'help' for interactive help
      tarantool> 42
      ---
      - 42
      ...
      
      ```
      
      Closes #5064
      
      NO_DOC=bugfix
      9965e3fe
    • Gleb Kashkin's avatar
      test: fix reading STDIN command on openSUSE · ea07854e
      Gleb Kashkin authored
      Inspired by gh-5064, that breaks the previous version of the test on
      openSUSE. When using `io.popen:write()` on tarantool with `-i` flag, it
      failed to run the command on openSUSE. This happened because before
      gh-5064 patch it used to employ `luaL_loadfile()` that interprets EOF
      as the end of the command, while when it is loaded as a string openSUSE
      expects it to end with '\n'.
      
      Needed for #5064
      NO_DOC=test fix
      NO_TEST=test fix
      NO_CHANGELOG=test fix
      ea07854e
    • Sergey Bronnikov's avatar
      doc: publish autogenerated module api documentation · f064175e
      Sergey Bronnikov authored
      NO_DOC=internal
      NO_TEST=internal
      f064175e
    • Sergey Bronnikov's avatar
      doxygen: comment out a setting with path to logo · ef434db5
      Sergey Bronnikov authored
      NO_CHANGELOG=Update doxygen config
      NO_DOC=Update doxygen config
      NO_TEST=Update doxygen config
      ef434db5
    • Alexander Turenko's avatar
      feedback: hide from box.cfg if disabled at build · 51a9cef3
      Alexander Turenko authored
      It is counter-intuitive to see options of a component that is disabled
      at build time. Especially, when the returned value means that the
      component is enabled (while it is not so).
      
      Before this patch (on `-DENABLE_FEEDBACK_DAEMON=OFF` build):
      
      ```yaml
      tarantool> box.cfg()
      tarantool> box.cfg.feedback_enabled
      ---
      - true
      ...
      ```
      
      After this patch (on `-DENABLE_FEEDBACK_DAEMON=OFF` build):
      
      ```yaml
      tarantool> box.cfg()
      tarantool> box.cfg.feedback_enabled
      ---
      - null
      ...
      ```
      
      NB: The following test cases in cartridge are failed with
      `-DENABLE_FEEDBACK_DAEMON=OFF` (as before as well as after the patch):
      
      * integration.feedback.test_feedback
      * integration.feedback.test_rocks
      
      Since they verify cartridge's additions for the feedback daemon, it is
      expected outcome of disabling the component entirely. Ideally we should
      conditionally disable those test cases, but it is out of scope here.
      
      Follows up #3308
      
      NO_DOC=I think it is expected behavior and unlikely it requires any
             change in the documentation
      NO_TEST=a test would verify behavior of the particular build type, but
              we have no such configuration in CI, so the test would be pretty
              useless
      NO_CHANGELOG=seems too minor to highlight it for users
      51a9cef3
    • Alexander Turenko's avatar
      cmake: show ENABLE_FEEDBACK_DAEMON in cmake output · 1546a123
      Alexander Turenko authored
      It is convenient to fast check, whether the option was enabled or
      disabled. Especially, when cmake is called indirectly, say, by a package
      manager on Gentoo.
      
      Follows up #3308
      
      NO_DOC=quite minor build process change
      NO_TEST=has no relation to tarantool behavior
      NO_CHANGELOG=see NO_DOC
      1546a123
  7. Aug 08, 2022
    • Ilya Verbin's avatar
      Use size-bounded versions of sprintf, strcpy and strcat · 243f9ebd
      Ilya Verbin authored
      To avoid potential buffer overflows and to make static analyzers happy.
      
      Fixed CWE-120:
      - sprintf: does not check for buffer overflows
      - strcpy: does not check for buffer overflows when copying to destination
      - strcat: does not check for buffer overflows when concatenating to
        destination
      
      Closes #7534
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      243f9ebd
    • Ilya Verbin's avatar
      util: introduce strlcat utility function · dcd9be4a
      Ilya Verbin authored
      strlcat is a function from BSD, which is designed to be safer, more
      consistent, and less error prone replacement for strcat and strncat.
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      
      Part of #7534
      dcd9be4a
  8. Aug 05, 2022
    • Vladimir Davydov's avatar
      memtx: fix dirty data written to snapshot for hash index · 64d87e88
      Vladimir Davydov authored
      The hash index doesn't create a snapshot clarifier, which is used for
      filtering out uncommitted tuples from a snapshot. Fix this. Also fix
      a bug in hash_snapshot_iterator_next, where we passed a wrong argument
      to tuple_data_range. It hasn't fired, because the clarifier didn't work.
      
      Fixes commit ee8ed065 ("txm: clarify all fetched tuples").
      Fixes commit f167c1af ("memtx: decompress tuples in snapshot
      iterator").
      
      Closes #7539
      
      NO_DOC=bug fix
      64d87e88
    • Georgiy Lebedev's avatar
      memtx: fix handling of corner cases gap tracking in transaction manager · 7360281e
      Georgiy Lebedev authored
      
      Gap tracking does not handle gap writes when the key has the same value as
      the gap item: review the whole gap write handling logic, refactor it and
      fix handling of corner cases along the way.
      
      Co-authored-by: default avatarAlexander Lyapunov <alyapunov@tarantool.org>
      
      Closes #7375
      
      NO_DOC=bugfix
      7360281e
    • Georgiy Lebedev's avatar
      memtx: denormalize `ITER_ALL` to `ITER_GE` in TREE index · 5a5e72b9
      Georgiy Lebedev authored
      Since `ITER_ALL` is an alias to `ITER_GE` in context of TREE index,
      denormalize it during iterator creation.
      
      Needed for #7375
      
      NO_CHANGELOG=refactoring
      NO_DOC=refactoring
      NO_TEST=refactoring
      5a5e72b9
    • Georgiy Lebedev's avatar
      memtx: fix tree iterator `next` result clarification · 542f9525
      Georgiy Lebedev authored
      The problem is described in #7073. It was fixed only for
      `tree_iterator_start_raw` next method, but other methods used for reverse
      iterators are also subject to this bug: move tuple clarification from the
      wrapper of iterator `next` methods to individual iterator methods.
      
      Closes #7432
      
      NO_DOC=bugfix
      542f9525
    • Yaroslav Lobankov's avatar
      ci: disable LuaJIT tests for OSX arm64 builds · ef7eb61f
      Yaroslav Lobankov authored
      LuaJIT tests are disabled in the scope of the issue [1].
      
      [1] https://github.com/tarantool/tarantool/issues/4819
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      ef7eb61f
    • Alexander Turenko's avatar
      lua/decimal: add Lua value accessors to module API · c75fbce1
      Alexander Turenko authored
      The Rust module (see the issue) needs a getter and a setter for decimal
      values on the Lua stack. Let's make them part of the module API.
      
      Part of #7228
      
      @TarantoolBot document
      Title: Lua/C functions for decimals in the module API
      
      The following functions are added into the module API:
      
      ```c
      /**
       * Allocate a new decimal on the Lua stack and return
       * a pointer to it.
       */
      API_EXPORT box_decimal_t *
      luaT_newdecimal(struct lua_State *L);
      
      /**
       * Allocate a new decimal on the Lua stack with copy of given
       * decimal and return a pointer to it.
       */
      API_EXPORT box_decimal_t *
      luaT_pushdecimal(struct lua_State *L, const box_decimal_t *dec);
      
      /**
       * Check whether a value on the Lua stack is a decimal.
       *
       * Returns a pointer to the decimal on a successful check,
       * NULL otherwise.
       */
      API_EXPORT box_decimal_t *
      luaT_isdecimal(struct lua_State *L, int index);
      ```
      c75fbce1
    • Alexander Turenko's avatar
      lua/interval: rework luaT_{new,push}interval() · 225a6213
      Alexander Turenko authored
      This change follows the previous commits regarding decimal, uuid and
      datetiem functions. See them for details.
      
      Part of #7228
      
      NO_DOC=refactoring, no user-visible changes
      NO_TEST=refactoring, no behavior changes
      NO_CHANGELOG=refactoring, no user-visible changes
      225a6213
    • Alexander Turenko's avatar
      lua/datetime: rework luaT_{new,push}datetime() · 1eadf531
      Alexander Turenko authored
      This change follows the previous commits regarding
      `luaT_{new,push}decimal()` and `luaT_{new,push}uuid()`. See them for
      details.
      
      Part of #7228
      
      NO_DOC=refactoring, no user-visible changes
      NO_TEST=refactoring, no behavior changes
      NO_CHANGELOG=refactoring, no user-visible changes
      1eadf531
    • Alexander Turenko's avatar
      lua/uuid: rework luaT_{new,push}uuid() API · 21f6a4b7
      Alexander Turenko authored
      This change follows the previous commit regarding `luaT_newdecimal()`
      and `luaT_pushdecimal()`, see explanation and details there.
      
      Also changed the `luaL_` prefix to more appropriate `luaT_`. The `struct
      tt_uuid` is our own type, the functions are specific to tarantool. So
      `luaT_`.
      
      Part of #7228
      
      NO_DOC=refactoring, no user-visible changes
      NO_TEST=refactoring, no behavior changes
      NO_CHANGELOG=refactoring, no user-visible changes
      21f6a4b7
    • Alexander Turenko's avatar
      lua/decimal: rework luaT_{new,push}decimal() API · b4f6675a
      Alexander Turenko authored
      `luaT_pushdecimal()` now accepts a decimal argument to copy into the Lua
      managed memory.
      
      `luaT_newdecimal()` now doing what `luaT_pushdecimal()` did before: just
      allocates a storage for decimal on the Lua stack.
      
      This naming looks much more friendly. It also seems that it follow Lua
      API names: `lua_push*()` accepts what to push, `lua_new*()` doesn't.
      
      A couple of notes around the change:
      
      * On the first glance it seems that `luaT_pushdecimal()` is redundant,
        because it can be written using `luaT_newdecimal()` + copying. That's
        truth in contexts, where we know size of the internal `decimal_t`
        structure. A user of the module API don't know it and should pass
        `box_decimal_t *` pointer to `luaT_pushdecimal()` to write the value.
      * I use `memcpy()` instead of just `*a = *b` in `luaT_pushdecimal()` to
        copy the padding byte content. Who knows, maybe this not-so-legal way
        to hold extra information may be crucial for some use case or will
        allow us to add one field into the structure.
      
      This is preparatory commit for exposing `luaT_*decimal()` functions into
      the module API.
      
      Next commits will change uuid, datetime, interval functions in the same
      way.
      
      Part of #7228
      
      NO_DOC=refactoring, no user-visible changes
      NO_TEST=will be tested in a next commit, after exposing to the
              module API
      NO_CHANGELOG=refactoring, no user-visible changes
      b4f6675a
    • Alexander Turenko's avatar
      lua/decimal: return pointer from luaT_isdecimal() · 450e2664
      Alexander Turenko authored
      This way we can use just luaT_isdecimal() instead of two calls:
      luaT_isdecimal() + luaT_checkdecimal() or luaT_isdecimal() +
      luaL_checkcdata(). It is convenient and we already follow this way in
      luaT_istuple().
      
      The difference from luaT_checkdecimal() is that luaT_isdecimal() does
      not raise a Lua exception. In may be undesirable and/or complicated to
      handle in some contexts.
      
      This is the preparation for exposing luaT_isdecimal() into the module
      API.
      
      Part of #7228
      
      NO_DOC=refactoring, no user-visible changes
      NO_TEST=will be tested in a next commit, after exposing to the
              module API
      NO_CHANGELOG=refactoring, no user-visible changes
      450e2664
    • Alexander Turenko's avatar
      lua/decimal: use luaT_ prefix instead of lua_ · 3061bea9
      Alexander Turenko authored
      We use the tarantool specific prefix for functions that are working with
      tarantool specific types. lua_ or luaL_ prefix may be confusing, because
      it is not always clear what is the origin of the function and where to
      find its documentation.
      
      This change is the preparation for exposing luaT_pushdecimal() and
      luaT_isdecimal() into the module API.
      
      While I'm here, I made several tidy changes:
      
      * Added `static` where appropriate.
      * Removed luaT_pushdecimalstr() from the header file, because it is not
        used outside of the compilation unit.
      
      Part of #7228
      
      NO_DOC=refactoring, no user-visible changes
      NO_TEST=refactoring, nothing new to test
      NO_CHANGELOG=refactoring, no user-visible changes
      3061bea9
    • Serge Petrenko's avatar
      raft: make followers notice leader hang · 56571d83
      Serge Petrenko authored
      It's possible to hang an instance by some non-yielding request. The
      simplest example is `while true do end`. A more true to life one would
      be a `select{}` from a large space, or `pairs` iteration over a space
      without yields.
      
      Any such request makes the instance unresponsive - it can serve neither
      reads nor writes. At the same time, the instance appears alive to other
      cluster members: relay thread used to communicate with others is not
      hung and continues to send heartbeats every replication_timeout.
      
      The problem is the most severe with Raft leader elections: followers
      believe the leader is fine and do not start elections despite leader
      being unable to serve reads or writes.
      
      Closes #7512
      
      NO_DOC=bugfix
      56571d83
  9. Aug 04, 2022
    • Vladimir Davydov's avatar
      salad: rework bps tree read view API · 91caa388
      Vladimir Davydov authored
      Currently, there's no notion of a BPS tree read view per se - one can
      create an iterator over a regular tree and then "freeze" it. This works
      just fine for snapshotting and joining replicas, but this spartan API
      doesn't let us implement user read views, because to do that we need to
      do lookups and create iterators over a frozen tree as many times as we
      want, not just once.
      
      So this patch introduces a concept of bps_tree_view, which contains a
      frozen image of a bps_tree and implements a subset of non-modifying
      bps_tree methods:
      
       - bps_tree_view_size
       - bps_tree_view_find
       - bps_tree_view_first
       - bps_tree_view_last
       - bps_tree_view_lower_bound
       - bps_tree_view_lower_bound_elem
       - bps_tree_view_upper_bound
       - bps_tree_view_upper_bound_elem
       - bps_tree_view_iterator_get_elem
       - bps_tree_view_iterator_prev
       - bps_tree_view_iterator_next
       - bps_tree_view_iterator_is_equal
      
      Note, bps_tree and bps_tree_view share bps_tree_iterator, because
      iterator methods (get_elem, next, prev, is_equal) take bps_tree or
      bps_tree_view. The bps_tree_iterator now contains only block index and
      offset.
      
      We could also implement the rest of non-modifying methods, but didn't do
      that, because they are not needed to implement user read views:
      
       - bps_tree_random
       - bps_tree_approximate_count
       - bps_tree_debug_check
       - bps_tree_print
      
      To create a bps_tree_view from a bps_tree, one is supposed to call
      bps_tree_view_create. If a bps_tree_view is no longer needed, it should
      be destroyed with bps_tree_view_destroy.
      
      Old methods used for creating frozen iterators were dropped:
      
       - bps_tree_iterator_freeze
       - bps_tree_iterator_destroy
      
      To avoid code duplication, we factored out the common part of bps_tree
      and bps_tree_view into a new structure, named bps_tree_common.
      Basically, the new structure contains all bps_tree members except
      matras, which is stored in bps_tree. The difference between
      bps_tree_view and bps_tree is that the latter stores matras_view
      instead of matras. The common part contains pointers to matras and
      matras_view, which are used by internal implementation to look up
      bps_tree blocks.
      
      All internal methods now take bps_tree_common instead of bps_tree.
      For all public methods that are implemented both for bps_tree and
      bps_tree_view, we have the common implementation defined in _impl
      suffixed private function, which is called by the corresponding public
      functions.
      
      To ensure that a modifying method isn't called on bps_tree_common object
      corresponding to a bps_tree_view because of a bug in the bps_tree
      implementation, we added !matras_is_read_view_created assertion to
      bps_tree_touch_block.
      
      Closes #7191
      
      NO_DOC=refactoring
      NO_CHANGELOG=refactoring
      91caa388
    • Vladimir Davydov's avatar
      Use bps_tree_size instead of accessing size directly · 5855fd30
      Vladimir Davydov authored
      We have a method for getting the number of elements stored in a BPS
      tree. Let's use it instead of accessing BPS tree internals directly
      so that we can freely refactor BPS tree internals.
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      5855fd30
    • Vladimir Davydov's avatar
      salad: minor bps tree code cleanup · 2fa28b41
      Vladimir Davydov authored
       - Add bps_tree_delete_value to the comment and declarations.
         (All other public methods are there.)
       - Fix typo in a comment: approxiamte -> approximate.
       - Fix comment to bps_tree_random.
       - Remove repeated word 'count' from comments.
      
      NO_DOC=no change
      NO_TEST=no change
      NO_CHANGELOG=no change
      2fa28b41
Loading