如何设置 OCILogon2 的超时?

发布于 2024-08-11 13:03:40 字数 276 浏览 3 评论 0原文

当 Oracle 10 数据库启动并正常运行时,OCILogon2() 将立即连接。当数据库因网络问题而关闭或无法访问时 - 它将立即失败。 然而,当我们的 DBA 进行紧急维护并阻止传入连接时,可能需要 5 到 10 分钟才会超时。 这对我来说是个问题,因为我发现 OCILogin2 不是线程安全的,我们只能串行使用它 - 而且我连接到相当多的 Oracle DB。 3 台被封锁的服务器 X 5-10 分钟 = 15 至 30 分钟的锁定时间

有谁知道如何设置 OCILogon2 连接超时?

谢谢。

When the Oracle 10 databases are up and running fine, OCILogon2() will connect immediately. When the databases are turned off or inaccessible due to network issues - it will fail immediately.
However when our DBAs go into emergency maintenance and block incomming connections, it can take 5 to 10 minutes to timeout.
This is problematic for me since I've found that OCILogin2 isn't thread safe and we can only use it serially - and I connect to quite a few Oracle DBs. 3 blocked servers X 5-10 minutes = 15 to 30 minutes of lockup time

Does anyone know how to set the OCILogon2 connection timeout?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光清浅 2024-08-18 13:03:40

我目前正在与 OCI 合作,在我看来这是不可能的。
我能想到的唯一方法是使用非阻塞模式。在这种情况下,您需要 OCIServerAttach() 和 OCISessionBegin() 而不是 OCILogon()。但当我尝试此操作时,OCISessionBegin() 不断返回 OCI_ERROR 并显示以下错误代码:

  • ORA-03123 操作将阻塞
  • 原因:尝试的操作现在无法完成。
  • 操作:稍后重试该操作。

它看起来很奇怪,我还不知道如何处理它。

可能的解决方法是在另一个进程中运行登录,您可以在超时后终止该进程...

I'm currenty playing with OCI and it seems to me that it's impossible.
The only way I can think of is to use non-blocking mode. You'll need OCIServerAttach() and OCISessionBegin() instead of OCILogon() in this case. But when I tried this, OCISessionBegin() constantly returns OCI_ERROR with the following error code:

  • ORA-03123 operation would block
  • Cause: The attempted operation cannot complete now.
  • Action: Retry the operation later.

It looks strange and I don't yet know how to deal with it.

Possible workaround is to run your logon in another process, which you can kill after timeout...

徒留西风 2024-08-18 13:03:40

我们认为我们找到了正确的文件设置 - 但这是我们必须等到罕见和可怕的事情发生才能验证它的问题之一:-/

[sqlnet.ora]
SQLNET.OUTBOUND_CONNECT_TIMEOUT=60

来自 Oracle 文档..

http://download.oracle.com/docs/cd/B28359_01/network.111/ b28317/sqlnet.htm#BIIFGFHI

5.2.35 SQLNET.OUTBOUND_ CONNECT _TIMEOUT

用途

使用 SQLNET.OUTBOUND_ CONNECT _TIMEOUT 参数指定客户端与数据库实例建立 Oracle Net 连接的时间(以秒为单位)。

如果在指定时间内未建立 Oracle Net 连接,则连接尝试将终止。客户端收到 ORA-12170:TNS:发生连接超时错误。

出站连接超时间隔是 TCP 连接超时间隔的超集,它指定建立 TCP 连接所需的时间限制。此外,出站连接超时间隔包括连接到提供所请求服务的 Oracle 实例所花费的时间。

如果没有此参数,当数据库服务器主机系统无法访问时,对数据库服务器的客户端连接请求可能会在默认 TCP 连接超时持续时间内(在 Linux 上约为 8 分钟)被阻塞。

出站连接超时间隔仅适用于 TCP、带 SSL 的 TCP 和 IPC 传输连接。

默认

示例

SQLNET.OUTBOUND_ CONNECT _TIMEOUT=10

We think we found the right file setting - but it's one of those problems where we have to wait until something rare and horrible occurs before we can verify it :-/

[sqlnet.ora]
SQLNET.OUTBOUND_CONNECT_TIMEOUT=60

From the Oracle docs..

http://download.oracle.com/docs/cd/B28359_01/network.111/b28317/sqlnet.htm#BIIFGFHI

5.2.35 SQLNET.OUTBOUND_ CONNECT _TIMEOUT

Purpose

Use the SQLNET.OUTBOUND_ CONNECT _TIMEOUT parameter to specify the time, in seconds, for a client to establish an Oracle Net connection to the database instance.

If an Oracle Net connection is not established in the time specified, the connect attempt is terminated. The client receives an ORA-12170: TNS:Connect timeout occurred error.

The outbound connect timeout interval is a superset of the TCP connect timeout interval, which specifies a limit on the time taken to establish a TCP connection. Additionally, the outbound connect timeout interval includes the time taken to be connected to an Oracle instance providing the requested service.

Without this parameter, a client connection request to the database server may block for the default TCP connect timeout duration (approximately 8 minutes on Linux) when the database server host system is unreachable.

The outbound connect timeout interval is only applicable for TCP, TCP with SSL, and IPC transport connections.

Default

None

Example

SQLNET.OUTBOUND_ CONNECT _TIMEOUT=10

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文