Pavlo Golub: Migrate scheduled jobs to pg_timetable from pgAgent

Why migrate to pg_timetable from pgAgent? There are many reasons, actually, why people might want to export pgAgent jobs to pg_timetable. Most of them may be spotted by taking a look at the PostgreSQL schedulers comparison table I introduced in one of my previous posts and the supported platform table from the official readme. In my previous article I highlighted the reasons why and the ways how one might want to move scheduled jobs from pg_cron to pg_timetable. Differences and similarities between pg_timetable and pgAgent architectures Both tools use multi-step job architecture. pg_timetable uses “chain” and “task” terms, while pgAgent uses “job” and “step” terminology. pgAgent is able to execute SQL and BATCH (shell) tasks. pg_timetable‘s task can be one of SQL, PROGRAM, and BUILTIN. Thus to emulate pgAgent‘s BATCH step, pg_timetable will run a PROGRAM task calling shell execution, e.g. bash -c "command". pgAgent allows specifying many schedules for a job. If several schedules are found, we should duplicate the chain definition for each of them. To store scheduling information, pg_timetable uses cron notation, but pgAgent uses boolean arrays as storage. We need to provide a way of transforming the array to cron notation. pgAgent, as well as pg_timetable, allows ignoring task errors. The possible scenarios are: fail the job, mark the step as succeeded and continue, mark as fail but ignore it and proceed. pg_timetable allows only ignoring the error without marking it as succeeded. While pgAgent can limit job execution by the agent’s host, pg_timetable is more flexible in implementing control with the client name. Here we will assume the host name becomes a client name after migration. pgAgent allows setting start and end timestamp for a schedule, as well as if a schedule is enabled. We will migrate only valid schedules: those which are enabled and active right now within the date range. Prerequisites You have installed the pgagent ext[...]

pg
相关推荐 去reddit讨论
  1. Google 发布「AI 全家桶」反击 GPT-4o !搜索引擎罕见大更新, 121 句「AI」道尽焦虑
    Google在Google I/O发布会上推出了多种新产品和升级,包括Gemini大模型、Gemma多模态大模型、AI in Google Workspa...
  2. 简单是优势,但为何复杂性还受欢迎?
    文章探讨了简单性和复杂性的优劣。复杂性在某些情况下更受欢迎,因为它传达了努力、精通和创新的信号。然而,简单性更易理解、使用、构建和维护,具有较低的运营成本...
  3. 一目十行:上下文快速阅读法
    基于上下文关系的阅读方法强调理解文本的整体语境,通过识别句子、段落甚至整篇文章中的逻辑关系和线索,来解读文本的含义。实践方法包括上下文预测、语境线索、重点...
  4. 太贴心!OpenAI发布了类人化重大版本:GPT-4o
    OpenAI发布了GPT-4o,具有实时翻译、情绪检测、语音指令理解、声音合成和图像理解等功能。GPT-4o将通过API免费提供给用户。OpenAI还发布...
  5. Python中读写Parquet文件的方法
    Apache Parquet是一种流行的列式存储格式,使用pyarrow包可以轻松读写Parquet文件。可以转换DataFrame为Parquet文件,...
  6. 使用 braft 构建应用,应该关注哪些指标?
    本文介绍了使用braft构建应用时需要关注的指标。braft是一个C++ raft框架,开发者可以基于其抽象接口实现自己的业务逻辑。文章从metrics入...
  7. Python读取NetCDF文件-裁剪&计算
    这篇文章介绍了使用xarray包处理NetCDF文件的方法。xarray是基于pandas的数据结构构建的,可以方便地处理多维数组数据。文章还介绍了如何根...
  8. How to Use Stable Diffusion Effectively
    稳定扩散是一个由多个组件和参数组成的流水线,它们共同工作产生输出。模型是流水线中最重要的组件之一,不同版本的模型会对输出产生不同影响。选择合适的模型、采样...
  9. sqlx: 一个优秀的rust异步SQL库
    Rust生态圈中的sqlx库是一个功能齐全的数据库访问和查询构建器库,支持多种数据库。它具有异步、编译时检查查询、与数据库无关、纯Rust等特点。sqlx...
  10. Python 潮流周刊#50:我最喜欢的 Python 3.13 新特性!
    本期刊共分享了12篇文章、11个开源项目和2则音视频,涵盖Python 3.13新特性、Asyncio工作原理、Python文件处理、数据科学错误、加速N...