From bc842bf0cf8d4482d749f20a2994cac2a5d4d826 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Mon, 25 Mar 2024 18:35:36 +0100 Subject: [PATCH 1/3] chg: [sync] Reduce chunk size when fetching sightings to solve HTTP timeouts --- app/Model/Sighting.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Model/Sighting.php b/app/Model/Sighting.php index f6aa187d539..ee331aff027 100644 --- a/app/Model/Sighting.php +++ b/app/Model/Sighting.php @@ -1441,11 +1441,12 @@ private function pullSightingNewWay(array $user, array $eventUuids, ServerSyncTo $uuids = array_keys($eventUuids); $saved = 0; $savedEventUuids = []; - foreach (array_chunk($uuids, 100) as $chunk) { + foreach (array_chunk($uuids, 50) as $chunk) { try { $sightings = $serverSync->fetchSightingsForEvents($chunk); } catch (Exception $e) { - $this->logException("Failed to download sightings from remote server {$serverSync->server()['Server']['name']}.", $e); + $chunkSize = count($chunk); + $this->logException("Failed to download sightings for $chunkSize events from remote server {$serverSync->serverName()}.", $e); continue; } From 83bbdaaf9904692c9bc40bcb7b793b50c105f9e6 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Wed, 27 Mar 2024 08:53:58 +0100 Subject: [PATCH 2/3] chg: [sync] Shuffle event uuids when fetching sightings to solve HTTP timeouts --- app/Model/Sighting.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Model/Sighting.php b/app/Model/Sighting.php index ee331aff027..bdb4e9e5c66 100644 --- a/app/Model/Sighting.php +++ b/app/Model/Sighting.php @@ -1439,6 +1439,7 @@ public function pullSightings(array $user, ServerSyncTool $serverSync) private function pullSightingNewWay(array $user, array $eventUuids, ServerSyncTool $serverSync) { $uuids = array_keys($eventUuids); + shuffle($uuids); // shuffle array to avoid keeping events with a lof ot sightings in same batch all the time $saved = 0; $savedEventUuids = []; foreach (array_chunk($uuids, 50) as $chunk) { From 425639901b39181ecd663b3aee78b978a3e781a9 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Sun, 31 Mar 2024 09:40:10 +0200 Subject: [PATCH 3/3] fixup! chg: [sync] Reduce chunk size when fetching sightings to solve HTTP timeouts --- app/Model/Sighting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Model/Sighting.php b/app/Model/Sighting.php index bdb4e9e5c66..7a5371dd776 100644 --- a/app/Model/Sighting.php +++ b/app/Model/Sighting.php @@ -1442,7 +1442,7 @@ private function pullSightingNewWay(array $user, array $eventUuids, ServerSyncTo shuffle($uuids); // shuffle array to avoid keeping events with a lof ot sightings in same batch all the time $saved = 0; $savedEventUuids = []; - foreach (array_chunk($uuids, 50) as $chunk) { + foreach (array_chunk($uuids, 20) as $chunk) { try { $sightings = $serverSync->fetchSightingsForEvents($chunk); } catch (Exception $e) {