Skip to content
Snippets Groups Projects
  1. Apr 13, 2020
    • Serge Petrenko's avatar
      box: introduce indices by UUID · b238def8
      Serge Petrenko authored
      It is now possible to create an index over UUID values, returned by
      `uuid.new()`.
      
      Closes #4268
      Closes #2916
      
      @TarantoolBot document
      Title: Document uuid field type.
      
      There's a new field type -- UUID, it accepts values returned by
      `uuid.new()`.
      
      The index may be either unique or non-unique, nullable or non-nullable,
      and may be a primary key.
      
      The values in an index are ordered lexicographically by their string
      representation.
      
      To create an index over a uuid field for space `test`, say:
      ```
      box.space.test:create_index("pk", {parts={1, 'uuid'}})
      ```
      Now you may insert uuids into the space:
      ```
      tarantool> box.space.test:insert{uuid.new()}
      ---
      - [e631fdcc-0e8a-4d2f-83fd-b0ce6762b13f]
      ...
      
      tarantool> box.space.test:insert{uuid.fromstr('64d22e4d-ac92-4a23-899a-e59f34af5479')}
      ---
      - [64d22e4d-ac92-4a23-899a-e59f34af5479]
      ...
      
      tarantool> box.space.test:select{}
      ---
      - - [64d22e4d-ac92-4a23-899a-e59f34af5479]
        - [e631fdcc-0e8a-4d2f-83fd-b0ce6762b13f]
      ...
      
      ```
      b238def8
    • Serge Petrenko's avatar
      box: add MsgPack encoding/decoding for UUID · d68fc292
      Serge Petrenko authored
      A special format for encoding UUIDs to MsgPack is introduced.
      It is supported by both lua and C encoders/decoders, and it is now
      possible to insert UUIDs into spaces, but only into unindexed fields
      without format for now.
      
      Prerequisite #4268
      
      @TarantoolBot document
      Title: Internals: msgpack format for UUID
      
      UUID values share the MessagePack type with decimals:
      both use MP_EXT. A new subtype is introduced for UUIDs,
      MP_UUID = `0x02`
      UUID is encoded as follows:
      ```
          +--------+---------+-----------+
          | MP_EXT | MP_UUID | UuidValue |
          +--------+---------+-----------+
      ```
      Since UUID is 16 bytes in size, the header, MP_EXT, is always the same:
      `0xd8`. MP_UUID = `0x02` follows. The header is followed by the 16
      bytes of the UuidValue.
      
      UuidValue consists of 11 fields, which are encoded as big endian
      unsigned integers in the following order: `time_low` (4 bytes), `time_mid`
      (2 bytes), `time_hi_and_version` (2 bytes), `clock_seq_hi_and_reserved` (1
      byte), `clock_seq_low` (1 byte), `node[0], ..., node[5]` (1 byte each).
      
      The total size of such a representation is 18 bytes, whereas storing
      uuids as strings requires from 34 (when '-'s are ommitted) to 38 bytes
      per UUID, giving a 2x space usage improvement.
      d68fc292
    • Serge Petrenko's avatar
      uuid: expose tt_uuid_validate method · 9e6eae41
      Serge Petrenko authored
      Expose the code used to check UUID variant to a separate function:
      tt_uuid_validate(). The function will be used for msgpack uuid decoding
      when checking whether the buffer contains a valid uuid value.
      
      Prerequisite #4268
      9e6eae41
    • Serge Petrenko's avatar
      refactoring: extract mpstream into a separate library · fd27a75f
      Serge Petrenko authored
      mpstream is part of core library, which, since the introduction of
      messagepack extension types, leads to circular dependencies between core
      and any other library having extension type encoding/decoding methods
      (e.g. uuid library which will soon be expanded with such methods).
      
      Prerequisite #4268
      fd27a75f
  2. Apr 11, 2020
    • Alexander Turenko's avatar
      popen: fix 'may be clobbered' compiler warning · d9e69f72
      Alexander Turenko authored
      
      I guess a compiler assumes that the code inside vfork may use the stack
      slot that corresponds the variable and so clobber it. The recent commit
      07a07b3c ('popen: decouple logger fd
      from stderr') adds read from this variable after vfork() in the parent
      process.
      
      The warning is produced on RelWithDebInfo build with LTO enabled on GCC
      9.2.0 (locally) and on GCC 8.3.0 (in CI).
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      d9e69f72
  3. Apr 10, 2020
    • Alexander Turenko's avatar
      popen: use of exception safe functions for IO · 7c923503
      Alexander Turenko authored
      
      popen read / write functions are written in C and intended to be used
      from C: the contract is to return -1 at failure and set an entry to the
      diagnostics area. However a C++ exception from coio read / write
      functions would pass over a popen function stack frame.
      
      The solution is to use the recently introduced coio exception safe
      functions.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      7c923503
    • Alexander Turenko's avatar
      coio: add *_noxc read / write functions · 85eea4a8
      Alexander Turenko authored
      
      The popen implementation is written in C and uses coio read / write
      functions. If an exception occurs, it'll pass through the C code. It
      should be catched to proceed correctly.
      
      We usually have foo() and foo_xc() (exception) functions when both
      variants are necessary. Here I added non-conventional *_noxc() functions
      as the temporary solution to postpone refactoring of the code and all
      its usages.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      85eea4a8
    • Alexander Turenko's avatar
      coio: fix obsoleted comment in coio_write_timeout · b4360fec
      Alexander Turenko authored
      
      The comment was added in 52765de6, but
      becomes non-actual since 1.6.6-21-gc74abc786 ('Implement special
      TimedOut exception type and use it in coio and latch.')
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      b4360fec
    • Alexander Turenko's avatar
      popen: add missed diag_set() in popen IO functions · 4498d4f2
      Alexander Turenko authored
      
      Our usual convention for C code is to return a negative value at failure
      and set an entry to the diagnostics area.
      
      When code uses this convention consistently, it is much easier to handle
      failures when using it: you always know where to find an error type and
      message and how to pass the error to a C or Lua caller.
      
      See also the previous commit ('popen: add missed diag_set in
      popen_signal/delete').
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      4498d4f2
    • Alexander Turenko's avatar
      popen: remove redundant fd check before perform IO · 1ef95b99
      Alexander Turenko authored
      
      The function already checks flags to find out whether the file
      descriptor should be available for reading / writing. When it is so, the
      corresponding fd is great or equal to zero.
      
      The further commits will add missed diagnostics for IO functions and it
      is hard to write a meaningful error message for a situation that is not
      possible. Moreover, we would obligated to document the error as one of
      possible failures in a function contract (while it can't occur).
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      1ef95b99
    • Alexander Turenko's avatar
      popen: unblock popen_read_timeout at a first byte · 631f5f37
      Alexander Turenko authored
      
      Before this change popen_read_timeout() waits until a passed buffer will
      be fully filled (or until EOF / timeout / IO error occurs). Now it waits
      for any amount of data (but at least one byte).
      
      It allows to communicate with an interactive child program: write, read,
      repeat.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      631f5f37
    • Alexander Turenko's avatar
      popen: add const qualifier to popen_write_timeout · 04b0432d
      Alexander Turenko authored
      
      The buffer is for reading, we're not intend to change it.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      04b0432d
    • Alexander Turenko's avatar
      popen: decouple logger fd from stderr · 07a07b3c
      Alexander Turenko authored
      
      The default logger configuration writes logs to stderr.
      
      Popen implementation holds a logger fd until execve() to be able to
      write debug entries or information about a failure from a child. However
      when popen flags requires to close stderr in the child, the logger fd
      becomes closed: logging will fail.
      
      Another problem appears when a user want to capture stderr and
      tarantool's log level is set to debug (7). Since the logger uses stderr
      and it is fed to the parent using a pipe, the logger output will not
      shown on the 'real' stderr, but will be captured together with child's
      program debugging output.
      
      This commit duplicates a logger file descriptor that allows to close or
      redirect child's stderr without described side effects.
      
      See also 86ec3a5c ('popen: add logging
      in child process').
      
      Areas for improvements:
      
      * Copy logger fd at module initialization time instead of copying of
        each popen call.
      
      Alternatives:
      
      * Extend logger to allow to accumulate log entries in a buffer. Flush
        the buffer from the parent process. (It is possible since vfork does
        not split a virtual memory space).
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      07a07b3c
    • Alexander Turenko's avatar
      say: allow to set a logger file descriptor · 67c6a6e6
      Alexander Turenko authored
      
      It is necessary to decouple stderr from a logger file descriptor in the
      popen implementation.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      67c6a6e6
    • Alexander Turenko's avatar
      popen: add logging of fds closed in a child · 16c83356
      Alexander Turenko authored
      
      It is useful for debugging popen behaviour around file descriptors.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      16c83356
    • Alexander Turenko's avatar
      popen: add missed diag_set in popen_signal/delete · 96a25ee0
      Alexander Turenko authored
      
      Lua API will use content of the diagnostics area to report an error to a
      caller, so it is critical to always have proper diagnostics at failure.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      96a25ee0
    • Alexander Turenko's avatar
      popen: remove retval from popen_state() · e1579978
      Alexander Turenko authored
      
      After the previous commit ('popen: require popen handle to be non-NULL')
      it turns out that popen_state() function always succeeds. There is no
      reason to return a success / failure value from it.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      e1579978
    • Alexander Turenko's avatar
      popen: require popen handle to be non-NULL · 922cef65
      Alexander Turenko authored
      
      Further commits will add proper entries into the diagnostics area for
      failures inside popen functions. We should either report handle == NULL
      case via the diagnostics area or ensure that the NULL handle case is not
      possible.
      
      The latter approach is implemented in this commit. There are two
      reasons for this:
      
      * This way simplifies function contracts (one less kind of failure).
      * The popen Lua module (that will be implemented in the further commits)
        will not construct any logic using NULL as a handle. When 'NULL
        handle' error is not possible in the C API, it will be easier to
        verify that this failure is not possible the Lua API.
      
      A user of the C API should take care to don't call those functions with
      NULL handle.
      
      Part of #4031
      
      Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      922cef65
  4. Apr 08, 2020
  5. Apr 07, 2020
    • Nikita Pettik's avatar
      sql: reset values to be bound after execution · df03a7e8
      Nikita Pettik authored
      Before this patch prepared statements didn't reset bound values after
      its execution. As a result, if during next execution cycle not all
      parameters were provided, cached values would appear. For instance:
      
      prep = box.prepare('select :a, :b, :c')
      prep:execute({{[':a'] = 1}, {[':b'] = 2}, {[':c'] = 3}}
      -- [1, 2, 3]
      prep:execute({{[':a'] = 1}, {[':b'] = 2}})
      -- [1, 2, 3]
      
      However, expected result for the last query should be [1, 2, NULL].
      Let's fix it and always reset all binding values before next execution.
      
      Closes #4825
      df03a7e8
    • Nikita Pettik's avatar
      iproto: support error stacked diagnostic area · 4c465312
      Nikita Pettik authored
      This patch introduces support of stacked errors in IProto protocol and
      in net.box module.
      
      Closes #1148
      
      @TarantoolBot document
      Title: Stacked error diagnostic area
      
      Starting from now errors can be organized into lists. To achieve this
      Lua table representing error object is extended with .prev field and
      e:set_prev(err) method. .prev field returns previous error if any exist.
      e:set_prev(err) method expects err to be error object or nil and sets
      err as previous error of e. For instance:
      ```
      e1 = box.error.new({code = 111, reason = "cause"})
      e2 = box.error.new({code = 111, reason = "cause of cause"})
      
      e1:set_prev(e2)
      assert(e1.prev == e2) -- true
      ```
      Cycles are not allowed for error lists:
      ```
      e2:set_prev(e1)
      - error: 'builtin/error.lua: Cycles are not allowed'
      ```
      Nil is valid input to :set_prev() method:
      ```
      e1:set_prev(nil)
      assert(e1.prev == nil) -- true
      ```
      Note that error can be 'previous' only to the one error at once:
      ```
      e1:set_prev(e2)
      e3:set_prev(e2)
      assert(e1.prev == nil) -- true
      assert(e3.prev == e2) -- true
      ```
      Setting previous error does not erase its own previous members:
      ```
      -- e1 -> e2 -> e3 -> e4
      e1:set_prev(e2)
      e2:set_prev(e3)
      e3:set_prev(e4)
      e2:set_prev(e5)
      -- Now there are two lists: e1->e2->e5 and e3->e4
      assert(e1.prev == e2) -- true
      assert(e2.prev == e5) -- true
      assert(e3.prev == e4) -- true
      ```
      Alternatively:
      ```
      e1:set_prev(e2)
      e2:set_prev(e3)
      e3:set_prev(e4)
      e5:set_prev(e3)
      -- Now there are two lists: e1->e2 and e5->e3->e4
      assert(e1.prev == e2) -- true
      assert(e2.prev == nil) -- true
      assert(e5.prev == e3) -- true
      assert(e3.prev == e4) -- true
      ``
      Stacked diagnostics is also supported by IProto protocol. Now responses
      containing errors always (even if there's only one error to be returned)
      include new IProto key: IPROTO_ERROR_STACK (0x51). So, body corresponding to
      error response now looks like:
      ```
      MAP{IPROTO_ERROR : string, IPROTO_ERROR_STACK : ARRAY[MAP{ERROR_CODE : uint, ERROR_MESSAGE : string}, MAP{...}, ...]}
      ```
      where IPROTO_ERROR is 0x31 key, IPROTO_ERROR_STACK is 0x52, ERROR_CODE
      is 0x01 and ERROR_MESSAGE is 0x02.
      Instances of older versions (without support of stacked errors in
      protocol) simply ignore unknown keys and still rely only on IPROTO_ERROR
      key.
      4c465312
    • Nikita Pettik's avatar
      box: always promote error created via box.error() to diag · 4bcaf15e
      Nikita Pettik authored
      This patch makes box.error() always promote error to the diagnostic
      area despite of passed arguments.
      
      Closes #4829
      
      @TarantoolBot document
      Title: always promote error created via box.error() to diag
      
      box.error() is able to accept two types of argument: either pair of code
      and reason (box.error{code = 555, reason = 'Arbitrary message'}) or error
      object (box.error(err)). In the first case error is promoted to
      diagnostic area, meanwhile in the latter - it is not:
      ```
      e1 = box.error.new({code = 111, reason = "cause"})
      box.error({code = 111, reason = "err"})
      - error: err
      box.error.last()
      - err
      box.error(e1)
      - error: cause
      box.error.last()
      - err
      ```
      From now box.error(e1) sets error to diagnostic area as well:
      ```
      box.error(e1)
      - error: cause
      box.error.last()
      - cause
      ```
      4bcaf15e
    • Kirill Shcherbatov's avatar
      iproto: refactor error encoding with mpstream · ba7304fb
      Kirill Shcherbatov authored
      Refactor iproto_reply_error and iproto_write_error with a new
      mpstream-based helper mpstream_iproto_encode_error that encodes
      error object for iproto protocol on a given stream object.
      Previously each routine implemented an own error encoding, but
      with the increasing complexity of encode operation with following
      patches we need a uniform way to do it.
      
      The iproto_write_error routine starts using region location
      to use region-based mpstream. It is not a problem itself, because
      errors reporting is not really performance-critical path.
      
      Needed for #1148
      ba7304fb
    • Nikita Pettik's avatar
    • Nikita Pettik's avatar
      box: use stacked diagnostic area for functional indexes · c15cef54
      Nikita Pettik authored
      Since we've introduced stacked diagnostic in previous commit, let's use
      it in the code implementing functional indexes.
      
      Part of #1148
      c15cef54
    • Nikita Pettik's avatar
      box: introduce stacked diagnostic area · 3b887d04
      Nikita Pettik authored
      In terms of implementation, now struct error objects can be organized
      into double-linked lists. To achieve this pointers to the next and
      previous elements (cause and effect correspondingly) have been added to
      struct error. It is worth mentioning that already existing rlist and
      stailq list implementations are not suitable: rlist is cycled list, as a
      result it is impossible to start iteration over the list from random
      list entry and finish it at the logical end of the list; stailq is
      single-linked list leaving no possibility to remove elements from the
      middle of the list.
      
      As a part of C interface, box_error_add() has been introduced. In
      contrast to box_error_set() it does not replace last raised error, but
      instead it adds error to the list of diagnostic errors having already
      been set. If error is to be deleted (its reference counter hits 0 value)
      it is unlinked from the list it belongs to and destroyed. Meanwhile,
      error destruction leads to decrement of reference counter of its
      previous error and so on.
      
      To organize errors into lists in Lua, table representing error object in
      Lua now has .prev field (corresponding to 'previous' error) and method
      :set_prev(e). The latter accepts error object (i.e. created via
      box.error.new() or box.error.last()) and nil value. Both field .prev and
      :set_prev() method are implemented as ffi functions. Also note that
      cycles are not allowed while organizing errors into lists:
      e1 -> e2 -> e3; e3:set_prev(e1) -- would lead to error.
      
      Part of #1148
      3b887d04
    • Tim Curtis's avatar
      build: Fix static build based on Dockerfile · 9706de41
      Tim Curtis authored
      Found that 'openssl-1.1.0h' is EOL and its external link was removed.
      Fixed static build based on Dockerfile with the new link to the external
      openssl version 'openssl-1.1.1f'.
      
      Close #4830
      9706de41
  6. Apr 06, 2020
  7. Apr 02, 2020
    • Leonid's avatar
      luarocks: Add a kludge for option force of luarocks remove · 6ef13c69
      Leonid authored
      @Changelog
      Fixed the tarantoolctl rocks remove flag --force
      
      Forwarding of the --force flag to tarantoolctl rocks module was added.
      (Command: tarantoolctl rocks remove --force)
      
      Fixes: #3632
      6ef13c69
    • Leonid's avatar
      luarocks: Add a kludge for option all of luarocks search · 432ffa97
      Leonid authored
      @Changelog
      Fixed the tarantoolctl rocks search flag --all
      
      Forwarding of the --all flag to tarantoolctl rocks module was added.
      (Command: tarantoolctl rocks search --all)
      
      Fixes: #4529
      432ffa97
    • Alexander V. Tikhonov's avatar
      static build: create new build w/o dockerfile · fc55875e
      Alexander V. Tikhonov authored
      Fixed static build with '-DBUILD_STATIC=ON' option:
      
       - installed liblzma-dev library for libunwind static, due to found that
         static libunwind library uses undefined lzma functions:
           nm -a /usr/lib/x86_64-linux-gnu/libunwind-x86_64.a | grep lzma
                       U lzma_index_buffer_decode
                       U lzma_index_end
                       U lzma_index_size
                       U lzma_index_uncompressed_size
                       U lzma_stream_buffer_decode
                       U lzma_stream_footer_decode
         while dynamic libunwind correctly sees liblzma installed:
           ldd /usr/lib/x86_64-linux-gnu/libunwind-x86_64.so | grep lzma
             liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f8fd1c23000)
         so to fix it the static library of lzma was needed.
      
       - added lzma library to unwind library for Tarantool build at file:
           cmake/compiler.cmake
         due to fail:
           /usr/lib/x86_64-linux-gnu/libunwind-x86_64.a(elf64.o):
             In function `xz_uncompressed_size':
           ./src/elfxx.c:194: undefined reference to `lzma_stream_footer_decode'
           ./src/elfxx.c:201: undefined reference to `lzma_index_buffer_decode'
           ./src/elfxx.c:205: undefined reference to `lzma_index_size'
           ./src/elfxx.c:210: undefined reference to `lzma_index_end'
           ./src/elfxx.c:207: undefined reference to `lzma_index_uncompressed_size'
           ./src/elfxx.c:210: undefined reference to `lzma_index_end'
           /usr/lib/x86_64-linux-gnu/libunwind-x86_64.a(elf64.o):
             In function `_Uelf64_extract_minidebuginfo':
           ./src/elfxx.c:278: undefined reference to `lzma_stream_buffer_decode'
           collect2: error: ld returned 1 exit status
           test/unit/CMakeFiles/luaL_iterator.test.dir/build.make:134:
             recipe for target 'test/unit/luaL_iterator.test' failed
           make[2]: *** [test/unit/luaL_iterator.test] Error 1
      
       - added dl library to gomp library for test/unit tests
         binaries builds at file:
           cmake/BuildMisc.cmake
         due to fail:
           /usr/lib/gcc/x86_64-linux-gnu/7/libgomp.a(target.o):(.text+0x34d):
             more undefined references to `dlsym' follow
           /usr/lib/gcc/x86_64-linux-gnu/7/libgomp.a(target.o): In function
             `gomp_target_init':
           (.text+0x9cc): undefined reference to `dlerror'
           collect2: error: ld returned 1 exit status
      
        - added dl library to icu library for test/unit tests
         binaries builds at file:
           cmake/FindICU.cmake
         due to fail:
           /usr/x86_64-linux-gnu/libicuuc.a(putil.ao):
             In function `uprv_dl_open_60':
           (.text+0x1ce2): undefined reference to `dlopen'
           /usr/x86_64-linux-gnu/libicuuc.a(putil.ao):
             In function `uprv_dlsym_func_60':
           (.text+0x1d3d): undefined reference to `dlsym'
           /usr/x86_64-linux-gnu/libicuuc.a(putil.ao):
             In function `uprv_dl_close_60':
           (.text+0x1d21): undefined reference to `dlclose'
           collect2: error: ld returned 1 exit status
      
      Added static build to gitlab-ci in release check criteria named
      as static_build job. Previously named static_build job renamed to
      static_docker_build, due to it checks the build at Dockerfile.
      
      Also moved static build make targets from .gitlab.mk to .travis.mk
      to store it in common place with the other test/build make targets.
      Moved environement from .gitlab-ci.yml file into make targets to
      make this targets true building in static w/o additional setup.
      
      Close #4551
      fc55875e
    • Alexander V. Tikhonov's avatar
      build: resolve issues with sourceforge.net · 4a9302b8
      Alexander V. Tikhonov authored
      Found that wget may fail on downloading the file from flaky
      available servers with 500 HTTP error, like it was seen on
      icu4c sources downloading, please check the issue:
      https://sourceforge.net/p/forge/site-support/20071/
      
      Found that curl successfully downloads needed files even in
      such situations. Decided to use curl instead of wget tool
      to avoid of such errors feather.
      
      Also found that sourceforge site too often has issues and
      responds with 500 HTTP error. Decided to use the link from
      github instead of sourceforge to download the icu4c sources,
      as suggested on icu4c web site.
      4a9302b8
    • Alexander V. Tikhonov's avatar
      build: added static build subdirectory cleanup · 63640f5a
      Alexander V. Tikhonov authored
      Added the command for 'build' directory cleanup. It purges all
      artefacts produced for curl build, including the old configuration
      in build/curl.
      63640f5a
Loading