Back

Function Schedule not executed correctly

  • 0
  • Self Hosted
  • Functions
Irvine
1 Apr, 2024, 04:05

Hi Support,

We have two projects (Project-Stage and Project-Prod) on our Appwrite Self Hosted instance with same collection structure and functions. There are two functions with schedule setting 0 0 1 * *, the configs for the two functions in the json file are below.

In the Project-Stage project, no execution happens during the scheduled time. Not sure what happened, no logs for this.

In the Project-Prod project, execution happens and been triggered twice, two execution happens on the same time. We are doing horizontal scaling with shared storage, shared MariaDB, shared Redis, and shared InfluxDB. We have appwrite-schedule service scaling, could this be why executions are duplicated?

Function config in JSON.

TypeScript
{
    "$id": "65deec721e8d6e357af6",
    "name": "function1",
    "runtime": "node-18.0",
    "execute": [],
    "events": [],
    "schedule": "0 0 1 * *",
    "timeout": 900,
    "enabled": true,
    "logging": true,
    "entrypoint": "dist/main.js",
    "commands": "npm install && npm run build",
    "ignore": [
        "node_modules",
        ".npm"
    ],
    "path": "../functions/function1"
},
{
    "$id": "65ed50d075d4ac369e24",
    "name": "function2",
    "runtime": "node-18.0",
    "execute": [],
    "events": [],
    "schedule": "0 0 1 * *",
    "timeout": 900,
    "enabled": true,
    "logging": true,
    "entrypoint": "dist/main.js",
    "commands": "npm install && npm run build",
    "ignore": [
        "node_modules",
        ".npm"
    ],
    "path": "../functions/function2"
}
TL;DR
Issue: Scheduled function not executing correctly in Appwrite Self Hosted instance. In Project-Stage, no execution happens; in Project-Prod, execution occurs twice at the same time. Potential Cause: Horizontal scaling with shared services like MariaDB, Redis, InfluxDB, and scaling of the `appwrite-schedule` service may lead to duplicated executions. Solution: 1. Check the shared services' configurations impacting the scheduled functions. 2. Verify the scaling setup and its influence on function execution. 3. Review and adjust the configurations for the scheduled functions to prevent duplication.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more