Skip to content
Snippets Groups Projects
  1. Dec 11, 2019
    • Mergen Imeev's avatar
      sql: refactor sqlVdbeMemIntegerify() function · 65e9f9a1
      Mergen Imeev authored
      The sqlVdbeMemIntegerify() function accepts the is_forced flag as
      one of the arguments. But this flag is actually useless, because
      regardless of whether it is TRUE or FALSE, the function will do
      the same. This patch removes the is_forced argument from the
      function. There will be no test, since the result of the function
      has not changed.
      
      Part of #4526
      65e9f9a1
  2. Dec 10, 2019
    • Olga Arkhangelskaia's avatar
      lib: fix comment in coio_task.h · e6933207
      Olga Arkhangelskaia authored
      According to code coio_call does not take a timeout as an argument,
      however it was mentioned in the comment and usage example. This lead to
      error in documentation. The patch fixes it.
      
      Closes #4663
      e6933207
    • Vladislav Shpilevoy's avatar
      func: fix not unloading of unused modules · ca07088c
      Vladislav Shpilevoy authored
      C functions are loaded from .so/.dylib dynamic libraries. A
      library is loaded when any function from there is called first
      time. And was supposed to be unloaded, when all its functions are
      dropped from the schema (box.schema.func.drop()), and none of them
      is still in a call. But the unloading part was broken.
      
      In fact, box.schema.func.drop() never unloaded anything. Moreover,
      when functions from the module were added again without a restart,
      it led to a second mmap of the same module. And so on, the same
      library could be loaded any number of times.
      
      The problem was in a useless flag in struct module preventing its
      unloading even when it is totally unused. It is dropped.
      
      Closes #4648
      ca07088c
    • Vladislav Shpilevoy's avatar
      errinj: provide 'get' method in Lua · c3c6d3fc
      Vladislav Shpilevoy authored
      Error injections are used to simulate an error. They are
      represented as a flag, or a number, and are used in Lua tests. But
      they don't have any feedback. That makes impossible to use the
      injections to check that something has happened. Something very
      needed to be checked, and impossible to check in a different way.
      
      More certainly, the patch is motivated by a necessity to count
      loaded dynamic libraries to ensure, that they are loaded and
      unloaded when expected. This is impossible to do in a platform
      independent way. But an error injection as a debug-only counter
      would solve the problem.
      
      Needed for #4648
      c3c6d3fc
    • Vladislav Shpilevoy's avatar
      Fix build on Mac with gcc and XCode 11 · 16c40444
      Vladislav Shpilevoy authored
      There is a bug in XCode 11 which makes some standard C headers
      not self sufficient when compile with gcc. At least <stdlib.h> and
      <algorithm> are affected. When they are included first,
      compilation fails with creepy errors like this:
      
          In file included
          from /Applications/Xcode.app/Contents/Developer/
              Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
              sys/wait.h:110,
          from /Applications/Xcode.app/Contents/Developer/
              Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
              stdlib.h:66,
          from tarantool/third_party/zstd/lib/common/zstd_common.c:16:
              /Applications/Xcode.app/Content/Developer/
              Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
              sys/resource.h:
          In function 'getiopolicy_np': /Applications/Xcode.app/Contents/Developer/
              Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
              sys/resource.h:447:34: error:
                  expected declaration specifiers before '__OSX_AVAILABLE_STARTING'
                  447 | int     getiopolicy_np(int, int)
                  __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
      
      The patch workarounds the bug by deleting the buggy header
      includes where possible, and by changing include order in other
      cases.
      
      Also there was a second compilation problem. This was about
      different definitions of the same standard functions: via extern
      "C" and without. It looked like this:
      
          In file included from tarantool/src/trivia/util.h:36,
          from tarantool/src/tt_pthread.h:35,
          from tarantool/src/lib/core/fiber.h:38,
          from tarantool/src/lib/core/coio.h:33,
          from tarantool/src/lib/core/coio.cc:31:
          /usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0
          include-fixed/stdio.h:222:7: error: conflicting declaration of
          'char* ctermid(char*)' with 'C' linkage
            222 | char *ctermid(char *);
                |       ^~~~~~~
      
          In file included from /Applications/Xcode.app/Contents/Developer/Platforms/
          MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:525,
          from tarantool/src/lib/core/fiber.h:37,
          from tarantool/src/lib/core/coio.h:33,
          from tarantool/src/lib/core/coio.cc:31:
          /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/
          Developer/SDKs/MacOSX.sdk/usr/include/_ctermid.h:26:10: note: previous
          declaration with 'C++' linkage
            26 | char    *ctermid(char *);
               |          ^~~~~~~
      
      This bug is workarounded by deletion of the conflicting includes,
      because anyway they appeared to be not needed.
      
      Closes #4580
      
      Conflicts:
      	third_party/decNumber
      16c40444
    • Kirill Yukhin's avatar
      decNumber: bump new version · 2125b626
      Kirill Yukhin authored
      New commit fixes build on XCode 11.
      2125b626
    • Serge Petrenko's avatar
      backtrace: fix out of bounds access on backtrace printing · 2066f297
      Serge Petrenko authored
      snrpintf always null-terminates the passed string, and it also returns
      the number of bytes that "would have been written if there was enough
      space", so not only we don't have to null-terminate the string, but even
      more so we shouldn't do it erroneously. The only case when a string
      should be null-terminated manually is when the print cycle doesn't run
      at all, so move the termination before the cycle.
      
      Closes #4636
      2066f297
    • Serge Petrenko's avatar
      clear terminal state on panic · c6d4f010
      Serge Petrenko authored
      The tarantool_free() call in the end of main() works all the time except
      when we exit due to a panic. We need to clear terminal state in this
      case also, so return to using atexit() to clear readline state.
      
      Closes #4466
      c6d4f010
    • Chris Sosnin's avatar
      box: remove unicode_ci for functions · f88f9731
      Chris Sosnin authored
      Unicode_ci collation breaks the general
      rule for objects naming, so we remove it
      in version 2.3.1
      
      Closes #4561
      f88f9731
  3. Dec 06, 2019
    • Alexander V. Tikhonov's avatar
      build: fix unit tests build with -lrt on CentOS 6 · 960e9c0c
      Alexander V. Tikhonov authored
      After the commit 77fa45bd
      ('lua: add fiber.top() listing fiber cpu consumption')
      the unit tests builds failed like:
      
      /opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/ld:
        ../../src/lib/core/libcore.a(fiber.c.o): undefined reference to symbol
        'clock_gettime@@GLIBC_2.2.5'
      //lib64/librt.so.1: error adding symbols: DSO missing from command line
      collect2: error: ld returned 1 exit status
      test/unit/CMakeFiles/cbus.test.dir/build.make:108: recipe for target
        'test/unit/cbus.test' failed
      make[2]: *** [test/unit/cbus.test] Error 1
      
      Found that fiber.cc is using now clock_gettime(), which requires -lrt
      with glibc. To fix it added librt dependency for core library for glibc.
      Due to glibc requires for -lrt for clock_gettime() only for some
      versions, check 'man clock_gettime.2':
        'Link with -lrt (only for glibc versions before 2.17).'
      the check whether is able to use clock_gettime() w/o librt library is
      added.
      
      Close #4639
      
      (cherry picked from commit 99b0ef771135eab66ef3758371b1b5431e21cbff)
      960e9c0c
    • Chris Sosnin's avatar
      app: increase max recursion depth for encoding/decoding · bf20a7ce
      Chris Sosnin authored
      It was requested to be raised from 32 to 128
      
      Closes #4670
      bf20a7ce
  4. Dec 05, 2019
    • Vladislav Shpilevoy's avatar
      test: fix flaky box/gh-4627-session-use-after-free · 9643fdc7
      Vladislav Shpilevoy authored
      The problem was in that the test uses the global trigger
      box.session.on_disconnect() to set a global variable by one
      connection. But test-run can do multiple connects/reconnects to
      the same instance. That led to multiple invocations of
      box.session.on_disconnect(), which could override the global
      variable in unexpected ways and moments.
      
      The patch makes only one session execute that trigger.
      
      Probably related to https://github.com/tarantool/test-run/issues/46
      
      
      Follow up #4627
      
      Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      9643fdc7
    • Kirill Yukhin's avatar
      luajit: bump new a new version · e12930d0
      Kirill Yukhin authored
      List of changes
           - fold: keep type of emitted CONV in sync with its mode
           - test: adjust the test name related to PAIRSMM flag
      e12930d0
    • Olga Arkhangelskaia's avatar
      build: enables LUAJIT_ENABLE_PAIRSMM by default · 2110213c
      Olga Arkhangelskaia authored
      Turns on LUAJIT_ENABLE_PAIRSMM flag for tarantool build.
      Now __pairs/__ipairs metamethods are available.
      
      Closes #4650
      2110213c
    • Alexander V. Tikhonov's avatar
      build: add Fedora 31 into CI / CD · 9e09b07c
      Alexander V. Tikhonov authored
      Added build + test jobs in GitLab-CI and build + test + deploy jobs on
      Travis-CI for Fedora 31.
      
      Updated testing dependencies in the RPM spec to follow the new Python 2
      package naming scheme that was introduced in Fedora 31: it uses
      python2-' prefix rather then 'python-'.
      
      Fedora 31 does not provide python2-gevent and python2-greenlet packages,
      so they were pushed to https://packagecloud.io/packpack/backports
      repository. This repository is enabled in our build image
      (packpack/packpack:fedora-31) by default. Those dependencies are build-time,
      so nothing was changed for a user. The source RPM packages were gathered
      from https://rpms.remirepo.net/rpmphp/
      
      .
      
      Closes #4612
      
      Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      9e09b07c
    • Alexander Turenko's avatar
      test: update test-run · 5fccf003
      Alexander Turenko authored
      Strengthen test_run:cmd() against temporary connection failures (#193).
      
      We recently added 'replication/box_set_replication_stress' test that may
      exceed file descriptor limit. When test_run:cmd() function executes a
      command ('switch master' in the case), it tries to create a new socket
      and connect it to test-run's inspector, but it may fail to do so in the
      case, because of the file descriptor limit.
      
      The sockets that the test produces are closed in background, so if we'll
      keep trying to create and connect a socket we'll succeed once. This is
      exactly that the test-run's patch doing: it fails test_run:cmd()
      function only if a socket cannot be connected during 100 seconds.
      
      I guess that the reason why sockets are not closed immediately is that
      relays wait until replicas will close its side of a socket and only then
      closes its side. Didn't investigate it deeper, to be honest.
      5fccf003
  5. Dec 03, 2019
    • Maria's avatar
      json: fix stack-use-after-scope in json_decode() · 6508ddb7
      Maria authored
      Inside json_decode() struct luaL_serializer is allocated on stack, but
      json context stores pointer to it:
      
         998	static int json_decode(lua_State *l)
         999	{
        ...
        1007	    if (lua_gettop(l) == 2) {
        1008	        struct luaL_serializer user_cfg = *luaL_checkserializer(l);
        1009	        luaL_serializer_parse_options(l, &user_cfg);
        1010	        lua_pop(l, 1);
        1011	        json.cfg = &user_cfg;
        1012      }
      
      Later (for instance in json_decode_descend()), it can be dereferenced
      which in turn results in stack-use-after-scope (object turns into
      garbage right after scope is ended). To fix it let's simply avoid
      allocating and copying luaL_serializer on stack and instead use pointer
      to it.
      
      Bug is found by ASAN: test app-tap/json.test.lua fails with enabled
      ASAN. Current fix allows to pass all tests.
      
      Thanks to @Korablev77 for the initial investigation.
      
      Closes #4637
      6508ddb7
  6. Dec 02, 2019
    • Alexander Turenko's avatar
      Revert "test: update test-run" · 4acdeeda
      Alexander Turenko authored
      This reverts commit a0b196dd.
      
      This commit was pushed occasionally and points to a draft commit in
      test-run repository. See also
      https://github.com/tarantool/test-run/issues/195
      4acdeeda
    • Ilya Kosarev's avatar
      test: stabilize quorum test conditions · f6775e86
      Ilya Kosarev authored
      There were some pass conditions in quorum test which could take some
      time to be satisfied. Now they are wrapped using test_run:wait_cond to
      make the test stable.
      
      Closes #4586
      f6775e86
    • Ilya Kosarev's avatar
      replication: make anon replicas iteration safe · 6f038f4b
      Ilya Kosarev authored
      In replicaset_follow we iterate anon replicas list: list of replicas
      that haven't received an UUID. In case of successful connect replica
      link is being removed from anon list. If it happens immediately,
      without yield in applier, iteration breaks. Now it is fixed by
      rlist_foreach_entry_safe instead of common rlist_foreach_entry.
      Relevant test case is added.
      
      Part of #4586
      Closes #4576
      Closes #4440
      6f038f4b
    • Ilya Kosarev's avatar
      replication: fix appliers pruning · 36ff3c89
      Ilya Kosarev authored
      During pruning of appliers some anon replicas might connect
      from replicaset_follow called in another fiber. Therefore we need to
      prune appliers of anon replicas first and, moreover, prune them one by
      one instead of iterating them, as far as any of them might connect
      while we are stopping the other one and it will break iteration.
      
      Part of #4586
      Closes #4643
      36ff3c89
    • Ilya Kosarev's avatar
      test: update test-run · a0b196dd
      Ilya Kosarev authored
      Stabilize tcp_connect in test_run:cmd() (tarantool/test-run#193)
      a0b196dd
  7. Nov 27, 2019
    • Ilya Kosarev's avatar
      refactoring: remove try..catch wrapper around trigger->run · 43f2c359
      Ilya Kosarev authored
      Triggers don't throw exceptions any more. Now they have
      return codes to report errors.
      
      Closes #4247
      43f2c359
    • Ilya Kosarev's avatar
      refactoring: remove redundant line in txn_alter_trigger_new · 0a4079fc
      Ilya Kosarev authored
      Since refactoring: clear privilege managing triggers from exceptions
      (977fca29) we are doing zero memset for
      trigger struct in txn_alter_trigger_new. This means we don't any more
      need to set any field of this struct to NULL explicitly. 
      
      Part of #4247
      0a4079fc
    • Ilya Kosarev's avatar
      refactoring: update comment for index_def_check_tuple · 7b23b827
      Ilya Kosarev authored
      Originally index_def_check_tuple comment said that it throws a nice
      error. Since refactoring: remove exceptions from
      index_def_new_from_tuple (90ac0037)
      it returns an error. Now it is clearly specified in the comment.
      
      Part of #4247
      7b23b827
    • Ilya Kosarev's avatar
      refactoring: clear triggers from fresh exceptions · b4ddb4a0
      Ilya Kosarev authored
      Clear triggers from freshly occured exceptions. Trivial replacements:
      `diag_raise` by `return -1`, _xc function by it's non _xc version.
      
      Part of #4247
      b4ddb4a0
    • Ilya Kosarev's avatar
      refactoring: set diagnostics if sequence_by_id fails · cc6f68d2
      Ilya Kosarev authored
      In refactoring: use non _xc version of functions in triggers
      (b75d5f85) sequence_cache_find was
      replaced by sequence_by_id. It led to the loss of diagnostics in case
      of sequence_by_id failure. Now it is fixed.
      
      Part of #4247
      cc6f68d2
    • Ilya Kosarev's avatar
      refactoring: recombine error conditions in triggers · 8d66e638
      Ilya Kosarev authored
      Some error conditions in triggers and underlying functions were
      combined to look better. On the other hand, in
      on_replace_dd_fk_constraint we now return an error immediately if
      child space were not found instead of searching for both child and
      parent spaces before search results inspection.
      
      Part of #4247
      8d66e638
    • Ilya Kosarev's avatar
      refactoring: specify struct name in allocation diagnostics · bfe2a287
      Ilya Kosarev authored
      In case of allocation problems in region alloc we were setting
      diagnostics using "new slab" stub. Now we specify concrete struct name
      which was going to be allocated.
      
      Part of #4247
      bfe2a287
    • Ilya Kosarev's avatar
      refactoring: wrap new operator calls in triggers · aa2e0987
      Ilya Kosarev authored
      std operator new might throw so we need to wrap it in triggers to
      provide non-throwing triggers. It also means alter_space_move_indexes
      returns an error code now. It's usages are updated.
      
      Part of #4247
      aa2e0987
    • Nikita Pettik's avatar
      sql: fix decode of boolean binding value · abc08ca7
      Nikita Pettik authored
      Some time ago, when there was no support of boolean type in SQL, boolean
      values passed as parameters to be bound were converted to integer values
      0 and 1. It takes place in lua_sql_bind_decode(). However, now we can
      avoid this conversion and store booleans as booleans. Note that patch
      does not include test case since type of value is preserved correctly,
      so when binding is extracted from struct sql_bind it will assigned to
      the right value.
      abc08ca7
  8. Nov 26, 2019
    • Vladislav Shpilevoy's avatar
      iproto: don't destroy a session during disconnect · 6da9d395
      Vladislav Shpilevoy authored
      Binary session disconnect trigger yield could lead to use after
      free of the session object. That happened because iproto thread
      sent two requests to TX thread at disconnect:
      
          - Close the session and run its on disconnect triggers;
      
          - If all requests are handled, destroy the session.
      
      When a connection is idle, all requests are handled, so both these
      requests are sent. If the first one yielded in TX thread, the
      second one arrived and destroyed the session right under the feet
      of the first one.
      
      This can be solved in two ways - in TX thread, and in iproto
      thread.
      
      Iproto thread solution (which is chosen in the patch): just don't
      send destroy request until disconnect returns back to iproto
      thread.
      
      TX thread solution (alternative): add a flag which says whether
      disconnect is processed by TX. When destroy request arrives, it
      checks the flag. If disconnect is not done, the destroy request
      waits on a condition variable until it is.
      
      The iproto is a bit tricker to implement, but it looks more
      correct.
      
      Closes #4627
      6da9d395
  9. Nov 22, 2019
    • Kirill Yukhin's avatar
      luajit: bump a new version · 5d2105bf
      Kirill Yukhin authored
      Add LUAJIT_ENABLE_PAIRSMM flag as a build option for luajit.
      If the flag is set, pairs/ipairs metamethods are available in
      Lua 5.1.
      For Tarantool this option is enabled by default.
      5d2105bf
  10. Nov 21, 2019
    • Vladislav Shpilevoy's avatar
      build: fix warning re comparison of enum and uint · 2afbe263
      Vladislav Shpilevoy authored
      
      The warning is observed when tarantool is compiled by GCC 9.1.0.
      
      Warnings are treated as errors during a debug build or when
      -DENABLE_WERROR=ON option is passed to cmake, that is usual for our
      testing jobs in CI.
      
      The commit that introduces the problem is
      3a8adccf ('access: fix invalid error
      type for not found user').
      
      Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      2afbe263
    • Vladislav Shpilevoy's avatar
      replication: use empty password by default · 6c01ca48
      Vladislav Shpilevoy authored
      Replication's applier encoded an auth request with exactly the
      same parameters as extracted by the URI parser. I.e. when no
      password was specified, the parser returned it as NULL, and it was
      not encoded. The relay, received such an auth request, complained
      that IPROTO_TUPLE field is not specified (this is password).
      
      Such an error confuses - a user didn't do anything illegal, he
      just used URI like 'login@host:port', without a password after the
      login.
      
      The patch makes the applier use an empty string as a default
      password.
      
      An alternative was to force a user always set a password even if
      it is an empty string, like that: 'login:@host:port'. And if a
      password was not found in an auth request, then reject it with a
      password mismatch error. But in that case a URI of kind
      'login@host:port' becomes useless - it can never pass. In
      addition, netbox already uses an empty string as a default
      password. So the only way to make it consistent, and don't break
      anything - repeat netbox logic for replication URIs.
      
      Closes #4605
      
      Conflicts:
      	test/replication/suite.cfg
      6c01ca48
    • Vladislav Shpilevoy's avatar
      replication: show errno in replication info · 691715b5
      Vladislav Shpilevoy authored
      Box.info.replication shows applier/relay's latest error message.
      But it didn't include errno description for system errors, even
      though it was included in the logs. Now box.info shows the errno
      description as well, when possible.
      
      Closes #4402
      
      Conflicts:
      	test/replication/suite.cfg
      691715b5
    • Vladislav Shpilevoy's avatar
      error: move errno into an error object · 22bbb34f
      Vladislav Shpilevoy authored
      The only error type having an errno as a part of it was
      SystemError (and its descendants SocketError, TimedOut, OOM, ...).
      That was used in logs (SystemError::log() method), and exposed to
      Lua (if type was SystemError, an error object had 'errno' field).
      
      But actually errno might be useful not only there. For example,
      box.info.replication exposes the latest error message of
      applier/relay as 'message' field of 'upstream/downstream' fields,
      lacking errno description.
      
      Before the patch it was impossible to obtain an errno code from C,
      because it was necessary to check whether an error has SystemError
      type, cast to SystemError class, and call SystemError::get_errno()
      method.
      
      Now errno is available as a part of struct error object (available
      from C), and is not 0 for system errors.
      
      Part of #4402
      22bbb34f
    • Vladislav Shpilevoy's avatar
      access: fix invalid error type for not found user · 3a8adccf
      Vladislav Shpilevoy authored
      Box.session.su() raised 'SystemError' when a user was not found
      due to a too long user name. That was obviously wrong, because
      SystemError is always something related to libraries (standard,
      curl, etc), and it has an errno code.
      
      Now a ClientError is raised.
      3a8adccf
    • Vladislav Shpilevoy's avatar
      func: fix use after free on function unload · fa2893ea
      Vladislav Shpilevoy authored
      Functions are stored in lists inside module objects. Module
      objects are stored in a hash table, where key is a package name.
      But the key was a pointer at one of module's function definition
      object. Therefore, when that function was deleted, its freed
      package name memory was still in the hash key, and could be
      accessed, when another function was deleted.
      
      Now module does not use memory of its functions, and keep a copy
      of the package name.
      fa2893ea
    • Serge Petrenko's avatar
      app/fiber: wait till a full event loop iteration ends · 7990d1fa
      Serge Petrenko authored
      fiber.top() fills in statistics every event loop iteration,
      so if it was just enabled, fiber.top() returns zero in fiber cpu
      usage statistics because total time consumed by the main thread was
      not yet accounted for.
      Same stands for viewing top() results for a freshly created fiber:
      its metrics will be zero since it hasn't lived a full ev loop iteration
      yet.
      Fix this by delaying the test till top() results are meaningful and add
      minor refactoring.
      
      Follow-up #2694
      7990d1fa
Loading