Skip to content
Snippets Groups Projects
  1. Mar 10, 2025
  2. Feb 27, 2025
    • Georgy Moshkin's avatar
      fix: backport some commits to fix crash related to window funcs in subqueries · b06e25ff
      Georgy Moshkin authored
      Here's the expression we used to crash on, but now don't:
      ```SQL
      SELECT
        AVG(CAST (a AS decimal))
          FILTER (WHERE a > (SELECT MIN(a) OVER () FROM t1 LIMIT 1))
          OVER ()
      FROM t1;
      ```
      
      Ported code from following sqlite commits:
      
      - c316307315e532a7117183430669f345b75ea402
          Fix problems with using window-functions in correlated sub-queries.
      
      - 6cbb4c936c39acceb7a2181037f2d6e33badc32e
          Enhance the sqlite3ExprCompare() routine so that it knows to compare
          the OVER clause of window functions.
      
      - 38630ae1de36db73c4610348592bf616ac116529
          Assert that if two functions compare equal in every other way, then
          they must both have OVER clauses, or neither has an OVER clause.
          Use this fact to simplify expression comparison.
      
      - eda079cd2c8ac1217574cd372c7bbcf6f651ccab
          Combine the Expr.pTab and Expr.pWin fields into a union named "y".
          Add a new EP_WinFunc property that is only true if Expr.y.pWin is a
          valid pointer. This reduces the size of the Expr object by 8 bytes,
          reduces the overall amount of code, and shaves over 1 million cycles
          off of the speed test.
      
      - a83899754423bea16d4efeb4f39482b57d79c083
          Fix the sqlite3ExprDup() routine so that it makes complete
          duplications of subqueries containing window functions.
      
      NO_DOC=picodata
      NO_CHANGELOG=picodata
      CHECKPATCH_IGNORE=LONG_LINE,SPACING,LINE_SPACING,LOGICAL_CONTINUATIONS
      CHECKPATCH_IGNORE=OPEN_BRACE,CODE_INDENT,BLOCK_COMMENT_STYLE
      CHECKPATCH_IGNORE=LONG_LINE_COMMENT
      b06e25ff
    • Georgy Moshkin's avatar
      ci: add ability to ignore checkpatch error types on a per MR basis · a6522537
      Georgy Moshkin authored
      Add a line like the following so that check patch ignores these types
      of warnings for the current merge request.
      
          CHECKPATCH_IGNORE=LINE_SPACING,SPACING
          CHECKPATCH_IGNORE=LONG_LINE
      
      NO_DOC=ci
      NO_CHANGELOG=ci
      NO_TEST=ci
      a6522537
  3. Feb 26, 2025
  4. Feb 25, 2025
  5. Feb 20, 2025
  6. Feb 18, 2025
    • Georgy Moshkin's avatar
      fix: TK_LINEFEED handling in back-ported code · f23b1343
      Georgy Moshkin authored
      Tarantool has a special token type TK_LINEFEED introduced in commit
      ea958f41 ("sql: display line and position in syntax errors").
      Original sqlite only has the TK_SPACE token, which means that when we
      back-port any code which handles TK_SPACE in any way we must
      also update it to handle TK_LINEFEED appropriately.
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      f23b1343
  7. Feb 13, 2025
  8. Feb 12, 2025
  9. Feb 04, 2025
  10. Jan 28, 2025
    • Dmitry Ivanov's avatar
      feat: auto set box.cfg{checkpoint_enabled=false} on split-brain · e2911d68
      Dmitry Ivanov authored
      Split-brain detector might be triggered by complicated online
      cluster upgrades (e.g. "the quorum promote patch"), so we don't
      want to write inconsistent state to disk.
      
      If there's no inconsistent snapshot, the problem may go away
      once we restart the node with a newer version of Tarantool.
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      e2911d68
    • Dmitry Ivanov's avatar
      feat: add box.cfg.checkpoint_enabled to toggle snapshots on/off · 4cd0b4ae
      Dmitry Ivanov authored
      This patch adds a new control knob to let the user temporarily
      disable Tarantool's ability to create snapshots. This might come
      in useful when performing an online cluster upgrade which is
      known to bring nodes into an inconsistent state, e.g.
      "the quorum promote patch".
      
      Before upgrading, the user is supposed to run
      
      ```
      box.cfg{checkpoint_enabled = false}
      ```
      
      to temporarily disable both scheduled and manual snapshots.
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      4cd0b4ae
    • Maksim Kaitmazian's avatar
      fix: ssl iostream used to return errors without setting them via diag_set · 3352da86
      Maksim Kaitmazian authored and Maksim Kaitmazian's avatar Maksim Kaitmazian committed
      ssl-luatest/replication_test.lua used to fail because there was no error
      set in diag. Actually, the error was set, but in another fiber.
      The erroneous scenario was as follows:
      
      1. A fatal error occurs in one fiber, this fiber poisons iostream with
         SSL_IOSTREAM_POISON flag and reports the error using diag_set.
         This operation fails with an error reported.
      2. Another fiber starts a new operation and discovers that
         SSL_IOSTREAM_POISON is set, so it returns IOSTREAM_ERROR early.
         However, the error was set only in another fiber, not in this one
         (errors are fiber local), so diag_raise fails on the assertion.
      
      This commit resolves this problem by removing poisoning logic. If a
      fatal error occurred, further errors will be reported by opensll,
      not due to the flag.
      It also adds a new flag SSL_SHUTDOWN_MUST_NOT_BE_CALLED,
      which purpose is described in its comment.
      
      Note that the same strategy is used in rust-openssl:
      https://github.com/sfackler/rust-openssl/issues/2334
      
      Closes picodata#890.
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      3352da86
  11. Jan 21, 2025
    • Dmitry Ivanov's avatar
      fix: drop WAL directory lock upon exec() · cdf7a646
      Dmitry Ivanov authored
      Previously, we'd preserve WAL directory lock during exec(), meaning that
      stray child processes would not let us restart the instance:
      
      ```
      E> ER_ALREADY_RUNNING: Failed to lock WAL directory /data and hot_standby mode is off
      F> can't initialize storage: Failed to lock WAL directory /data and hot_standby mode is off
      ```
      
      This patch fixes that by setting O_CLOEXEC for the fd used in flock().
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      cdf7a646
  12. Jan 15, 2025
  13. Jan 10, 2025
  14. Dec 26, 2024
  15. Dec 25, 2024
  16. Dec 11, 2024
    • Dmitry Ivanov's avatar
      fix: don't cpipe_push into a closed pipe in tx_status_update · f90a0242
      Dmitry Ivanov authored
      The bug was discovered during the development of the quorum promote feature
      -- basically, it causes qpromote_several_outstanding_promotes_test.lua
      to fail spontaneously. Furthermore, we suspect that this is the underlying
      cause of lost heartbeats and subsequent severe replication lags.
      
      Long story short, whenever we want to send a message from the TX thread
      back to a relay thread, we should first check if they are still
      connected. Otherwise, we'll see
        * An assertion failure in debug, or
        * (Presumably) a relay hangup in release due to
          `if (status_msg->msg.route != NULL) return;`
          in relay_status_update() -> relay_check_status_needs_update().
      
      The upstream is aware of this issue:
      https://github.com/tarantool/tarantool/issues/9920
      
      Backtrace:
      
      ```
      __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
      0x00007f891f6a5463 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
      0x00007f891f64c120 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      0x00007f891f6334c3 in __GI_abort () at abort.c:79
      0x00007f891f6333df in __assert_fail_base (fmt=0x7f891f7c3c20 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
          assertion=assertion@entry=0x58560077b94b "loop() == pipe->producer", file=file@entry=0x58560077b935 "./src/lib/core/cbus.h", line=line@entry=224,
          function=function@entry=0x58560077b910 "void cpipe_push_input(cpipe*, cmsg*)") at assert.c:94
      0x00007f891f644177 in __assert_fail (assertion=0x58560077b94b "loop() == pipe->producer", file=0x58560077b935 "./src/lib/core/cbus.h", line=224,
          function=0x58560077b910 "void cpipe_push_input(cpipe*, cmsg*)") at assert.c:103
      0x0000585600328782 in cpipe_push_input (pipe=0x58563115dfc8, msg=0x58563115e028) at tarantool/src/lib/core/cbus.h:224
      0x0000585600328802 in cpipe_push (pipe=0x58563115dfc8, msg=0x58563115e028) at tarantool/src/lib/core/cbus.h:241
      0x000058560032a157 in tx_status_update (msg=0x58563115e028) at tarantool/src/box/relay.cc:629
      0x0000585600468d4b in cmsg_deliver (msg=0x58563115e028) at tarantool/src/lib/core/cbus.c:553
      0x0000585600469e50 in fiber_pool_f (ap=0x7f891e8129a8) at tarantool/src/lib/core/fiber_pool.c:64
      0x00005856001be16a in fiber_cxx_invoke(fiber_func, typedef __va_list_tag __va_list_tag *) (f=0x585600469b82 <fiber_pool_f>, ap=0x7f891e8129a8)
          at tarantool/src/lib/core/fiber.h:1283
      0x000058560045f495 in fiber_loop (data=0x0) at tarantool/src/lib/core/fiber.c:1085
      0x0000585600745b8f in coro_init () at tarantool/third_party/coro/coro.c:108
      ```
      
      Relevant frames:
      
      ```
      0x0000585600328782 in cpipe_push_input (pipe=0x58563115dfc8, msg=0x58563115e028) at tarantool/src/lib/core/cbus.h:224
      224             assert(loop() == pipe->producer);
      (gdb)
      0x0000585600328802 in cpipe_push (pipe=0x58563115dfc8, msg=0x58563115e028) at tarantool/src/lib/core/cbus.h:241
      241             cpipe_push_input(pipe, msg);
      (gdb)
      0x000058560032a157 in tx_status_update (msg=0x58563115e028) at tarantool/src/box/relay.cc:629
      629             cpipe_push(&status->relay->relay_pipe, msg);
      (gdb)
      0x0000585600468d4b in cmsg_deliver (msg=0x58563115e028) at tarantool/src/lib/core/cbus.c:553
      553             msg->hop->f(msg);
      (gdb)
      0x0000585600469e50 in fiber_pool_f (ap=0x7f891e8129a8) at tarantool/src/lib/core/fiber_pool.c:64
      64              cmsg_deliver(msg);
      (gdb)
      ```
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      f90a0242
    • Dmitry Ivanov's avatar
      fix: don't close stderr & stdout in log_destroy · 5dce40fd
      Dmitry Ivanov authored
      Previously, log_destroy would close log->fd even if it's one of the
      standard streams. This behavior almost never makes sense, unless
      one's trying to write a unix daemon which is obviously not the case.
      
      Closing stderr has the following side effects:
      - it breaks a reinit of the default logger;
      - it inhibits ASan's final leak report;
      - it causes a EPOLLHUP during a restart via `--entrypoint-fd` (Picodata).
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      5dce40fd
    • Dmitry Ivanov's avatar
      cmake: dump all include directories for box · c3970f07
      Dmitry Ivanov authored
      This stores all of the include directories of box into a file
      called box-include-args. We use this to generate certain FFI
      bindings using rust-bindgen.
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      c3970f07
    • Dmitry Ivanov's avatar
      misc: fix clang-specific warnings in luajit's asserts · f0f0042b
      Dmitry Ivanov authored
      Apparently, clang 18 is not particularly happy about luajit's static
      assert implementation:
      
      ```
      In file included from tarantool/src/box/box.cc:38:
      In file included from tarantool/src/lua/utils.h:47:
      In file included from tarantool/third_party/luajit/src/lj_state.h:9:
      tarantool/third_party/luajit/src/lj_obj.h:488:1: error: variable length arrays in C++ are a Clang extension; did you mean to use 'static_assert'? [-Werror,-Wvla-extension-static-assert]
        488 | LJ_STATIC_ASSERT(offsetof(Node, val) == 0);
            | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      tarantool/third_party/luajit/src/lj_def.h:370:71: note: expanded from macro 'LJ_STATIC_ASSERT'
        370 |   extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
            |                                                                       ^~~~~~~~~~~
      tarantool/third_party/luajit/src/lj_obj.h:488:18: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
        488 | LJ_STATIC_ASSERT(offsetof(Node, val) == 0);
            | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      tarantool/src/trivia/util.h:273:33: note: expanded from macro 'offsetof'
        273 | #define offsetof(type, member) ((size_t) &((type *)0)->member)
            |                                 ^
      tarantool/third_party/luajit/src/lj_def.h:370:72: note: expanded from macro 'LJ_STATIC_ASSERT'
        370 |   extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
            |
      ```
      
      Luckily, we can just mute this.
      
      NO_DOC=<nothing interesting here>
      NO_TEST=<tested during build time>
      NO_CHANGELOG=<nothing interesting here>
      f0f0042b
    • Denis Smirnov's avatar
      fix: check sql statement is not busy on unprepare · a396931b
      Denis Smirnov authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      a396931b
    • Denis Smirnov's avatar
      feat: unprepare statement references after sql execution · 9b09da1f
      Denis Smirnov authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      Picodata SQL now manages the Tarantool statement cache using a
      dedicated SQL fiber that handles preparation and unpreparation of
      statements based on an LRU eviction policy. Prepared statements
      can be executed across different sessions by SQL clients.
      
      Previously, when a client executed a prepared statement, it
      increased the reference count in the statement cache and linked
      the statement to the client's session. While this approach seemed
      fine, it caused issues during eviction, as references to these
      statements remained in client sessions, preventing proper eviction.
      
      This commit addresses the issue by ensuring that if a statement is
      added to the current session during execution, it is removed and
      the session state is restored once execution is complete.
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      9b09da1f
    • Denis Smirnov's avatar
      feat: avoid schema version bump for temporary spaces · 39a95ab7
      Denis Smirnov authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      Temporary spaces, used for cluster-wide SQL data materialization,
      were causing unnecessary netbox schema version bumps, leading to
      schema downloading via netbox, excessive Lua garbage and GC blocks.
      Since these tables are for internal SQL use, we don't need to inform
      netbox clients about schema changes. We now maintain separate schema
      versions: one for netbox clients and one for the internal prepared
      statement cache.
      
      NO_DOC=picodata internal patch
      NO_CHANGELOG=picodata internal patch
      39a95ab7
    • Dmitry Ivanov's avatar
      test(qsync): fix tests and drop the ones incompatible with new RAFT_PROMOTE · 51c8f6f9
      Dmitry Ivanov authored
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      51c8f6f9
    • Dmitry Rodionov's avatar
      test(qsync): add multiple tests for RAFT_PROMOTE queue · 08a1a1e4
      Dmitry Rodionov authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      
      * smoke test that verifies that cluster can be successfully bootstrapped
      * test diverging limbo owner (litmus test)
        - doesn't work on fork master, works with promote chains
      * test aba leader
        - two cases where elected leader fails to deliver promote to others
      * attempt to model 2+2 quorum lowering case
      * two cases with two outstanding promotes
      * use new injections for particular xrow types
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      
      Co-authored-by: default avatarDmitry Ivanov <ivadmi5@gmail.com>
      08a1a1e4
    • Dmitry Ivanov's avatar
      fix(qsync): account for pending RAFT_PROMOTE in box.ctl.wait_rw() · 7569030e
      Dmitry Ivanov authored
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      7569030e
    • Dmitry Ivanov's avatar
      fix(qsync): improve handling of non-ack RAFT_PROMOTE · 8877b105
      Dmitry Ivanov authored
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      8877b105
    • Dmitry Ivanov's avatar
      fix(qsync): on_parameters_change may apply pending RAFT_PROMOTE · 3536ad0c
      Dmitry Ivanov authored
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      3536ad0c
    • Dmitry Ivanov's avatar
    • Dmitry Rodionov's avatar
      feat: tarantoolctl cat now prints more known keys · 2dd91c48
      Dmitry Rodionov authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      
      Co-authored-by: default avatarDmitry Ivanov <ivadmi5@gmail.com>
      2dd91c48
    • Arseniy Volynets's avatar
      fix: wrong sql cache byte counter · 5b97eaa0
      Arseniy Volynets authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      - If you prepare and execute statement with params
      in the projection and then unprepare the
      statement, byte counter may show the wrong value
      or even overflow.
      - The problem is that when we compile sql
      statement, we set parameter type to 'any'.
      But when we execute the statement we set parameter
      type to actual type. Then we use this type in
      calculation of estimated of sql cache entry size.
      This leads to different estimated sizes of cache
      entry during prepare and during unprepare after
      statement was executed
      - Fix this by resetting type to 'any' after
      executing the statement
      
      NO_DOC=picodata internal patch
      NO_CHANGELOG=picodata internal patch
      5b97eaa0
    • Arseniy Volynets's avatar
      refactor: add session id to prepare funcs · 66297e1a
      Arseniy Volynets authored and Dmitry Ivanov's avatar Dmitry Ivanov committed
      BREAKING CHANGE!:
      1. add session id argument to sql_prepare_ext
      2. introduce sql_unprepare_ext function.
      This function removes prepared stmt using
      given session id.
      
      In picodata SQL, we may prepare stmt in one
      session and unprepare it in some
      other session, which does not know in
      what session the statement was prepared. Now
      sql_prepare_ext returns not only statement id,
      but also a session id. This way statement can
      be unprepared from other session using
      sql_unprepare_ext.
      
      NO_DOC=picodata internal patch
      NO_CHANGELOG=picodata internal patch
      66297e1a
Loading