Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-798

Is it a bug that mysql_stmt_ prepare_start and mysql_stmt_ prepare_ct must be the same thread

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 3.4.7
    • None
    • API
    • None
    • win10

    Description

      Do other xxx_start and xxx_comt have the same thread call requirement.

      template <typename Pool, typename Scope>
              static auto async_mysql_stmt_prepare(service_context<Pool, Scope> &ctx,
                                                   char *sql_ptr, std::size_t size)
                  -> ::mcs::execution::task<int>
              {
                  int ret{0};
                  auto *stmt = ctx.key.connect.raw_stmt();
       
                  auto status = ::mysql_stmt_prepare_start(&ret, stmt, sql_ptr, size);
                  auto h = co_await utils::current_coroutine{};
                  auto call_back_impl = [&](int new_status) noexcept {
                      status = new_status;
                      h.resume();
                  };
                  using call_back_impl_type = decltype(call_back_impl);
                  mariadb_poll_callback_object<call_back_impl_type> callback{call_back_impl};
       
                  auto *mysql = ctx.key.connect.data();
                  auto &loop = ctx.key.loop;
                  auto &pool = ctx.pool;
                  auto &counting_scope = ctx.counting_scope;
       
                  while (status != 0)
                  {
                      loop.register_event(::mysql_get_socket(mysql), status, &callback);
                      co_await std::suspend_always{};
      #if 0
      //NOTE: get stuck here. resume from a thread different from the thread of mysql_stmt_prepare_start
                      ex::spawn(ex::starts_on(
                                    pool.get_scheduler(),
                                    ex::just() | ex::then([&]() noexcept {
                                        status = ::mysql_stmt_prepare_cont(&ret, stmt, status);
                                        h.resume();
                                    })),
                                counting_scope.get_token());
                      co_await std::suspend_always{};
      #else
                      // NOTE: OK。The threads of mysql_stmt_prepare_start and mysql_stmt_prepare_cont are the same.
                      status = ::mysql_stmt_prepare_cont(&ret, stmt, status);
      #endif
                  }
                  co_return ret;
              }
      

      Attachments

        Activity

          People

            georg Georg Richter
            9587 mcs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.