Skip to content
Snippets Groups Projects
  1. Oct 12, 2019
    • Vladislav Shpilevoy's avatar
      replication: recfg with 0 quorum returns immediately · c6bea65f
      Vladislav Shpilevoy authored
      Replication quorum 0 not only affects orphan status, but also,
      according to documentation, makes box.cfg() return immediately
      regardless of whether connections to upstreams are established.
      
      It was not so before the patch. What is worse, even with non 0
      quorum the instance was blocked on reconfiguration for connect
      timeout seconds, if at least one node is not connected.
      
      Now quorum is respected on reconfiguration. On a bootstrap it is
      still impossible to return earlier than
      replication_connect_timeout, because nodes need to choose some
      cluster settings. Too early start would make it impossible -
      cluster's participants will just start and choose different
      cluster UUIDs.
      
      Closes #3760
      c6bea65f
  2. Oct 09, 2019
    • Serge Petrenko's avatar
      replication: add is_orphan field to ballot · dc1e4009
      Serge Petrenko authored
      A successfully fetched remote instance ballot isn't updated during
      bootstrap procedure. This leads to a case when different instances
      choose different masters as their bootstrap leaders.
      
      Imagine such a situation.
      You start instance A without replication set up. Instance A successfully
      bootstraps.
      You also have instances B and C both with replication set up to {A, B,
      C} and replication_connect_quorum set to 3
      You first start instance B. It doesn't proceed to choosing a leader
      until one of the events happens: either the replication_connect_timeout
      runs out, or instance C is up and starts listening on its port.
      B has established connection to A and fetched its ballot, with some
      vclock, say, {1: 1}.
      B retries connection to C every replication_timeout seconds.
      Then you start instance C. Instance C succeeds in connecting to A and B
      right away and bootstraps from instance A. Instance A registers C in its
      _cluster table. This registration is replicated to instance C.
      Meanwhile, instance C is trying to sync with quorum instances (which is
      3), and stays in orphan mode.
      Now replication_timeout on instance B finally runs out. It retries a
      previously unsuccessful connection to C and succeeds. C sends its ballot
      to B with vclock = {1: 2, 2:0} (in our example), since it has already
      incremented it after _cluster registration.
      B sees that C has a greater vclock than A, and chooses to bootstrap from
      C instead of A. C is orphan and rejects B's attempt to join. B dies.
      
      To fix such ungentlemanlike behaviour of C, we should at least include
      loading status in ballot and prefer fully bootstrapped instances to the
      ones still syncing with other replicas.
      We also need to use a separate flag instead of ballot's already existent
      is_ro, since we still want to prefer loading instances over the ones
      explicitly configured to be read-only.
      
      Closes #4527
      dc1e4009
    • Kirill Yukhin's avatar
    • Cyrill Gorcunov's avatar
      box/console: Fix missing variable declaration · df821d0f
      Cyrill Gorcunov authored
      
      During rework of the console lua mode series
      the declaration of variable has been lost and
      this cause test case for remote unix console
      connection to fail.
      
      Fixes issue from c358398c
      
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      df821d0f
  3. Oct 04, 2019
  4. Oct 01, 2019
    • Roman Khabibov's avatar
      Fix 53d43160 · 0b9de586
      Roman Khabibov authored
      0b9de586
    • Roman Khabibov's avatar
      json: clarify bad syntax error messages · 53d43160
      Roman Khabibov authored
      Count lines in the json parsing structure. It is needed to print
      the number of line and column where a mistake was made.
      
      Closes #3316
      
      (cherry picked from commit 9f9bd3eb2d064129ff6b1a764140ebef242d7ff7)
      53d43160
    • Vladislav Shpilevoy's avatar
      app: exit gracefully when a main script throws an error · 157a2d88
      Vladislav Shpilevoy authored
      Code to run main script (passed via command line args, or
      interactive console) has a footer where it notifies systemd,
      logs a happened error, and panics.
      
      Before the patch that code was unreachable in case of any
      exception in a main script, because panic happened earlier. Now a
      happened exception is correctly carried to the footer with proper
      error processing.
      
      A first and obvious solution was replace all panics with diag_set
      and use fiber_join on the script runner fiber. But appeared, that
      the fiber running a main script can't be joined. This is because
      normally it exits via os.exit() which never returns and therefore
      its caller never dies = can't be joined.
      
      The patch solves this problem by passing main fiber diag to the
      script runner by pointer, eliminating fiber_join necessity.
      
      Closes #4382
      157a2d88
  5. Sep 27, 2019
    • Ilya Kosarev's avatar
      test: fix replica expectance in broken lsn test · cd01573c
      Ilya Kosarev authored
      xlog/panic_on_broken_lsn includes waiting for replica and then
      box.info.vclock usage. Sometimes box.info.vclock was giving wrong
      values. Now it is stable due to improved replica expectation
      criterion.
      
      Closes #4508
      cd01573c
  6. Sep 25, 2019
    • Vladislav Shpilevoy's avatar
      app: raise an error on too nested tables serialization · d7a8942a
      Vladislav Shpilevoy authored
      Closes #4434
      Follow-up #4366
      
      @TarantoolBot document
      Title: json/msgpack.cfg.encode_deep_as_nil option
      
      Tarantool has several so called serializers to convert data
      between Lua and another format: YAML, JSON, msgpack.
      
      YAML is a crazy serializer without depth restrictions. But for
      JSON, msgpack, and msgpackffi a user could set encode_max_depth
      option. That option led to crop of a table when it had too many
      nested levels. Sometimes such behaviour is undesirable.
      
      Now an error is raised instead of data corruption:
      
          t = nil
          for i = 1, 100 do t = {t} end
          msgpack.encode(t) -- Here an exception is thrown.
      
      To disable it and return the old behaviour back here is a new
      option:
      
          <serializer>.cfg({encode_deep_as_nil = true})
      
      Option encode_deep_as_nil works for JSON, msgpack, and msgpackffi
      modules, and is false by default. It means, that now if some
      existing users have cropping, even intentional, they will get the
      exception.
      d7a8942a
    • Vladislav Shpilevoy's avatar
      tuple: use global msgpack serializer in Lua tuple · 676369b1
      Vladislav Shpilevoy authored
      Tuple is a C library exposed to Lua. In Lua to translate Lua
      objects into tuples and back luaL_serializer structure is used.
      
      In Tarantool we have several global serializers, one of which is
      for msgpack. Tuples store data in msgpack, and in theory should
      have used that global msgpack serializer. But in fact the tuple
      module had its own private serializer because of tuples encoding
      specifics such as never encode sparse arrays as maps.
      
      This patch makes tuple Lua module use global msgpack serializer
      always. But how does tuple handle sparse arrays now? In fact,
      the tuple module still has its own serializer, but it is updated
      each time when the msgpack serializer is changed.
      
      Part of #4434
      676369b1
    • Vladislav Shpilevoy's avatar
      msgpack: make msgpackffi use encode_max_depth option · 4bb253f7
      Vladislav Shpilevoy authored
      Msgpack Lua module is not a simple set of functions. It is a
      global serializer object used by plenty of other Lua and C
      modules. Msgpack as a serializer can be configured, and in theory
      its configuration updates should affect all other modules. For
      example, a user could change encode_max_depth:
      
          require('msgpack').cfg({encode_max_depth = <new_value>})
      
      And that would make tuple:update() accept tables with <new_value>
      depth without a crop.
      
      But in fact msgpack configuration didn't affect some places, such
      as this one. And all the others who use msgpackffi.
      
      This patch fixes it, for encode_max_depth option. Other options
      are still ignored.
      
      Part of #4434
      4bb253f7
    • Vladislav Shpilevoy's avatar
      app: serializers update now is reflected in Lua · fe4a8047
      Vladislav Shpilevoy authored
      There are some objects called serializers - msgpack, cjson, yaml,
      maybe more. They are global objects affecting both Lua and C
      modules.
      
      A serializer have settings which can be updated. But before the
      patch an update changed only C structure of the serializer. It
      made impossible to use settings of the serializers from Lua.
      
      Now any update of any serializer is reflected both in its C and
      Lua structures.
      
      Part of #4434
      fe4a8047
  7. Sep 24, 2019
    • Alexander V. Tikhonov's avatar
      build: LTO release build fails · c6091b1a
      Alexander V. Tikhonov authored
      LTO build failed because of warnings on the uninitialized
      variables treated as errors:
      
      /mnt/src/box/tuple_update.c: In function ‘do_op_splice’:
      /mnt/src/box/tuple_update.c:764:15: error: ‘str_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         arg->offset = str_len;
                     ^
      /mnt/src/box/tuple_update.c:755:10: note: ‘str_len’ was declared here
        int32_t str_len;
                ^
      /mnt/src/box/tuple_update.c: In function ‘do_op_bit’:
      /mnt/src/box/tuple_update.c:725:12: error: ‘val’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         arg->val &= val;
                  ^
      /mnt/src/box/tuple_update.c:720:11: note: ‘val’ was declared here
        uint64_t val;
                 ^
      /mnt/src/box/tuple_update.c: In function ‘update_read_ops’:
      /mnt/src/box/tuple_update.c:1068:4: error: ‘field_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
          diag_set(ClientError, ER_NO_SUCH_FIELD_NO, field_no);
          ^
      /mnt/src/box/tuple_update.c:1057:10: note: ‘field_no’ was declared here
        int32_t field_no;
                ^
      lto1: all warnings being treated as errors
      
      Fixed by setting variables to 0 value on initializations.
      
      Closed #4512
      c6091b1a
  8. Sep 20, 2019
  9. Sep 19, 2019
    • Alexander V. Tikhonov's avatar
      build: FreeBSD packages installation · 1f2338bd
      Alexander V. Tikhonov authored
      Found that the curl failed to build on FreeBSD with errors:
      gmake[2]: Entering directory '/home/vagrant/tarantool/third_party/curl/src'
        CCLD     curl
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `SSLv23_client_method'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `CONF_modules_free'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `ERR_free_strings'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `sk_value'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `ENGINE_cleanup'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `SSL_library_init'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `EVP_MD_CTX_destroy'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `sk_pop_free'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `SSLeay'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `SSL_get_ex_new_index'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `OPENSSL_add_all_algorithms_noconf'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `SSL_COMP_free_compression_methods'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `EVP_MD_CTX_create'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `EVP_cleanup'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `sk_num'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `sk_pop'
      /usr/local/bin/ld: ../lib/.libs/libcurl.so: undefined reference to `SSL_load_error_strings'
      collect2: error: ld returned 1 exit status
      gmake[2]: *** [Makefile:921: curl] Error 1
      
      Found root cause of the issue at the `./configure <...>` output:
       | checking for OpenSSL headers version... 1.0.2 - 0x1000214fL
       | checking for OpenSSL library version... 1.1.1
       | configure: WARNING: OpenSSL headers and library versions do not match.
      It is seen that the Tarantool bootstrap installed pkg 'openssl'
      of the version '1.0.2', while the currently default FreeBSD 'openssl'
      version was '1.1.1'.
      
      Anyway we don't need any special openssl version installed against
      default one, so the fix is just to remove the openssl package from
      bootstrap installation.
      Also found that some installing packages are not needed too,
      removed it from FreeBSD bootstrap.
      
      Additionally added libiconv library into bootstrap which is needed
      as workaround to avoid of the issue described in:
      	https://github.com/tarantool/tarantool/issues/3791
      
      Closed #4490
      1f2338bd
  10. Sep 18, 2019
    • Roman Khabibov's avatar
      sql: set type flag after varbinary to number cast · 5ba5ed37
      Roman Khabibov authored
      It was forgotten to set MEM_Real flag for VDBE memory containing result
      of varbinary to number cast operation. This patch fixes that and sets
      corresponding flag if the cast takes place.
      
      Closes #4356
      5ba5ed37
    • Roman Khabibov's avatar
      sql: do not print binary data in diag_set() · 9535f09f
      Roman Khabibov authored
      Print the data type instead of the data itself in diag_set() in the case
      of binary data. The reason of this patch is that LibYAML converts whole
      error message to base64 in the case of non-printable symbols.
      
      Part of #4356
      9535f09f
    • Vladislav Shpilevoy's avatar
      tuple: remove some dependencies on struct tuple_update and rope · b9a18871
      Vladislav Shpilevoy authored
      Function do_op_insert() was depending on struct tuple_update
      because of 'region' field. In next patches struct tuple_update
      will be on much more high level of API than do_op_insert and such
      a dependency would be wrong. Drop it.
      
      Functions update_read_ops(), update_finish(),
      tuple_upsert_squash() were depending on update_alloc() function
      intended to be used by rope only. Rope will migrate down to lower
      API in next patches, so this dependency should not exist.
      
      Part of #1261
      b9a18871
    • Vladislav Shpilevoy's avatar
      tuple: update splice should not use index_base after reading args · 74f6a6be
      Vladislav Shpilevoy authored
      Splice was the last operation which used index_base in its do_op()
      function. Now none of the operations use it. This allows to drop
      dependency of operation implementations on index_base and on the
      whole tuple_update, in next patches.
      
      Part of #1261
      74f6a6be
    • Vladislav Shpilevoy's avatar
      tuple: rework update error reporting · bae634bb
      Vladislav Shpilevoy authored
      - Unify error code names, they all should start with ER_UPDATE_*;
      
      - Use string field identifier in error messages, because soon they
        will support both field numbers and JSON paths;
      
      - Report all field numbers 1-based. This simplifies error analysis
        because no need to think from where an update has come - Lua or
        C/iproto. Also it allows to drop index_base argument from many
        functions;
      
      - Introduce helper functions to set commonly appearing errors.
        Currently it is not a problem, but next patches will add several
        new files in all of which the same errors can happen;
      
      - Deletion checks that number of fields to delete is > 0 right
        after reading the argument, not during deletion appliance. It
        allows to make such check in only one place even when more
        delete implementations will appear;
      
      - make_arith_operation now takes update_op as an argument
        explicitly, not teared into separate arguments. It allows to use
        error helpers. Also dead code is dropped from this function with
        incorrect usage of some of errors;
      
      Part of #1261
      bae634bb
    • Vladislav Shpilevoy's avatar
      tuple: expose JSON go_to_key and go_to_index functions · d5c8298d
      Vladislav Shpilevoy authored
      They are needed in JSON path update for a case, when a final part
      of the path may not exist, and go_to_path returns an error.
      
      That case is '=' and '!' on not existing fields. For example,
      in {'=', '[1][2][3]', 20} field [3] can be not existing.
      
      For these cases JSON update will have its own implementation of
      go_to_path allowing optional last field.
      
      Needed for #1261
      d5c8298d
  11. Sep 17, 2019
    • Mergen Imeev's avatar
      sql: make valueToText() operate on MAP/ARRAY values · 736cdd81
      Mergen Imeev authored
      Since ARRAY and MAP cannot be converted to SCALAR type, this
      operation should throw an error. But when the error is raised in
      SQL, it is displayed in unreadable form. The reason for this is
      that the given array or map is not correctly converted to a
      string. This patch fixes the problem by converting ARRAY or MAP to
      their string representation.
      For example:
      
      box.execute('CREATE TABLE t1(i INT PRIMARY KEY, a SCALAR);')
      format = {}
      format[1] = {type = 'integer', name = 'I'}
      format[2] = {type = 'array', name = 'A'}
      s = box.schema.space.create('T2', {format=format})
      i = s:create_index('ii')
      s:insert({1, {1,2,3}})
      box.execute('INSERT INTO t1 SELECT * FROM t2;')
      
      Should return:
      - error: 'Type mismatch: can not convert [1, 2, 3] to scalar'
      
      Follow-up #4189
      736cdd81
    • Mergen Imeev's avatar
      sql: add ARRAY, MAP and ANY types to mem_apply_type() · de79b714
      Mergen Imeev authored
      Function mem_apply_type() implements implicit type conversion. As
      a rule, tuple to be inserted to the space is exposed to this
      conversion which is invoked during execution of OP_MakeRecord
      opcode (which in turn forms tuple). This function was not adjusted
      to operate on ARRAY, MAP and ANY field types since they are poorly
      supported in current SQL implementation. Hence, when tuple to be
      inserted in space having mentioned field types reaches this
      function, it results in error. Note that we can't set ARRAY or MAP
      types in SQL, but such situation may appear during UPDATE
      operation on space created via Lua interface. This problem is
      solved by extending implicit type conversions with obvious casts:
      array field can be casted to array, map to map and any to any.
      
      Closes #4189
      de79b714
    • Maria's avatar
      Proper error handling for fio.mktree · 8ccfc691
      Maria authored
      Method fio.mktree is used to create given path unconditionally -
      without checking if it was a directory or something else. This
      led to inappropriate error messages or even inconsistent behavior.
      Now check the type of a given path.
      
      Closes #4439
      8ccfc691
  12. Sep 16, 2019
    • Roman Khabibov's avatar
      sql: allow to create view as <WITH> clause · 38bb4caa
      Roman Khabibov authored
      Allow views to use CTEs, which can be in any (nested) select after
      <AS>. Before this patch, during view creation all referenced
      spaces were fetched by name from SELECT and their reference
      counters were incremented to avoid dangling references. It
      occurred in update_view_references(). Obviously, CTE tables
      weren't held in space cache, ergo error "space doesn’t exist" was
      raised. Add check if a space from FROM is CTE. If it is, don't
      increment its reference counter and don't raise the error.
      
      Closes #4149
      38bb4caa
    • Oleg Babin's avatar
      rocks: fix zero values in ziptime · 3658cb00
      Oleg Babin authored
      If the rock was packed with luarocks then the time in it is set to zeros
      and this is not the case with the unix format can be removed when date given
      is added to zipwriter_open_new_file_in_zip (luarocks/luarocks#1056)
      
      Closes #4481
      3658cb00
    • Nikita Pettik's avatar
      sql: swap FK masks during altering of space · 33236ecc
      Nikita Pettik authored
      It was forgotten to swap old and new mask (holding fields involved into
      foreign key relation) during space alteration (lists of object
      representing FK metadata are swapped successfully). Since mask is vital
      and depending on its value different byte-codes implementing SQL query
      can be produced, this mistake resulted in assertion fault in debug build
      and wrong constraint check in release build. Let's fix this bug and swap
      masks as well as foreign key lists.
      
      Closes #4495
      33236ecc
    • Nikita Pettik's avatar
      sql: remove ENGINE from list of reserved keywords · 07618dad
      Nikita Pettik authored
      ENGINE became reserved keyword in 1013a744. There's no any actual
      reason why ENGINE should be reserved keyword. What is more, we are going
      to use this word as a name of some fields for tables forming
      informational schema. Hence, until it is too late (it is not documented
      yet), let's remove ENGINE from the list of reserved keywords and allow
      identifiers be that word.
      07618dad
  13. Sep 13, 2019
    • Vladimir Davydov's avatar
      relay: join new replicas off read view · 6332aca6
      Vladimir Davydov authored
      Historically, we join a new replica off the last checkpoint. As a
      result, we must always keep the last memtx snapshot and all vinyl data
      files corresponding to it. Actually, there's no need to use the last
      checkpoint for joining a replica. Instead we can use the current read
      view as both memtx and vinyl support it. This should speed up the
      process of joining a new replica, because we don't need to replay all
      xlogs written after the last checkpoint, only those that are accumulated
      while we are relaying the current read view. This should also allow us
      to avoid creating a snapshot file on bootstrap, because the only reason
      why we need it is allowing joining replicas. Besides, this is a step
      towards decoupling the vinyl metadata log from checkpointing in
      particular and from xlogs in general.
      
      Closes #1271
      6332aca6
    • Alexander Turenko's avatar
      lua: pwd: split data fetch from deserialization · 6c5d3f06
      Alexander Turenko authored
      This commit does not change a user visible behaviour. It refactors pwd
      module to explicitly divide code that fetches data from passwd / group
      databases from code that performs deserialization of the data to Lua
      tables.
      
      The idea of splitting of those actions appears when it was observed that
      a call of getpw() / getgr() leads to problems on some systems when it is
      invoked during passwd / group database traveral.
      
      Now it is more obvious that we don't call getpw() during passwd
      traversal and getgr() during group traveral.
      
      Follows up #4428 and #4447.
      6c5d3f06
Loading