From 866cd520738d9de2af8163e9c0d98d6bbadc3530 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 25 Mar 2026 07:52:33 +0000 Subject: [PATCH] Convo: fetched collections can be huge - add a slight delay between storing items if we did not fetch them from the network to allow the DB to do its thing (cherry picked from commit 6d8bfe58efcb505206dd9607e3b35965f0c4ae5b) Co-authored-by: Mario --- Zotlabs/Daemon/Convo.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Zotlabs/Daemon/Convo.php b/Zotlabs/Daemon/Convo.php index 6a2c912ed..4bf01d1fb 100644 --- a/Zotlabs/Daemon/Convo.php +++ b/Zotlabs/Daemon/Convo.php @@ -6,6 +6,7 @@ use Zotlabs\Lib\Activity; use Zotlabs\Lib\ActivityStreams; use Zotlabs\Lib\ASCollection; use Zotlabs\Lib\ASCache; +use Zotlabs\Lib\Config; class Convo { @@ -33,6 +34,7 @@ class Convo { } $force = $argv[4] ?? false; + $interval = Config::Get('queueworker', 'queue_interval', 500000); foreach ($channels as $channel_id) { $channel = channelx_by_n($channel_id); @@ -46,6 +48,8 @@ class Convo { } foreach ($messages as $message) { + $network_fetch = false; + if (is_string($message)) { $cached = ASCache::Get($message); if ($cached) { @@ -54,6 +58,8 @@ class Convo { } else { // logger('convo_fetching: ' . $message); + $network_fetch = true; + $data = Activity::fetch($message, $channel); if ($data) { ASCache::Set($message, $data); @@ -65,6 +71,12 @@ class Convo { $data = $message; } + if (!$network_fetch) { + // Add some delay so that the DB will not be overwhelmed + // Fetched from network will already have a slight delay + usleep($interval); + } + $AS = new ActivityStreams($data); if ($AS->is_valid() && is_array($AS->obj)) { $item = Activity::decode_note($AS);