Skip to content
Snippets Groups Projects
  1. Apr 26, 2019
  2. Apr 25, 2019
    • Vladislav Shpilevoy's avatar
      swim: optimize memory layout of struct swim_member · e1c94e90
      Vladislav Shpilevoy authored
      Struct swim_member describes attributes of one remote member of
      a SWIM cluster. It is relatively often accessed. And it has two
      huge structures - struct swim_packet ping/ack_task. Each is 1500
      bytes. When these tasks are in the middle of the structure, they
      split and spoil cache lines.
      
      This patch moves the whole failure detection attribute family to
      the bottom of the structure, and moves these two tasks to the
      end of layout.
      e1c94e90
    • Vladislav Shpilevoy's avatar
      swim: introduce suspicion · 8f903360
      Vladislav Shpilevoy authored
      Suspicion component is a way how SWIM protects from
      false-positive failure detections. When the network is slow, or
      a SWIM node does not manage to process messages in time because
      of being overloaded, other nodes will not receive ACKs in time,
      but it is too soon to declare the member dead.
      
      The nodes will mark the member as suspected, and will ping it
      indirectly, via other members. It 1) gives the suspected member
      more time to respond on ACKs, 2) protects from the case when it
      is a network problem on particular channels.
      
      Part of #3234
      8f903360
    • Vladislav Shpilevoy's avatar
      swim: introduce routing · 8c9b88d2
      Vladislav Shpilevoy authored
      Before the patch SWIM packets were being sent quite
      straightforward from one instance to another with transparent
      routing on Internet Level of TCP/IP. But the SWIM paper
      describes last yet not implemented component - suspicion
      mechanism.
      
      So as not to overload this message with suspicion details it is
      enough to say that it makes possible sending a packet through an
      intermediate SWIM instance, not directly.
      
      This commit extends the SWIM protocol with a new transport-level
      section named 'routing'. It allows to send indirect SWIM messages
      transparently via packet forwarding implemented fully inside
      transportation component, in swim_io.c.
      
      Part of #3234
      8c9b88d2
    • Vladislav Shpilevoy's avatar
      swim: store sender UUID in swim io tasks · 776397ba
      Vladislav Shpilevoy authored
      Struct swim_task is an asynchronous task generated by the SWIM
      core and scheduled to be sent when a next EV_WRITE event appears.
      
      It has a callback 'complete' called when the task finally sent
      its packet into the network. In this callback a next SWIM round
      step can be scheduled, or set a deadline for a ping. Usually it
      requires to know to which member the packet was sent. For this
      UUID is required, but swim_task operates by inet addresses only.
      
      At this moment UUID necessity can be bypassed via container_of
      or via some queues, but it is not so once suspicion component is
      introduced.
      
      The patch adds sender's UUID to struct swim_task.
      
      Part of #3234
      776397ba
    • Vladislav Shpilevoy's avatar
      swim: wrap sio_strfaddr() · caeadc15
      Vladislav Shpilevoy authored
      SIO provides a function sio_strfaddr() to obtain string
      representation of an arbitrary struct sockaddr. Call of this
      function usually looks bulky because it requires explicit cast to
      const struct sockaddr *, and expects the address size in the
      second paremeter.
      
      SWIM uses only AF_INET addresses and always casts them to
      const struct sockaddr * + passes sizeof(struct sockaddr_in) to
      each invocation of sio_strfaddr(). This patch wraps
      sio_strfaddr() with a function making these preparations.
      
      Part of #3234
      caeadc15
    • Vladislav Shpilevoy's avatar
      sio: make sio_strfaddr() using tt_static_buf · 84638518
      Vladislav Shpilevoy authored
      Sometimes it is wanted to format multiple addresses and call
      sio_strfaddr() multiple times, but it uses one static thread
      local buffer, and next calls overwrite results of previous ones.
      
      On the contrary, tt_static_buf() is not a single buffer per
      thread - it is 4 buffers. Now sio_strfaddr() uses it and it is
      possible to call it 4 times without rewriting old results.
      
      Also, this update makes .bss section a bit smaller - -1 static
      buffer of size 1025, and +16 bytes for tt_static buffers. Total:
      -1009 bytes.
      84638518
    • Vladislav Shpilevoy's avatar
      swim: drop swim_uuid_str() function · 8770fd5c
      Vladislav Shpilevoy authored
      It appeared  that tt_uuid lib provides the same function:
      tt_uuid_str().
      8770fd5c
    • Vladislav Shpilevoy's avatar
      test: introduce swim packet filter by destination address · 7251efa5
      Vladislav Shpilevoy authored
      The filter is going to be used to test the SWIM suspicion
      component. The destination filter will break certain network
      channels, and the suspicion component shall withstand that.
      
      Part of #3234
      7251efa5
    • Vladislav Shpilevoy's avatar
      test: remove swim packet filter destructors · adb63189
      Vladislav Shpilevoy authored
      Swim test packet filters are supposed to filter out packets
      matching certain criteria or with a probability. They were
      implemented as a filter-function and userdata passed into the
      former on each invocation. Usually it was allocated on heap and
      needed deletion. But it appeared that much simpler is to store
      the filters inside struct swim_node, pass it as userdata, and get
      rid of userdata destructors and dynamic allocations.
      
      The patch is motivated by necessity to add one new filter, which
      anyway will need struct swim_node as userdata.
      adb63189
    • Vladislav Shpilevoy's avatar
      test: rename swim_cluster_node to swim_cluster_member · 1bef21a9
      Vladislav Shpilevoy authored
      There are two different structures - public struct swim_member
      exposed by SWIM API, and struct swim_node defined and used inside
      tests. Before this patch swim_cluster_node() was returning struct
      swim_member, just historically. But more and more places appear
      where it is wanted to safely take struct swim_node, not
      swim_member, with an appropriate assertion on an invalid index.
      
      This patch renames swim_cluster_node() to swim_cluster_member(),
      and introduces new swim_cluster_node() returning swim_node.
      1bef21a9
    • Alexander Turenko's avatar
      travis-ci: add Debian Buster and Ubuntu Disco · d2d85f8a
      Alexander Turenko authored
      Fixes #4174.
      d2d85f8a
    • Kirill Shcherbatov's avatar
      sql: invalid integer type in arithmetic operations · ff846255
      Kirill Shcherbatov authored
      Tarantool SQL used to return 'number' type in request metadata
      for arithmetic operations even when only 'integer's were used.
      
      This also fixes query planner optimisation bug:
      SELECT a FROM t1 WHERE a+0 IN (SELECT a FROM t1);
      used to open a new ephemeral table with OpenTEphemeral when
      it is not required (introduced by 2b22b913).
      
      Closes #4103
      ff846255
    • Kirill Shcherbatov's avatar
      sql: check access rights of table in VIEW · c0ae52e8
      Kirill Shcherbatov authored
      When access is performed using VIEW, access rights should be
      checked against table[s] which it is referencing, not against
      VIEW itself. Added a test case to verify this behaviour.
      
      Closes #4104
      c0ae52e8
    • Kirill Shcherbatov's avatar
      tap: fix is_deeply box.NULL corner cases · 8e337858
      Kirill Shcherbatov authored
      The tap:is_deeply call used to return inconsistent result
      processing an empty tuple and tuple that has no values:
      is_deeply({a = box.NULL}, {})  == true
      is_deeply({}, {a = box.NULL}) == false
      Fixed to return true by default in such case. You may also
      set tap.strict = true to change this behaviour.
      
      @TarantoolBot document
      Title: tap test new flag 'strict'
      In some scenarios it is convenient to distinguish box.NULL and
      nil in tap:is(), tap:isnt(), tap:is_deeply() tests.
      For example, {result='Success'} and {result='Success', error=None}
      are different HTTP responses. You may set t.strict = true to
      behave such way.
      Example:
      t = require('tap').test('123')
      t.strict = true
      t:is_deeply({a = box.NULL}, {}) -- false
      
      Closes #4125
      8e337858
    • Nikita Pettik's avatar
      sql: update ptr to VDBE after its creation in sql_txn · d03c337a
      Nikita Pettik authored
      VDBE object is used in struct sql_txn to add new autoincrement ids in
      sequence_next(). List of these ids is returned later as a query
      execution result. sql_txn is created once SQL statement is executed
      inside transaction and exists till commit or rollback. After its
      creation it contains pointer to current VDBE. Each VDBE is freed after
      statement is executed. Hence, after first SQL statement within
      transaction is executed, sql_txn will point to freed memory (dangling
      pointer). This leads to crash in the next processed statement. Fix to
      this bug is simple: we must re-assign pointer to VDBE in sql_txn before
      VDBE execution.
      
      Closes #4157
      d03c337a
    • Nikita Pettik's avatar
      sql: make <search condition> accept only boolean · 085ba61e
      Nikita Pettik authored
      <search condition> is a predicate used as a part of WHERE and JOIN
      clauses. ANSI SQL states that <search condition> must accept only
      boolean arguments. In our SQL it is implemented as bytecode instruction
      OP_If which in turn carries out logic of conditional jump. Hence this
      patch makes this opcode accept only boolean values.
      
      Closes #3723
      085ba61e
    • Nikita Pettik's avatar
      sql: make LIKE predicate return boolean result · 101f87f5
      Nikita Pettik authored
      According to ANSI, LIKE predicate should return boolean result.
      This patch changes type of return value of LIKE predicate.
      
      Part of #3723
      101f87f5
    • Nikita Pettik's avatar
      sql: make predicates accept and return boolean · cb237e7d
      Nikita Pettik authored
      This patch make following predicates accept and return only values
      of type boolean: IN, EXISTS, OR, AND, NOT, BETWEEN, IS (NULL).
      In terms of approach, it is enough to patch opcodes implementing these
      predicates.
      
      Part of #3723
      cb237e7d
    • Nikita Pettik's avatar
      sql: make comparison predicate return boolean · a57ae24e
      Nikita Pettik authored
      According to ANSI SQL result of comparison predicates must be BOOLEAN.
      Before introduction of BOOLEAN type they returned 0 and 1. Now we can
      change those values to false and true respectively.
      
      Part of #3723
      a57ae24e
    • Nikita Pettik's avatar
      sql: improve type determination for column meta · 8dcea62a
      Nikita Pettik authored
      In most cases we don't assign and store type of node of expression AST
      (except for constant literals).  To determine type of node  we use
      sql_expr_type() function, which implements logic of quite simple
      recursive tree traversal. Before this patch we set type of node after
      code generation in sqlExprCodeTarget() without any traversal. This
      approach is way worse even then sql_expr_type(). So, to improve accuracy
      of type determination, let's always call that method and remove type
      assignment in sqlExprCodeTarget().
      
      Closes #4126
      8dcea62a
    • Nikita Pettik's avatar
      sql: introduce type boolean · 0a8b1791
      Nikita Pettik authored
      This patch introduces basic facilities to operate on boolean type:
      boolean literals "true" and "false" where true > false; alias to null -
      unknown; column type "BOOLEAN" and shortcut "BOOL"; opportunity to
      insert and select boolean values from table; OR and AND predicates
      accept boolean arguments; CAST operation involving boolean type;
      comparison between boolean values (including VDBE sorter routines).
      
      Part of #3648
      0a8b1791
    • Nikita Pettik's avatar
      sql: remove sql_bind_value() function · 0f6d6419
      Nikita Pettik authored
      It is not used (since we dispatch call of sql_bind_*type*() in
      sql_bind_column()), so can be removed.
      0f6d6419
    • Nikita Pettik's avatar
      sql: use msgpack types instead of custom ones · 56e7b657
      Nikita Pettik authored
      This patch provides straightforward refactoring replacing enum sql_type
      with enum mp_type. Note that we use msgpack format instead of field_type
      since it is more suitable when dealing with NULLs.
      56e7b657
    • Nikita Pettik's avatar
      sql: disallow text values participate in sum() aggregate · 3a12e0c3
      Nikita Pettik authored
      It is obvious that we can't add string with number except the case when
      string is a number literal in quotes (aka '123' or '0.5'). Before this
      patch values which can't be converted to numbers were just skipped.
      Now error is raised. This patch also removes sql_value_numeric_type()
      function since it is not used anymore: instead we invoke
      mem_apply_numeric_type().
      3a12e0c3
    • Nikita Pettik's avatar
      sql: refactor mem_apply_numeric_type() · 936a3537
      Nikita Pettik authored
      Fix codestyle according to Tarantool guideline; remove unused argument
      from signature; make function non-static - we are going to use it in
      aggregate function sum() (src/box/sql/func.c) to attempt at converting
      string values to numbers.
      936a3537
  3. Apr 24, 2019
    • Alexander Turenko's avatar
      httpc: temporary disable redirecting test case · 4cc6978a
      Alexander Turenko authored
      Redirects can work improperly with libcurl-7.30 and older. CentOS 7
      provides libcurl-7.29, so app-tap/http_client.test.lua fails on the
      corresponding test case in CI. We need to disable the test case until
      #4180 will be resolved.
      
      While we are here fixed httpd.py to write a response at once, not
      char-by-char (the typo from daf1ced8). See
      gevent/pywsgy.py::process_result().
      
      Related to #4119 and #4180.
      4cc6978a
  4. Apr 23, 2019
    • Шипицын Анатолий's avatar
      httpc: allow to don't auto-follow redirects · daf1ced8
      Шипицын Анатолий authored
      While we are here also added forgotten option descriptions to httpc.lua.
      
      @TarantoolBot document
      Title: httpc: new 'follow_location' option
      
      When the option is set to `true` (which is default) and a response has
      3xx code the http client will automatically issue another request to a
      location that a server sends in 'Location' header. If the new response
      is 3xx again, the http.client will issue a next request and so on in a
      loop until a non-3xx response will be received. This last response will
      be returned as a result.
      
      Setting this option to `false` allows to disable this behaviour. In this
      case the http client will return a 3xx response itself.
      
      See https://curl.haxx.se/libcurl/c/CURLOPT_FOLLOWLOCATION.html
      daf1ced8
    • Kirill Shcherbatov's avatar
      httpc: update client error message · 5ebf9338
      Kirill Shcherbatov authored
      Previously Tarantool used to raise the confusing error message in
      case of invalid usage of the httpc module. Fixed to follow the
      current module API.
      
      Closes #4136
      5ebf9338
    • Kirill Shcherbatov's avatar
      box: fix empty tuple invalid update · 3eac590e
      Kirill Shcherbatov authored
      The tuple:update() used to work incorrectly in case of empty
      tuple produced with box.tuple.new{} because update_create_rope
      unconditionally initialized a new rope with [tuple_data,
      mp_next(tuple_data)] field that might not exists.
      
      Closes #4041
      3eac590e
    • Vladislav Shpilevoy's avatar
      sql: drop a useless check from lookupName() · 5e0ee714
      Vladislav Shpilevoy authored
      There was a variable used as a counter from 0 to
      uint32_t space_def->field_count. Obviously it can't be < 0, but
      there was a check for that. Drop it.
      
      The check was revealed during SQL BOOLEAN review, where one of
      patches gets rid of some explicit Expr.type assignments.
      5e0ee714
    • Roman Khabibov's avatar
      sql: modify TRIM() function signature · f95a34da
      Roman Khabibov authored
      According to the ANSI standard, ltrim, rtrim and trim should
      be merged into one unified TRIM() function. The specialization of
      trimming (left, right or both and trimming characters) determined
      in arguments of this function.
      
      Closes #3879
      
      @TarantoolBot document
      Title: TRIM() function
      
      Modify signature of SQL function TRIM(). This function removes
      characters included in <trim character> (binary) string from
      <trim source> (binary) string until encounter a character that doesn't
      belong to <trim character>. Removal occurs on the side, specified by
      <trim specification>. Now, syntax is following:
      TRIM([ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>).
      
      <trim specification> can be one of the following keywords: LEADING,
      TRAILING and BOTH.
      <trim character> is the set of trimming characters.
      <trim source> is the string, that will be trimmed.
      If FROM is specified, then:
      1) Either <trim specification> or <trim character> or both shall be
      specified.
      2) If <trim specification> is not specified, then BOTH is implicit.
      3) If <trim character> is not specified, then ' ' is implicit.
      f95a34da
    • Mergen Imeev's avatar
      sql: remove unused code from main.c · 7bfbd1cd
      Mergen Imeev authored
      This patch removes part of unused functions and macros from
      main.c. This will facilitate the work of removing SQL error/status
      codes.
      
      Needed for #4074
      7bfbd1cd
  5. Apr 19, 2019
    • Kirill Yukhin's avatar
      sysview: set format for spaces with sysview engine · 5072227e
      Kirill Yukhin authored
      The patch sets format for spaces with sysview engine.
      This is done due to following reasons:
        1. Since an SQL view looks into underneath space's format, set
           it for spaces with sysview engine. Before the patch, spaces
           with sysview enginge didn't have its own tuples and hence
           didn't need to have a format.
        2. To use sysview engine to deal with SQL views. This will allow
           to use sysview machinery to query SQL views from Lua land.
      
      Closes #4111
      5072227e
  6. Apr 18, 2019
    • Vladislav Shpilevoy's avatar
      swim: drop incarnation_inc parameter from update() routines · c9eb277b
      Vladislav Shpilevoy authored
      Update_addr and update_payload need to increment member's
      incarnation when it is self. For that they used a special
      parameter incarnation_inc set in 1 for self and in 0 for others.
      
      It was used to encapsulate incarnation update + event scheduling
      on member attribute updates, but on the other hand it broke
      another encapsulation level - there should not be exceptions for
      'self' in these functions.
      
      This patch makes incarnation increment explicit in the places
      where 'self' is updated.
      c9eb277b
    • Vladislav Shpilevoy's avatar
      swim: introduce payload · dfc4ce43
      Vladislav Shpilevoy authored
      Payload is arbitrary user data disseminated over the cluster
      along with other member attributes.
      
      Part of #3234
      dfc4ce43
    • Vladislav Shpilevoy's avatar
      swim: rename TTL to TTD · 7df5f63f
      Vladislav Shpilevoy authored
      TTL is time-to-live and it slightly confuses when is said about a
      member's attribute. Status_ttl looks like after this value gets
      0 the status is deleted or is no longer valid.
      
      TTD is more precise definition for these counters and is expanded
      as time-to-disseminate.
      7df5f63f
    • Vladislav Shpilevoy's avatar
      swim: do not rebuild packet meta multiple times · d251efe7
      Vladislav Shpilevoy authored
      Before the patch there were 2 cases when an unchanged packet was
      rebuilt partially on each send:
      
        - cached round message's meta section was rebuilt on each
          EV_WRITE event in swim_scheduler_on_output() function;
      
        - broadcast message's meta section was rebuilt too even though
          its content does not depend on a broadcast interface.
      
      The third case appears with indirect pings patch which aggravates
      meta building business by routing and packet forwarding. When a
      packet needs to be forwarded farther, its meta is built in a
      special manner preserving the route before EV_WRITE appears, and
      on_output should not touch that meta.
      
      This patch adds a check preventing unnecessary meta rebuilds.
      Besides, the check and the meta building code are moved into a
      dedicated function out of swim_scheduler_on_output() - it allows
      to completely split logic of packing a message and sending it.
      Separated logic helps a lot when indirect pings are introduced.
      
      Part of #3234
      d251efe7
    • Vladislav Shpilevoy's avatar
      swim: fix a bug with invalidation of round msg in fly · 7a1a8b1c
      Vladislav Shpilevoy authored
      SWIM works in rounds, each split in steps. On step SWIM sends a
      round message. The message is not changed between steps of one
      round usually, and is cached so as not to rebuild it without
      necessity. But when something changes in one member's attributes,
      or in the member table, the message is invalidated to be rebuilt
      on a next step. Invalidation resets the cached packet.
      
      But it leads to a bug, when a round message is already scheduled
      to be sent, however is not actually sent and invalidated in fly.
      Such a message on a next EV_WRITE event will be sent as an empty
      packet, which obviously makes no sense.
      
      On the other hand it would be harmful to cancel the invalidated
      packet if it is in fly, because during frequent changes the
      instance will not send anything.
      
      There are no a test case, because empty packets does not break
      anything, but still they are useless. And, as it is said above,
      such invalidation would prevent sending any round messages when
      there are lots of updates.
      
      Follow up for cf0ddeb8
      (swim: keep encoded round message cached)
      7a1a8b1c
    • Vladislav Shpilevoy's avatar
      swim: extract binary ip/port into a separate struct · b1c77743
      Vladislav Shpilevoy authored
      At this moment there are two binary structures in the SWIM
      protocol carrying an address: swim_member_passport and
      swim_meta_header_bin - one address in each. This code duplication
      was not formidable enough to stimulate creation of a separate
      address structure.
      
      But forthcoming indirect messages protocol extensions will add 2
      new cases of encoding a binary address. It triggered this patch
      to reduce code duplication.
      
      Part of #3234
      b1c77743
Loading