Не хватает памяти при восстановлении из бэкапа

Пробуем сделать standby решение со снятием backup c main и restore на standby.
Размер индекса до 1.7 ГБ.
Операция restore падает по памяти:

Manticore config file: 
Backup dir: /mnt/backup
2024-03-11 13:07:55 [Info] Starting to restore...

Manticore config
  endpoint =  http://10.9.2.78:9312
2024-03-11 13:07:55 [Info] Restoring config files...
string(77) "/mnt/backup/backup-20240311124106/config/var/lib/manticore/manticore.json.zst"
string(79) "/mnt/backup/backup-20240311124106/config/etc/manticoresearch/manticore.conf.zst"
2024-03-11 13:07:55 [Info]   config files - OK
2024-03-11 13:07:55 [Info] Restoring state files...
string(95) "/mnt/backup/backup-20240311124106/state/usr/local/lib/manticore/buddy-plugins/composer.json.zst"
2024-03-11 13:07:55 [Info]   state files - OK
2024-03-11 13:07:55 [Info] Restoring data files...
string(71) "/mnt/backup/backup-20240311124106/data/products/products.58047.spds.zst"

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 56745056 bytes) in /usr/share/manticore/modules/manticore-backup/src/Lib/FileStorage.php on line 576

Помогает правка в исходнике /usr/share/manticore/modules/manticore-backup/src/Lib/FileStorage.php:
ini_set ('memory_limit', '256M');
Но это как то не кашерно :slight_smile: Есть ли другое решение?

Какая версия manticore-backup и manticore-executor?

manticore-executor/now 0.7.8-23082210-810d7d3 amd64
manticore-backup/now 1.0.8-23080408-f7638f9 all

Вероятно исправлено в новой версии. В 1.0.8 было так https://github.com/manticoresoftware/manticoresearch-backup/blob/1.0.8/src/Lib/FileStorage.php#L569C28-L583

	protected static function decompress(string $file): string {
		static::validateZstdInstalled();

		$data = file_get_contents($file);
		if ($data === false) {
			throw new RuntimeException("Failed to read file: $file");
		}
		$data = zstd_uncompress($data);
		if ($data === false) {
			throw new RuntimeException("Failed to decompress file: $file");
		}

		return $data;
	}
}

Теперь так https://github.com/manticoresoftware/manticoresearch-backup/blob/f2b89f3ab770008f90f893ef9602c5069daf84b1/src/Lib/FileStorage.php#L602-L628

	protected static function decompress(string $source, string $target): bool {
		static::validateZstdInstalled();
		$sourceStream = fopen("compress.zstd://{$source}", 'rb');
		$targetStream = fopen($target, 'wb');
		if (!$sourceStream || !$targetStream) {
			return false;
		}

		while (!feof($sourceStream)) {
			$buffer = fread($sourceStream, 4096);
			if (!$buffer) {
				break;
			}

			$written = fwrite($targetStream, $buffer);
			if (!$written) {
				return false;
			}
		}

	  // Close the streams when we're done
		fclose($sourceStream);
		fclose($targetStream);

		return true;
	}
}

Когда новая версия выйдет?

Хочется верить, что в конце месяца. Потихоньку начинаем предрелизное тестирование.

2 Likes