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.
This commit is contained in:
Steven Nguyen 2024-08-12 19:34:23 +00:00 committed by GitHub
parent b5fad9f234
commit a52626e5d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) {