Skip to content
New issue

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

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

Already on GitHub? # to your account

对于PostgreSQL,传递了错误的connectTimeout #5096

Closed
xlofhappy opened this issue Feb 3, 2023 · 9 comments
Closed

对于PostgreSQL,传递了错误的connectTimeout #5096

xlofhappy opened this issue Feb 3, 2023 · 9 comments
Milestone

Comments

@xlofhappy
Copy link

在DruidAbstractDataSource中 的 createPhysicalConnection 方法中,
if (driver != null && "org.postgresql.Driver".equals(driver.getClass().getName())) {
if (connectTimeoutStr == null) {
connectTimeoutStr = Integer.toString(connectTimeout);
}
physicalConnectProperties.put("loginTimeout", connectTimeoutStr);

            if (socketTimeoutSr == null) {
                socketTimeoutSr = Integer.toString(socketTimeout);
            }
            physicalConnectProperties.put("socketTimeout", socketTimeoutSr);
        }

当数据库时 postgresql时,使用connectTimeout的值传递 loginTimeout 属性至 postgresql的Driver中,用以创建物理连接,但org.postgresql.Driver 中会将 loginTimeout认为是以秒单位,详见方法 Driver中的 private static long timeout(Properties props) 方法

@kimmking
Copy link
Collaborator

kimmking commented Feb 18, 2023

image
You are right, from the README.md, loginTimeout/connectTimeout/socketTimeout are three different options of pg driver in seconds.

https://github.com/pgjdbc/pgjdbc/blob/2b90ad04696324d107b65b085df4b1db8f6c162d/README.md
https://github.com/pgjdbc/pgjdbc/search?q=socketTimeout&type=

@kimmking
Copy link
Collaborator

there will be corrected by two steps:

  • config three options with seconds in your application, and correct comments/docs in druid codes
  • add a loginTimeout to set it and not use connectTimeout option

@wenshao
Copy link
Member

wenshao commented Feb 19, 2023

https://github.com/alibaba/druid/releases/tag/1.2.16
问题已修复,请用新版本

@wenshao wenshao closed this as completed Feb 19, 2023
@kuguobing
Copy link

DruidDataSource::init()

if (connectTimeout == 0) {
socketTimeout = DEFAULT_TIME_CONNECT_TIMEOUT_MILLIS;
}

这个怎么还没改?

Wincher added a commit to Wincher/druid that referenced this issue Feb 21, 2023
	loginTimeout in milliseconds, socketTimeout in seconds
fix alibaba#5096 Postgres modify timeout value unit from milliseconds to seconds
	wrong field assignment
Wincher added a commit to Wincher/druid that referenced this issue Feb 21, 2023
	loginTimeout in second , socketTimeout in millisecond
fix alibaba#5096 Postgres modify timeout value unit from milliseconds to seconds
	wrong field assignment
Wincher added a commit to Wincher/druid that referenced this issue Feb 27, 2023
	loginTimeout in second , socketTimeout in millisecond
fix alibaba#5096 Postgres modify timeout value unit from milliseconds to seconds
	wrong field assignment
@kimmking kimmking reopened this Mar 4, 2023
@kimmking
Copy link
Collaborator

kimmking commented Mar 4, 2023

fixed now: 06b8ac1

@lizongbo
Copy link
Collaborator

lizongbo commented Jan 7, 2024

请使用 1.2.21验证

@lizongbo lizongbo closed this as completed Jan 7, 2024
@laojiongkim
Copy link

1.2.21,it happended again

@DerrickRoseCode
Copy link

1.2.21 我的报错也还在

@kimmking
Copy link
Collaborator

kimmking commented Nov 12, 2024 via email

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants