You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ever since upgrading to v3.0.0, I've been seeing pr-tracker-fetcher take a really long time to insert landings. For example, here's some info about a current run:
[nix-shell:~]# strace -p 3570312
strace: Process 3570312 attached
epoll_wait(4,
And some gdb information on the rust process. It seems to be in the middle of doing some string formatting in the guts of sqlx:
[nix-shell:~]# gdb -p 3570307
...
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f41a85f1dc0 (LWP 3570307) ".pr-tracker-fet" 0x0000560955f4c06e in <core::iter::adapters::take::Take<I> as core::iter::traits::iterator::Iterator>::next ()
2 Thread 0x7f41a85ed6c0 (LWP 3570308) "tokio-runtime-w" 0x00007f41a86fd1e6 in epoll_wait ()
from /nix/store/ddwyrxif62r8n6xclvskjyy6szdhvj60-glibc-2.39-5/lib/libc.so.6
3 Thread 0x7f41a83ec6c0 (LWP 3570309) "tokio-runtime-w" 0x00007f41a86facfd in syscall ()
from /nix/store/ddwyrxif62r8n6xclvskjyy6szdhvj60-glibc-2.39-5/lib/libc.so.6
4 Thread 0x7f41a01e86c0 (LWP 3570310) "tokio-runtime-w" 0x00007f41a86facfd in syscall ()
from /nix/store/ddwyrxif62r8n6xclvskjyy6szdhvj60-glibc-2.39-5/lib/libc.so.6
5 Thread 0x7f41a3fff6c0 (LWP 3570311) "tokio-runtime-w" 0x00007f41a86facfd in syscall ()
from /nix/store/ddwyrxif62r8n6xclvskjyy6szdhvj60-glibc-2.39-5/lib/libc.so.6
(gdb) thread apply 1 bt
Thread 1 (Thread 0x7f41a85f1dc0 (LWP 3570307) ".pr-tracker-fet"):
#0 0x0000560955f4c06e in <core::iter::adapters::take::Take<I> as core::iter::traits::iterator::Iterator>::next ()
#1 0x0000560955f4c56c in <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter ()
#2 0x0000560955f524b1 in sqlformat::tokenizer::get_uc_words ()
#3 0x0000560955f4e988 in sqlformat::tokenizer::tokenize ()
#4 0x0000560955f4c709 in sqlformat::format ()
#5 0x0000560955f3f424 in sqlx_core::logger::QueryLogger::finish ()
#6 0x0000560955cb59f5 in sqlx_postgres::connection::executor::<impl sqlx_postgres::connection::PgConnection>::run::{{closure}}::{{closure}}::{{closure}} ()
#7 0x0000560955cd6fb4 in <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll ()
#8 0x0000560955cd707d in <sqlx_core::ext::async_stream::TryAsyncStream<T> as futures_core::stream::Stream>::poll_next ()
#9 0x0000560955cb13e7 in sqlx_postgres::connection::executor::<impl sqlx_core::executor::Executor for &mut sqlx_postgres::connection::PgConnection>::fetch_many::{{closure}}::{{closure}} ()
#10 0x0000560955cd6fb4 in <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll ()
#11 0x0000560955cd707d in <sqlx_core::ext::async_stream::TryAsyncStream<T> as futures_core::stream::Stream>::poll_next ()
#12 0x0000560955cf32b4 in <futures_util::stream::try_stream::try_filter_map::TryFilterMap<St,Fut,F> as futures_core::stream::Stream>::poll_next ()
#13 0x0000560955cbb54e in <futures_util::stream::try_stream::try_collect::TryCollect<St,C> as core::future::future::Future>::poll ()
#14 0x0000560955cee7c4 in sqlx_core::query::Query<DB,A>::execute::{{closure}} ()
#15 0x0000560955ce2c08 in pr_tracker_fetcher::run::{{closure}} ()
#16 0x0000560955ced842 in tokio::runtime::park::CachedParkThread::block_on ()
#17 0x0000560955cc2bea in tokio::runtime::context::runtime::enter_runtime ()
#18 0x0000560955ce0003 in pr_tracker_fetcher::main ()
#19 0x0000560955ceed23 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#20 0x0000560955d1800d in std::rt::lang_start::{{closure}} ()
#21 0x00005609561ff021 in std::rt::lang_start_internal ()
#22 0x0000560955ce019c in main ()
Theory: under the hood, sqlx "streams" its output to postgresql, which is why we see the query over in postgresql, but it's still streaming the query, so postgresql has nothing to do.
The text was updated successfully, but these errors were encountered:
That query finally finished, and sqlx logged a slow query warning:
$ journalctl -u pr-tracker-fetcher
...
Apr 21 10:37:16 clark pr-tracker-fetcher-start[3570307]: [2024-04-21T17:37:15Z WARN sqlx::query] slow statement: execution time exceeded alert threshold summary="INSERT INTO landings(github_pr, branch_id) …" db.statement="\n\nINSERT INTO\n landin
gs(github_pr, branch_id)\nVALUES\n
[... ~2.8 mb of text ...]
ON CONFLICT (github_pr, branch_id) DO NOTHING\n" rows_affected=0 rows_returned=0 elapsed=1.937380964s slow_threshold=1s
So I guess that means that postgresql was able to chug through the ~8mb query in a bit under 2 seconds, but I also know that from postgresql's perspective, this query started quite some time ago (see above):
query_start | 2024-04-21 16:26:20.188579+00
So from postgresql's perspective, that query took over 1 hour:
$ nix-shell -p 'python3.withPackages (ps: with ps; [ dateutil ])' --run python
>>> import datetime as dt; from dateutil.parser import parse
>>> (parse("2024-04-21T17:37:15Z") - parse("2024-04-21 16:26:20.188579+00")).total_seconds()/3600
1.181892061388889
Ever since upgrading to v3.0.0, I've been seeing pr-tracker-fetcher take a really long time to insert landings. For example, here's some info about a current run:
You can see that this query started over 30 minutes ago!
The rust process seems to be pegging a core, while the postgres process is doing nothing:
I think psql is just waiting on a socket:
And some gdb information on the rust process. It seems to be in the middle of doing some string formatting in the guts of sqlx:
I believe we're stuck here: https://github.com/molybdenumsoftware/pr-tracker/blob/v3.0.0/crates/store/src/lib.rs#L468
Theory: under the hood, sqlx "streams" its output to postgresql, which is why we see the query over in postgresql, but it's still streaming the query, so postgresql has nothing to do.
The text was updated successfully, but these errors were encountered: