Skip to content
Snippets Groups Projects
  1. Mar 27, 2020
    • Nikita Pettik's avatar
      box/error: don't set error created via box.error.new to diag · eaa86088
      Nikita Pettik authored
      To achieve this let's refactor luaT_error_create() to return error
      object instead of setting it via box_error_set().
      luaT_error_create() is used both to handle box.error() and
      box.error.new() invocations, and box.error() is still expected to set
      error to diagnostic area. So, luaT_error_call() which implements
      box.error() processing at the end calls diag_set_error().
      It is worth mentioning that net.box module relied on the fact that
      box.error.new() set error to diagnostic area: otherwise request errors
      don't get to diagnostic area on client side.
      
      Needed for #1148
      Closes #4778
      
      @TarantoolBot document
      Title: Don't promote error created via box.error.new to diagnostic area
      
      Now box.error.new() only creates error object, but doesn't set it to
      Tarantool's diagnostic area:
      ```
      box.error.clear()
      e = box.error.new({code = 111, reason = "cause"})
      assert(box.error.last() == nil)
      ---
      - true
      ...
      ```
      To set error in diagnostic area explicitly box.error.set() has been
      introduced. It accepts error object which is set as last system error
      (i.e. becomes available via box.error.last()).
      Finally, box.error.new() does not longer accept error object as an
      argument (this was undocumented feature).
      Note that patch does not affect box.error(), which still pushes error to
      diagnostic area. This fact is reflected in docs:
      '''
      Emulate a request error, with text based on one of the pre-defined
      Tarantool errors...
      '''
      eaa86088
  2. Mar 26, 2020
    • Vladislav Shpilevoy's avatar
      fio: on close() don't loose fd if internal close fails · 177679a6
      Vladislav Shpilevoy authored
      File descriptor was set to -1 regardless of whether
      the object was closed properly. As a result, in case
      of an error the descriptor would leak.
      
      GC finalizer of a descriptor is left intact not to
      overcomplicate it.
      177679a6
    • Vladislav Shpilevoy's avatar
      swim: use fiber._internal.schedule_task() for GC · f073834b
      Vladislav Shpilevoy authored
      swim object created a new fiber in its GC function, because C
      function swim_delete() yields, and can't be called from an ffi.gc
      hook.
      
      It is not needed since the fiber module has a single worker
      exactly for such cases. The patch uses it.
      
      Follow up #4727
      f073834b
    • Vladislav Shpilevoy's avatar
      fio: close unused descriptors automatically · 3d5b4daa
      Vladislav Shpilevoy authored
      Fio.open() returned a file descriptor, which was not closed
      automatically after all its links were nullified. In other words,
      GC didn't close the descriptor.
      
      This was not really useful, because after fio.open() an exception
      may appear, and user needed to workaround this to manually call
      fio_object:close(). Also this was not consistent with io.open().
      
      Now fio.open() object closes the descriptor automatically when
      GCed.
      
      Closes #4727
      
      @TarantoolBot document
      Title: fio descriptor is closed automatically by GC
      
      fio.open() returns a descriptor which can be closed manually by
      calling :close() method, or it will be closed automatically, when
      it has no references, and GC deletes it.
      
      :close() method existed always, auto GC was added just now.
      
      Keep in mind, that the number of file descriptors is limited, and
      they can end earlier than GC will be triggered to collect not
      used descriptors. It is always better to close them manually as
      soon as possible.
      3d5b4daa
    • Vladislav Shpilevoy's avatar
      fiber: introduce schedule_task() internal function · 8443bd93
      Vladislav Shpilevoy authored
      fiber._internal.schedule_task() is an API for a singleton fiber
      worker object. It serves for not urgent delayed execution of
      functions. Main purpose - schedule execution of a function, which
      is going to yield, from a context, where a yield is not allowed.
      Such as an FFI object's GC callback.
      
      It will be used by SWIM and by fio, whose destruction yields, but
      they need to use GC finalizer, where a yield is not allowed.
      
      Part of #4727
      8443bd93
    • Alexander V. Tikhonov's avatar
      test: fix OSX host setup · a41bef3b
      Alexander V. Tikhonov authored
      Fixed OSX host setup for Tarantool build:
      - set brew installation from Homebrew repository instructions;
      - set in use Python 2 latest commit from tapped local formula,
        since Python 2 is EOL, also removed extra pip installation with
        get-pip script, because tapped formula installs pip itself.
        python@2 was deleted from homebrew/core in commit 028f11f9e:
          python@2: delete (https://github.com/Homebrew/homebrew-core/issues/49796)
          EOL 1 January 2020.
        Tapped formula created from the latest formula before its removal:
          git -C "$(brew --repo homebrew/core)" show 028f11f9e^:Formula/python@2.rb
      - added upgrade packages call to avoid of fails on already
        installed packages, but with previous version;
      - fixed the gitlab-ci configuration for sudo on testing hosts and removed pip
        option '--user' to avoid of use the users paths with special setup for it.
      
      Fixed OSX host setup for Tarantool test:
      - set maximum processes limit value to 2500 for testing process;
      - new Mac machines are going to be added into CI and usernames on them
        are long according to internal policies. It makes a home directory to
        be long too and so a path to a unix socket created during testing can
        be longer then UNIX_PATH_MAX=108 constant which is described as issue
          https://github.com/tarantool/tarantool/issues/4634
        To avoid of it the short working directory for testing set by option:
          --vardir /tmp/tnt
      a41bef3b
    • Nikita Pettik's avatar
      box/error: introduce box.error.set() method · f00945a1
      Nikita Pettik authored
      box.error.set(err) sets err to instance's diagnostics area. Argument err
      is supposed to be instance of error object. This method is required
      since we are going to avoid adding created via box.error.new() errors to
      Tarantool's diagnostic area.
      
      Needed for #1148
      Part of #4778
      f00945a1
    • Nikita Pettik's avatar
      test: move box.error tests to box/error.test.lua · 195d99d0
      Nikita Pettik authored
      We are going to introduce more tests related to error module, so let's
      move all error-related tests from box/misc.test.lua to a separate test
      file (box/error.test.lua).
      
      Needed for #1148
      195d99d0
    • Kirill Shcherbatov's avatar
      box: rename diag_add_error to diag_set_error · 55a39946
      Kirill Shcherbatov authored
      Let's rename diag_add_error() to diag_set_error() because it actually
      replaces an error object in diagnostic area with a new one and this name
      is not representative. Moreover, we are going to introduce a new
      diag_add_error() which will place error at the top of stack diagnostic
      area.
      
      Needed for #1148
      55a39946
    • Kirill Shcherbatov's avatar
      box: rfc for stacked diagnostic area · 61cdd89f
      Kirill Shcherbatov authored
      Part of #1148
      61cdd89f
    • Cyrill Gorcunov's avatar
      test: unit/popen -- provide a child process · 12086678
      Cyrill Gorcunov authored
      
      Testing via plain C interface with a shell is not stable,
      the shell might simply be misconfigured or not found and
      we will simply stuck forever (the signal handling in libev
      is tricky and requires at least idle cycles or similar to
      pass event processing). Thus lets rather run a program we
      know is presenting in the system (popen-child executable).
      
      Fixes #4811
      
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      12086678
    • Cyrill Gorcunov's avatar
      popen: do not require space for shell args · c6b8ed77
      Cyrill Gorcunov authored
      
      In case of direct execute without using a shell there
      is no need to require a caller to allocate redundant
      space, lets pass executable name in first argument.
      
      Since this is yet testing api we're allowed to change
      without breaking aything.
      
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      c6b8ed77
  3. Mar 25, 2020
  4. Mar 23, 2020
    • Timur Safin's avatar
      evio: workaround for wsl1 so_linger assertion · 734bcafc
      Timur Safin authored
      
      SO_LINGER makes no much sense for unix-sockets, and Microsoft WSL
      is returning EINVAL if setsockopts called for SO_LINGER over unix
      sockets:
      
        [004] 2020-03-11 18:42:29.592 [29182] main/102/app sio.c:169 !> SystemError setsockopt(SO_LINGER), called on fd 16, aka
        [004] 2020-03-11 18:42:29.592 [29182] main/102/app F> can't initialize storage: setsockopt(SO_LINGER), called on fd 16,
        [004] 2020-03-11 18:42:29.592 [29182] main/102/app F> can't initialize storage: setsockopt(SO_LINGER), called on fd 16,
      
      And it's sort of correct here, but the problem is Linux is simply
      silently ignoring it, which passes tests.
      
      After much debates we decided to work-around this case via CMAKE
      define.
      
      NB! In a future (April/May 2020), when WSL2 with full Linux kernel
      would be released we should disable this check.
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      734bcafc
  5. Mar 20, 2020
  6. Mar 19, 2020
    • Vladislav Shpilevoy's avatar
      iproto: show real port in logs and box.info.listen · 2c3acf2b
      Vladislav Shpilevoy authored
      Box.cfg{listen = 0} automatically chooses a port. But it was
      impossible to obtain a real port the instance is bound to.
      
      An ability to see a real port may help to make test-run more
      robust, because it won't depend on which ports are free, and
      won't need to pre-choose them in advance.
      
      Now box.info.listen shows a real address, or nil when listen is
      turned off. Also a real address is logged instead of the dummy
      0-port one.
      
      Closes #4620
      
      @TarantoolBot document
      Title: box.info.listen - real address
      
      New value in box.info - listen. It is a real address to which the
      instance was bound. For example, if box.cfg.listen was set with
      a zero port, box.info.listen will show a real port. The address
      is stored as a string:
      
          - unix/:<path> for UNIX domain sockets;
          - <ip>:<port> for IPv4;
          - [ip]:<port> for IPv6.
      
      If the instance does not listen anything, box.info.listen is nil.
      2c3acf2b
  7. Mar 18, 2020
    • Oleg Babin's avatar
      box: allow to retrieve the last generated value of sequence · 64c69fe0
      Oleg Babin authored
      
      This patch introduces "current" function for sequences.
      It returns the last retrieved value of specified sequence or
      throws an error if no value has been generated yet.
      
      This patch partially reverts 3ff1f1e3
      (box: remove sequence_get) here similar function "get" was removed
      to avoid possible misleading with "currval" function of PosgreSQL
      that returns the last obtained value of the sequence in the scope
      of current session. In contrast "current" returns the last globally
      retrieved value of the sequence.
      
      Closes #4752
      
      Reviewed-by: default avatarVladislav Shpilevoy <v.shpilevoy@tarantool.org>
      Reviewed-by: default avatarNikita Pettik <korablev@tarantool.org>
      
      @TarantoolBot document
      Title: sequence:current()
      
      This patch introduces "current" function for sequences.
      It returns the last retrieved value of specified sequence or
      throws an error if no value has been generated yet ("next"
      has not been called yet or right after "reset" is called).
      
      Lua:
      
      Example:
      
      ```lua
      sq = box.schema.sequence.create('test')
      ---
      ...
      sq:current()
      ---
      - error: Sequence 'test' is not started
      ...
      sq:next()
      ---
      - 1
      ...
      sq:current()
      ---
      - 1
      ...
      sq:set(42)
      ---
      ...
      sq:current()
      ---
      - 42
      ...
      sq:reset()
      ---
      ...
      sq:current()  -- error
      ---
      - error: Sequence 'test' is not started
      ...
      ```
      
      C API:
      
      ```C
      int
      box_sequence_current(uint32_t seq_id, int64_t *result);
      ```
      
      Where:
        * seq_id - sequence identifier;
        * result - pointer to a variable where the current sequence
        value will be stored on success.
      
      Returns 0 on success and -1 otherwise. In case of an error user
      could get it via `box_error_last()`.
      64c69fe0
  8. Mar 17, 2020
  9. Mar 16, 2020
    • Vladislav Shpilevoy's avatar
      tuple: document all missed box.tuple.* methods · adc98575
      Vladislav Shpilevoy authored
      In #4684 it was found that box.tuple.* contained some private
      functions: bless(), encode(), and is().
      
      Bless() and encode() didn't make any sense for a user, so they
      were hidden into box.internal.tuple.*.
      
      But box.tuple.is() is actually a useful thing. It is harnessed in
      the tests a lot, and is likely to be already used by customers,
      because it is available in box.tuple.* for a long time. It is a
      matter of time when someone will open a doc ticket saying that
      box.tuple.is() is not documented. The patch makes it legally
      public.
      
      Follow-up #4684
      
      @TarantoolBot document
      Title: box.tuple.is()
      ```Lua
      box.tuple.is(object)
      ```
      A function to check whether a given object is a tuple cdata
      object. Returns true or false. Never raises nor returns an error.
      adc98575
    • Vladislav Shpilevoy's avatar
      tuple: hide internal functions from box.tuple.* · b2b3fb21
      Vladislav Shpilevoy authored
      box.tuple.bless, .encode, and .is are internal. Their
      behaviour is not documented, and they may omit some checks for the
      sake of speed, and can crash if used without thinking.
      
      Nonetheless, despite they are not documented, curious users could
      notice them in box.tuple.* output via autocompletion, for example.
      And they could try to use them. This is not ok.
      
      box.tuple.bless() being called by a user leads either to a crash,
      or to a leak (because it is basically tuple reference counter
      increment).
      
      box.tuple.encode() is kind of a wrapper around msgpack, and users
      should not touch it. It may change, may be removed. And is just
      makes no sense except some rare cases in schema.lua.
      
      bless() and encode() were used in schema.lua only, so the patch
      simply moves them to box.internal.tuple.
      
      box.tuple.is() is kept as is, because
      - this is used in the tests a lot;
      - it is totally safe;
      - that function actually makes sense, and some users could have
        already started using it.
      
      There is no a test, since nothing to test - bless() is not
      available for users anymore (assuming no one is brave enough to
      rely on box.internal).
      
      Closes #4684
      b2b3fb21
Loading