From a52626e5d31d99935a58e9763149a3c07dadd256 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:34:23 +0000 Subject: [PATCH] fix(upgrade): fix migration stuck at "Starting Data Migration [...]" The iterator was in the loop so it was always reset to null and the same data set to be scanned. For cases where this happened, the iterator was not empty, but the keys returned from the scan was empty. According to [redis](https://redis.io/docs/latest/commands/scan/#number-of-elements-returned-at-every-scan-call), this is expected behavior. > SCAN family functions do not guarantee that the number of elements returned per call are in a given range. The commands are also allowed to return zero elements, and the client should not consider the iteration complete as long as the returned cursor is not zero. As such, we must make sure we're using the new iterator returned to continue scanning the keys. --- src/Appwrite/Platform/Tasks/Migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index e8d716a1f0..dcba59bb1d 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -43,8 +43,8 @@ class Migrate extends Action private function clearProjectsCache(Document $project) { try { + $iterator = null; do { - $iterator = null; $pattern = "default-cache-_{$project->getInternalId()}:*"; $keys = $this->redis->scan($iterator, $pattern, 1000); if ($keys !== false) {