Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer reset the indexes error #30

Closed
liangyongrui opened this issue Jan 6, 2020 · 2 comments
Closed

buffer reset the indexes error #30

liangyongrui opened this issue Jan 6, 2020 · 2 comments
Assignees
Labels

Comments

@liangyongrui
Copy link

liangyongrui commented Jan 6, 2020

dependencies

[dependencies.sqlx]
git = 'https://github.com/launchbadge/sqlx.git'
features = ['mysql']

code

sqlx::query(
        "SELECT ... from ...
        where id = ?",
    )
    .bind(id)
    .fetch_optional(&mut *conn)
    .await?
    .map(|row| .......)

error backtrace

thread 'test_schedule_job' panicked at 'assertion failed: `(left == right)`
  left: `8174`,
 right: `8192`', /Users/liangyongrui/.cargo/git/checkouts/sqlx-f05f33ba4f5c3036/5c532a8/sqlx-core/src/io/buf_stream.rs:77:17
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::continue_panic_fmt
   7: std::panicking::begin_panic_fmt
   8: sqlx_core::io::buf_stream::BufStream<S>::peek::{{closure}}
   9: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  10: std::future::set_task_context
  11: <std::future::GenFuture<T> as core::future::future::Future>::poll
  12: std::future::poll_with_tls_context::{{closure}}
  13: std::future::get_task_context
  14: std::future::poll_with_tls_context
  15: sqlx_core::mysql::connection::MySqlConnection::try_receive::{{closure}}
  16: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  17: std::future::set_task_context
  18: <std::future::GenFuture<T> as core::future::future::Future>::poll
  19: std::future::poll_with_tls_context::{{closure}}
  20: std::future::get_task_context
  21: std::future::poll_with_tls_context
  22: sqlx_core::mysql::connection::MySqlConnection::receive::{{closure}}
  23: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  24: std::future::set_task_context
  25: <std::future::GenFuture<T> as core::future::future::Future>::poll
  26: std::future::poll_with_tls_context::{{closure}}
  27: std::future::get_task_context
  28: std::future::poll_with_tls_context
  29: sqlx_core::mysql::executor::<impl sqlx_core::mysql::connection::MySqlConnection>::prepare_with_cache::{{closure}}
  30: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  31: std::future::set_task_context
  32: <std::future::GenFuture<T> as core::future::future::Future>::poll
  33: std::future::poll_with_tls_context::{{closure}}
  34: std::future::get_task_context
  35: std::future::poll_with_tls_context
  36: sqlx_core::mysql::executor::<impl sqlx_core::mysql::connection::MySqlConnection>::fetch::{{closure}}
  37: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  38: std::future::set_task_context
  39: <std::future::GenFuture<T> as core::future::future::Future>::poll
  40: <async_stream::async_stream::AsyncStream<T,U> as futures_core::stream::Stream>::poll_next
  41: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
  42: <S as futures_core::stream::TryStream>::try_poll_next
  43: futures_util::stream::try_stream::TryStreamExt::try_poll_next_unpin
  44: <futures_util::stream::try_stream::try_next::TryNext<St> as core::future::future::Future>::poll
  45: std::future::poll_with_tls_context::{{closure}}
  46: std::future::get_task_context
  47: std::future::poll_with_tls_context
  48: sqlx_core::executor::Executor::fetch_optional::{{closure}}
  49: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  50: std::future::set_task_context
  51: <std::future::GenFuture<T> as core::future::future::Future>::poll
  52: <core::pin::Pin<P> as core::future::future::Future>::poll
  53: std::future::poll_with_tls_context::{{closure}}
  54: std::future::get_task_context
  55: std::future::poll_with_tls_context
  56: sqlx_core::query::Query<DB,P>::fetch_optional::{{closure}}
  57: <std::future::GenFuture<T> as core::future::future::Future>::poll::{{closure}}
  58: std::future::set_task_context
  59: <std::future::GenFuture<T> as core::future::future::Future>::poll
  60: std::future::poll_with_tls_context::{{closure}}
  61: std::future::get_task_context
  62: std::future::poll_with_tls_context
...

buf_stream.rs 77:17

            // If we are out of space to write to in the read buffer,
            // we reset the indexes
            if self.rbuf.len() < (self.rbuf_windex + cnt) {
                // TODO: This assumes that all data is consumed when we need to re-allocate
                debug_assert_eq!(self.rbuf_rindex, self.rbuf_windex);

                self.rbuf_rindex = 0;
                self.rbuf_windex = 0;
            }
@mehcode mehcode added the bug label Jan 6, 2020
@mehcode mehcode self-assigned this Jan 6, 2020
@mehcode mehcode closed this as completed in 92f3f8c Jan 6, 2020
@mehcode
Copy link
Member

mehcode commented Jan 6, 2020

Thanks for reporting. This looks like a simple oversight as master was clearly unfinished there. I finished the implementation there and added a test to make sure it works.

@mehcode
Copy link
Member

mehcode commented Jan 6, 2020

Release as v0.1.3

losfair pushed a commit to losfair/sqlx that referenced this issue Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants