0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-30 19:41:46 +01:00
Commit Graph

14 Commits

Author SHA1 Message Date
Brett Hoerner
30bafdd382
chore(plugin-server): kafka ack cleanup and metric (#21111)
* cleanup: remove unused team arg from registerLastStep

* cleanup: rename promises to ackPromises to make it more clear thats what they are

* cleanup(plugin-server): make waitForAck explicit/required

* add Kafka produce/ack metrics

* Clarify Kafka produce metric/labels
2024-03-25 13:01:15 +00:00
Harry Waye
f901665bfa
chore: make sure dlqs exist in function tests before consuming (#16550)
In CI it's often the case that we get an error saying the
topic-partition pair doesn't exist. This creates the topic explicitly.
2023-07-13 10:49:01 +01:00
Harry Waye
39224b018e
chore: fix flaky dlq functional tests (#15439)
There is a race condition in these tests where the consumer isn't
consuming in time to pick up bad messages, so we ensure that we set the
offsets to the earliest messages.
2023-05-09 14:36:14 +01:00
Harry Waye
01da91d1e2
test: remove explicit dependencies from functional tests (#14471)
* test: remove explicit dependencies from functional tests

* Install pnpm in devcontainer
2023-03-01 12:03:54 +00:00
Harry Waye
a4a3a0c902
test(plugin-server): use librdkafka for functional tests (#14468)
* test(plugin-server): use librdkafka for functional tests

While trying to port the session recordings to use node-librdkafka I
found it useful to first implement it in the functional tests.

* use obj destructuring to make calls more self explanatory
2023-03-01 11:03:13 +00:00
Harry Waye
63ba5e2fb7
chore: remove usage of delayUntilEventsIngested (#13509)
Its usage is odd and it's not clear what it's doing.
2022-12-29 21:54:44 +00:00
Harry Waye
1e82569bbb
chore(plugin-server): Add metrics for time of last processed message (#13350)
* chore(plugin-server): Add metrics for time of last processed message

Previously we have been alerting on Kafka consumer group offset lag.
However, really we care about the delay between messages being written
to Kafka and being processed by the plugin server.

By adding the last processed timestamp, as a gauge, we can then alert on
if that time and now is greater than a threshold.

This alert would not require the plugin-server to be up to trigger, just
that there be some time registered so it handles complete failure also.

For the case that there are no messages past the committed offsets, we
will end up triggering the alert if we do not also take into
consideration the production rate into the topic.

* wip

* wip

* fix imports order

* fix group id

* Add and use waitForExpect instead

* remove yarn.lock

* move comment

* wip
2022-12-15 18:28:43 +00:00
Harry Waye
1e6c062095
feat(plugin-server): distribute scheduled tasks i.e. runEveryX (#13124)
* chore(plugin-server): disrtibute scheduled tasks

Changes I've made here from the original PR:

 1. add some logging of task run times
 2. add concurrency, except only one task of a plugin will run at a time
 3. add a timeout to task run times

This reverts commit 23db43a0dc.

* chore: add timings for scheduled tasks runtime

* chore: add timeouts for scheduled tasks

* chore: clarify duration unit

* chore: deduplicate tasks in a batch, add partition concurrency

* chore: add flag to switch between old and new behaviour

This defaults to new, but can be set to old by setting environment
variable `USE_KAFKA_FOR_SCHEDULED_TASKS=false`

* fix tests

* enable USE_KAFKA_FOR_SCHEDULED_TASKS in tests
2022-12-05 12:30:52 +00:00
Harry Waye
23db43a0dc
Revert "Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker """ (#13107)
Revert "Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker "" (#13100)"

This reverts commit 8eec4c9346.
2022-12-03 00:13:27 +00:00
Harry Waye
8eec4c9346
Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker "" (#13100)
Revert "Revert "fix(plugin-server): ignore old cron tasks from graphile-worker " (#13095)"

This reverts commit 5634ab4d7f.
2022-12-02 18:11:17 +00:00
Harry Waye
5634ab4d7f
Revert "fix(plugin-server): ignore old cron tasks from graphile-worker " (#13095)
Revert "fix(plugin-server): ignore old cron tasks from graphile-worker  (#13094)"

This reverts commit b079a8cc8e.
2022-12-02 16:28:30 +00:00
Harry Waye
b079a8cc8e
fix(plugin-server): ignore old cron tasks from graphile-worker (#13094)
* Revert "Revert "feat(plugin-server): distribute scheduled tasks i.e. runEveryX" (#13087)"

This reverts commit 78e6f48660.

* fix(plugin-server): ignore old cron tasks from graphile-worker

When we are backed up on jobs, we end up still creating tasks in the
graphile-worker job table, i.e. there is no backpressure. This change
makes us skip over old tasks, so that we don't get backed up.

* fix tests
2022-12-02 15:20:16 +00:00
Harry Waye
78e6f48660
Revert "feat(plugin-server): distribute scheduled tasks i.e. runEveryX" (#13087)
Revert "feat(plugin-server): distribute scheduled tasks i.e. runEveryX (#13037)"

This reverts commit 45912e839c.
2022-12-02 10:40:58 +00:00
Harry Waye
45912e839c
feat(plugin-server): distribute scheduled tasks i.e. runEveryX (#13037)
* feat(plugin-server): distribute scheduled tasks i.e. runEveryX

At the moment we only run on which ever Graphile worker node picks up
the scheduled tasks. Tasks are run in sequence, running through each of
the associated pluginConfigIds.

We tried to spread the workload by creating a Graphile Worker job for
each pluginConfigId, but this caused a lot of load on the Graphile
Worker database.

One thing this PR doesn't tackle is what happens if we end up having the
jobs back up. There is probably some logic we should add to avoid really
old scheduled tasks from running.

* wip

* wip

* fix tests

* fix tests

* types

* update unit test

* add key

* fix order

* Update plugin-server/src/main/ingestion-queues/scheduled-tasks-consumer.ts

* chore: skip stale scheduled tasks

* update comments

* add statsd counter
2022-12-02 09:42:55 +00:00