Skip to content
Snippets Groups Projects
  1. Jun 29, 2018
  2. Jun 28, 2018
    • Kirill Yukhin's avatar
      sql: enable basic SELECTs for Lua created tables · 78efac86
      Kirill Yukhin authored
      Update expander of SELECT statement to search for space if
      corresponding table wasn't found in table hash. Create dummy
      table if so and fill def field only.
      
      Also fix a leak in VIEW creation.
      
      Part of #3369
      78efac86
  3. Jun 27, 2018
  4. Jun 26, 2018
    • Vladimir Davydov's avatar
      vinyl: fix read iterator skips source after reading cache · 13f4355c
      Vladimir Davydov authored
      If a source is used on a read iteration (i.e. the key at which it is
      positioned is the next best match or, in terms of the read iterator
      implementation, its front_id matches the read iterator front_id), its
      history is cleaned up, see vy_read_iterator_apply_history(). This breaks
      the logic behind vy_read_src_is_behind(), which assumes that the history
      always points to the last used key. As a result, a source may be
      mistakenly skipped, as illustrated below:
      
        Fiber 1                               Fiber 2
        -------                               -------
        1. Opens read iterator.
        2. Advances it to the next key.
           The returned key was read from
           a mem or run (not from cache).
           The source's history is emptied.
                                              Adds a chain containing
                                              the key read by fiber 1
                                              to the cache.
        3. Continues iteration, reads
           next few keys from the cache
           until the chain ends. The source
           used at step 2 is skipped.
        4. Calls vy_read_src_is_behind()
           on the source used at step 2 and
           skipped at step 3. It returns
           false, because its history is
           empty, thus skipping keys stored
           in it.
      
      Fix this bug by moving the code that checks whether a source iterator
      needs to be advanced from vy_read_src_is_behind() to source iterator
      'skip' method, because there we always know the last key returned by
      the iterator.
      
      Basically, this returns the code we had before commit b4d57284
      ("vinyl: consolidate skip optimization checks in read iterator").
      
      Closes #3477
      13f4355c
    • Georgy Kirichenko's avatar
      Introduce privileges for object groups · af35de96
      Georgy Kirichenko authored
      Allow define access privileges for all spaces, functions and sequences.
      Read and write privileges are supported for spaces, execute privilege
      for sequences. Privilege granting and revoking might be done through old api
      without object identification:
        box.schema.user.grant("guest", "read", "space")
      
      Prerequisite #945
      af35de96
    • Vladislav Shpilevoy's avatar
      Fix multiline lua console · 3dd0db6b
      Vladislav Shpilevoy authored
      3dd0db6b
    • Konstantin Osipov's avatar
      schema: misc changes to improve code readability · 4aaefbe4
      Konstantin Osipov authored
      Use constants, rename methods, invert acl-object
      compatibility matrix.
      
      In scope of gh-945.
      4aaefbe4
    • imarkov's avatar
      security: add limits on object_type-privilege pair · 983c194e
      imarkov authored
      Introduce constraints on object_type-privilege pairs.
      These constraints limit senseless grants/revokes, i.e.,
      sequence - execute, all space related privileges(insert, delete,
      update),
      function - alter, all space related privileges,
      role - all privileges except create, drop, alter, execute
      
      Prerequisite #945
      983c194e
    • Kirill Shcherbatov's avatar
      sql: fix tests failures on concurrent run. · 09e08964
      Kirill Shcherbatov authored
      Resolves #3472.
      09e08964
  5. Jun 25, 2018
    • Konstantin Osipov's avatar
      Merge branch '1.9' into 1.10 · 3ec12041
      Konstantin Osipov authored
      3ec12041
    • Vladimir Davydov's avatar
      socket: fix race between unix tcp server stop and start · 80d379ee
      Vladimir Davydov authored
      If called on a unix socket, bind(2) creates a new file, see unix(7).
      When we stop a unix tcp server, we should remove that file. Currently,
      we do it from the tcp server fiber, after the server loop is broken,
      which happens when the socket is closed, see tcp_server_loop(). This
      opens a time window for another tcp server to reuse the same path:
      
          main fiber                  tcp server loop
          ----------                  ---------------
      
          -- Start a tcp server.
          s = socket.tcp_server('unix/', sock_path, ...)
          -- Stop the server.
          s:close()
      
                                      socket_readable? => no, break loop
      
          -- Start a new tcp server. Use the same path as before.
          -- This function succeeds, because the socket is closed
          -- so tcp_server_bind_addr() will clean up by itself.
          s = socket.tcp_server('unix/', sock_path, ...)
      
           tcp_server_bind
            tcp_server_bind_addr
             socket_bind => EADDRINUSE
             tcp_connect => ECONNREFUSED
             -- Remove dead unix socket.
             fio.unlink(addr.port)
             socket_bind => success
      
                                      -- Deletes unix socket used
                                      -- by the new server.
                                      fio.unlink(addr.port)
      
      In particular, the race results in sporadic failures of app-tap/console
      test, which restarts a tcp server using the same file path.
      
      To fix this issue, let's close the socket after removing the socket
      file. This is absolutely legit on any UNIX system, and this eliminates
      the race shown above, because a new server that tries to bind on the
      same path as the one already used by a dying server will not receive
      ECONNREFUSED until the socket fd is closed and hence the file is
      removed.
      
      A note about the app-tap/console test. After this patch is applied,
      socket.close() takes a little longer for unix tcp server, because it
      yields twice, once for removing the socket file and once for closing the
      socket file descriptor. As a result, on_disconnect() trigger left from
      the previous test case has time to run after session.type() check.
      Actually, those triggers have already been tested and we should have
      cleared them before proceeding to the next test case. So instead of
      adding two new on_disconnect checks to the test plan, let's clear the
      triggers before session.type() test case and remove 3 on_connect and 5
      on_auth checks from the test plan.
      
      Closes #3168
      80d379ee
    • Konstantin Osipov's avatar
    • Vladislav Shpilevoy's avatar
      iproto: protect from false-correct size in msg header · c6951c92
      Vladislav Shpilevoy authored
      Consider this packet:
      
          msgpack = require('msgpack')
          data = msgpack.encode(18400000000000000000)..'aaaaaaa'
      
      Tarantool interprets 18400000000000000000 as size of a coming
      iproto request, and tries with no any checks to allocate buffer
      of such size. It calculates needed capacity like this:
      
          capacity = start_value;
          while (capacity < size)
              capacity *= 2;
      
      Here it is possible that on i-th iteration 'capacity' < 'size',
      but 'capacity * 2' overflows 64 bits and becomes < 'size' again,
      so this loop never ends and occupies 100% CPU.
      
      Strictly speaking overflow has undefined behavior. On the
      original system it led to nullifying 'capacity'.
      
      Such size is improbable as a real packet gabarits, but can appear
      as a result of parsing of some invalid packet, first bytes of
      which accidentally appears to be valid MessagePack uint. This is
      how the bug emerged on the real system.
      
      Lets restrict the maximal packet size to 2GB.
      
      Closes #3464
      c6951c92
  6. Jun 24, 2018
    • Mergen Imeev's avatar
      box: create bigrefs for tuples · 3768d4bb
      Mergen Imeev authored
      Due to limitation of reference counters for tuple being only
      65535 it was possible to reach this limitation. This patch
      increases capacity of reference counters to 4 billions.
      
      Closes #3224
      3768d4bb
  7. Jun 22, 2018
  8. Jun 21, 2018
    • Kirill Shcherbatov's avatar
      sql: drop useless legacy Cursor hints · 54c1e08a
      Kirill Shcherbatov authored
      Deleted BTREE_BULKLOAD and OPFLAG_BULKCSR as they become
      useless since btree.c was dropped as a part of #2419.
      Removed SQLITE_ENABLE_CURSOR_HINTS sections as this code
      has never been in use.
      Start use OPFLAG_SEEKEQ instead of equal BTREE_SEEK_EQ as
      this macro name has no sense since no btree present in SQL.
      
      Resolves #3121.
      54c1e08a
  9. Jun 19, 2018
    • Nikita Pettik's avatar
      sql: remove complete.c · e44cdf58
      Nikita Pettik authored
      e44cdf58
    • Nikita Pettik's avatar
      sql: remove OMIT_VIEW defines · d34eb660
      Nikita Pettik authored
      In Tarantool VIEWs are always enabled, so there is no need for such
      ifdef guards. This patch simply removes them.
      d34eb660
    • Nikita Pettik's avatar
      sql: rework VIEW internals · dc358cb0
      Nikita Pettik authored
      This patch significantly reworks VIEW mechanisms.
      Firstly, names resolution for VIEW now occurs during its creation.
      In other words, we can't run following code, since name T1 doesn't exist
      at the moment of V1 creation:
      
      CREATE VIEW v1 AS SELECT * FROM t1;
      CREATE TABLE t1(id PRIMARY KEY);
      
      Now, table t1 must be created before view. As a result, no circularly
      defined views are allowed. Moreover, it means that space representing
      view is created with appropriate field names, types, collations etc.
      
      Also, introduced view reference counter for each space. It is
      incremented for each space participating in select statement.
      For instace:
      
      CREATE VIEW v1 AS SELECT * FROM (SELECT * FROM t1, t2);
      
      In this case, view reference counter is increased for spaces T1 and T2.
      Similarly, such counter is decremented for all dependent spaces when
      VIEW is dropped.  To support such behavior, auxiliary
      on_commit triggers are added. However, it is still not enough, since
      before dropping space itself, we must drop secondary indexes, clear
      _sequence space etc. Such changes can't be rollbacked (due to the lack
      of transactional DDL), so before executing DROP routine, special opcode
      OP_CheckViewReferences checks view reference counter for space to be
      dropped.
      
      Finally, we don't hold struct Select in struct Table or anywhere else
      anymore.  Instead, 'CREATE VIEW AS SELECT ...' string is stored in
      def->opts.sql.  At compilation time of query on view
      (such as 'SELECT * FROM v1;') this string is parsed once and loaded
      into struct Select, which in turn is used as before.
      
      Fixed tests where view was created prior to referenced table.
      
      Closes #3429, #3368, #3300
      dc358cb0
    • Nikita Pettik's avatar
      sql: remove redundant goto from VDBE prologue · df245de9
      Nikita Pettik authored
      Structure of VDBE prologue:
      
          0: OP_Init 0 N (address to start) 0 --|
      |-> 1: ...                                |
      |      ...                                |
      |   N: OP_Transaction         <------------
      |   N+1: (Constant expressions to be saved in registers)
      |      ...
      |-- M: OP_Goto 0 1 0
      
      However, last opcode in VDBE program (i.e. OP_Goto) is generated always,
      despite the existence of OP_Transaction or constant expressions.
      Thus, VDBE program for queries like <SELECT * FROM table;> features
      redundant jump. Such useless jump wastes exectuion time (although it is
      executed once) and may affect jump prediction.
      
      This patch adds conditional branch for generating jump opcode finishing
      VDBE program: it is appended only if we need to start transaction or
      code constrant expressions.
      
      Closes #3231
      df245de9
    • Nikita Pettik's avatar
      sql: review fixes for a4028705 · e0ec7756
      Nikita Pettik authored
      e0ec7756
  10. Jun 15, 2018
  11. Jun 14, 2018
    • Vladislav Shpilevoy's avatar
      Merge branch '1.10' into 2.0 · 3b6d9661
      Vladislav Shpilevoy authored
      3b6d9661
    • Vladislav Shpilevoy's avatar
      session: fix box.session.sync() · 6cc31e04
      Vladislav Shpilevoy authored
      Before the patch box.session.sync() is global for the session and
      is updated on each new iproto request. When the connection is
      multiplexed, box.session.sync() can be changed with no finishing
      a current request, if a new one arrives.
      
      The patch makes box.session.push() local for the request,
      protecting it from multiplexing mess. Box.session.sync() after
      the patch can be safely used inside a request.
      
      Closes #3450
      
      @TarantoolBot document
      Title: box.session.sync() became request local
      Box.session.sync() was global for a session, so it was unusable
      when the connection behind the session is multiplexed. Now
      box.session.sync() is request local and can be safely used inside
      the request processor.
      6cc31e04
    • Vladislav Shpilevoy's avatar
      fiber: remove fiber local storage · 766feac2
      Vladislav Shpilevoy authored
      Replace it with more specific structures and pointers in order to
      prepare to add `net` storage.
      
      This allows to make the code working with fiber storage simpler,
      remove useless wrappers and casts, and in the next patch - remove
      broken session.sync and add fiber sync.
      
      Note that under no circumstances fiber.h is allowed to include
      application-specific headers like session.h or txn.h. One only
      is allowed to announce a struct and add opaque pointer to it.
      766feac2
    • Vladimir Davydov's avatar
      Merge branch '1.9' into 1.10 · 57ea7669
      Vladimir Davydov authored
      57ea7669
    • Vladimir Davydov's avatar
      memtx: don't delay deletion of temporary tuples during snapshot · f9299c43
      Vladimir Davydov authored
      Since tuples stored in temporary spaces are never written to disk, we
      can always delete them immediately, even when a snapshot is in progress.
      
      Closes #3432
      f9299c43
    • Vladimir Davydov's avatar
      Remove unused space_noop · 93ed36ea
      Vladimir Davydov authored
      93ed36ea
    • Kirill Yukhin's avatar
      sql: implement point where for DELETE stmts · a4028705
      Kirill Yukhin authored
      This patch implements support of SQL's DELETE statemets
      which a accompanied by point WHERE point constraints.
      This patch doesn't support any kinds of nested selects
      or JOINs.
      
      Part of #3235
      a4028705
    • Kirill Yukhin's avatar
      sql: remove expressions from SQL indexes · 11c9d68c
      Kirill Yukhin authored
      Legacy SQL FE was able to create indexes w/ expressions.
      Tarantool will employ diofferenct scheme to implement
      functional indexes, thus code  handling it in SQL FE is
      dead and redundant. Remove it.
      
      Part of #3235
      11c9d68c
Loading