PostgreSQL ODBC 驱动程序在 SQLExecDirect

问题描述

这仅发生在 prod 环境中,我无法在沙箱中重现相同的行为。

#0  0x00007f07854d8cb9 in __GI___poll (fds=0x7f076d8f1e88,nfds=1,timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f077c2ad990 in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#2  0x00007f077c2adaf8 in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#3  0x00007f077c2aa2d9 in PQgetResult () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#4  0x00007f077c5176b3 in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#5  0x00007f077c4fa644 in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#6  0x00007f077c4fbab5 in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#7  0x00007f077c53242a in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#8  0x00007f077c50de7a in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#9  0x00007f077c50f3a7 in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#10 0x00007f077c50fac1 in ?? () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#11 0x00007f077c5395bb in sqlExecDirect () from /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
#12 0x00007f0787a5a16f in sqlExecDirect () from /usr/lib/x86_64-linux-gnu/libodbc.so.2
#13 0x00000000004be434 in my_function_where_i_call_sql_exec_direct ()

我们在类似于 AWS 的云中使用托管 Postgres,该服务提供了 Web 界面,我可以在其中访问服务器日志。对我来说最奇怪的是我看到我的查询成功执行:

{
    "transaction_id": "0","error_severity": "LOG","hostname": "rc1a-...mdb.yandexcloud.net","internal_query": "","process_id": "2624784","session_id": "60672f13.280d10","query_pos": "0","user_name": "ace","application_name": "ace-realm-Meta - 10.128.0.9 ","command_tag": "idle in transaction","context": "","hint": "","message": "statement: RELEASE _EXEC_SVP_0x319d9f0;SAVEPOINT _EXEC_SVP_0x319d9f0;SELECT R_Object.Meta FROM R_Object  WHERE ((R_Object.id \\= 15) ) ORDER BY R_Object.id ASC ","session_line_num": "2817","connection_from": "localhost:48058","database_name": "droblozhko1","internal_query_pos": "0","query": "","virtual_transaction_id": "59/191031","detail": "","location": "","session_start_time": "2021-04-02T17:49:55+03:00","sql_state_code": "00000"
}

(这意味着没有排他锁阻止我的选择?!)

我在谷歌上搜索了很多,发现只有一个关于类似故事的讨论:https://postgrespro.com/list/thread-id/2394695,但是这个线程中提到的 sql_ATTR_QUERY_TIMEOUT 和 keepliave pqoptions 正在影响任何事情:\

分享任何想法,因为我完全没有想法。

Update1. 为什么超时是负的(在最后一帧)?这就是 poll() 永远不会返回的原因。

更新 2 我发现 PQgetResult() 调用 pqWait(),它调用 pqWaitTimed 并将硬编码的完成时间设置为 -1。现在的问题是这个逻辑应该如何处理网络问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)