kagkarlsson / db-scheduler

Persistent cluster-friendly scheduler for Java
Apache License 2.0
1.23k stars 188 forks source link

Add task log #391

Closed good-vi closed 1 year ago

good-vi commented 1 year ago

Hi. Can we made second table scheduled_tasks_history similar scheduled_tasks where we can store history log?:

create table scheduled_tasks_history (
  task_name text not null,
  task_instance text not null,
  task_data bytea,
  execution_time timestamp with time zone not null,
  picked BOOLEAN not null,
  picked_by text,
  last_success timestamp with time zone,
  last_failure timestamp with time zone,
  consecutive_failures INT,
  version BIGINT not null
);

CREATE INDEX execution_time_idx ON scheduled_tasks (execution_time);

I found StatsRegistry where i can probably inject self-written logger, but i need additional info:

void register(ExecutionStatsEvent e, TaskInstance additionalInfo)
// or
void register(ExecutionStatsEvent e, Execution additionalInfo)

Also i found that debug loggers in ExecutePicked not present any info about task.

kagkarlsson commented 1 year ago

A log-table would need to be added as an extension or addon and maintained outside the core project. I think this is similar to what @melistik and rocketbase-io needed. See their project db-scheduler-log

good-vi commented 1 year ago

@kagkarlsson thx. You can add the project to the readme so you don't have to worry about it again. Its funny how they solve my problem using injection in custom serializer)