使用DBMS_JOB.Submit时,Oracle 19c安排工作将来14小时

发布于 2025-02-05 13:54:16 字数 502 浏览 2 评论 0原文

我们有一个最近在AWS上迁移到Oracle 19c的客户。由于迁移,因此使用dbms_job.submit在我们的应用程序中创建的任何Oracle作业都计划在DB服务器时间提前7个小时运行。

例如,以下测试代码在7:00在客户端的计算机上运行。 AWS服务器上的时间为14:00,但是创建了在21:00运行的实际工作,

DECLARE
  I NUMBER;
BEGIN
  DBMS_JOB.SUBMIT(I, 'DECLARE I NUMBER; BEGIN SELECT COUNT(1) INTO I FROM DUAL; END;');
  COMMIT;
END;

这听起来时区与时区有关吗?有什么想法吗?

更新:

我们的客户位于美国(我在英国),当我在其DB上运行代码时,我的操作系统时区设置为“(UTC+00:00)伦敦”,该工作已安排立即地。如果我将操作系统时区更新为“(UTC-08:00)太平洋时间”,以模仿他们的操作系统,以上代码将在7个小时的时间内计划运行。

We've got a client who's recently migrated to Oracle 19c on an AWS. Since the migration, any Oracle jobs that are created within our application, using DBMS_JOB.SUBMIT, are scheduled to run 7 hours ahead of the DB server time.

For example, the following test code was run on a client's machine at 7:00. The time on the AWS server was 14:00 but the actual job was created to run at 21:00

DECLARE
  I NUMBER;
BEGIN
  DBMS_JOB.SUBMIT(I, 'DECLARE I NUMBER; BEGIN SELECT COUNT(1) INTO I FROM DUAL; END;');
  COMMIT;
END;

This sounds time zone related? Any thoughts?

Update:

Our clients are based in the US (I'm in the UK) and when I run the code above on their DB, with my OS Time zone set to "(UTC+00:00) London", the job is scheduled immediately. If I update my OS Time Zone to "(UTC-08:00) Pacific Time", to mimic their OS, running the code above schedules the job to run in 7 hours time.

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

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

发布评论

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

评论(1

很快妥协 2025-02-12 13:54:16

这个问题是由我刚钉住的错误引起的。我已经在Oracle创建了一个服务请求,因此他们可以在其DBMS_IJOB代码中修复此请求。看来该错误是在19C中引入的,其中DBMS_JOB代码已被重构为DBMS_SCHEDULER。该错误仍然存​​在于最新的Oracle DB Ru中,即19.19。 DBMS_IJOB软件包从日期到时间戳进行了错误的转换,将当前数据库主机时间(SYSDATE)解释为当前会话时区的时间(而这是数据库主机OS的时区的时间)。这导致了可见的偏移。这种偏移可能是正面和负面的,这导致工作的开始太早或太晚。现在,唯一的解决方法是切换到DBMS_SCHEDULER或抵消dbms_job.submit next_date参数,以补偿错误的时间戳。

This issue is caused by a bug that I have just nailed down. I have created a service request at Oracle, so they can fix this in their code of dbms_ijob. Looks like it this bug has been introduced in 19c where the dbms_job code has been refactored to just be a facade to dbms_scheduler. The bug still exists in the latest Oracle DB RU, i.e., 19.19. The dbms_ijob package does a wrong conversion from date to timestamp where it interprets the current database hosts system time (sysdate) as a time in the timezone of the current session (while it is a time in the timezone of the database host os). This leads to the seen offset. This offset can be positive and negative, which leads to a too early or too late start of the job. Only workaround right now is to switch to dbms_scheduler or to offset the dbms_job.submit next_date parameter to compensate the wrong timestamp.

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