【发布时间】:2021-10-02 08:53:45
【问题描述】:
我们为 RavenDB 数据库创建了 PeriodicExport。我们尝试将备份文件上传到 Azure BLOB 容器。
在 Azure BLOB 容器中,我可以看到 增量 备份文件。但我没有看到完整备份文件。
我还可以从 Raven Alerts 中看到下一个错误:
| Label | Description |
|---|---|
| Title | Error in Periodic Export |
| Message | Status code: RequestEntityTooLarge <?xml version="1.0" encoding="utf-8"?><Error><Code>RequestBodyTooLarge</Code><Message>The request body is too large and exceeds the maximum permissible limit. RequestId:8b013757-401e-0014-4965-b7e992000000 Time:2021-10-02T08:13:54.8562742Z</Message><MaxLimit>67108864</MaxLimit></Error> |
| Level | Error |
还有完整的异常信息:
Raven.Abstractions.Connection.ErrorResponseException: Status code: RequestEntityTooLarge
<?xml version="1.0" encoding="utf-8"?><Error><Code>RequestBodyTooLarge</Code><Message>The request body is too large and exceeds the maximum permissible limit.
RequestId:8b013757-401e-0014-4965-b7e992000000
Time:2021-10-02T08:13:54.8562742Z</Message><MaxLimit>67108864</MaxLimit></Error>
at Raven.Database.Client.Azure.RavenAzureClient.PutBlob(String containerName, String key, Stream stream, Dictionary`2 metadata) in c:\Builds\RavenDB-Stable-3.0\Raven.Database\Client\Azure\RavenAzureClient.cs:line 93
at Raven.Database.Bundles.PeriodicExports.PeriodicExportTask.UploadToAzure(String backupPath, PeriodicExportSetup localExportConfigs, Boolean isFullBackup) in c:\Builds\RavenDB-Stable-3.0\Raven.Database\Bundles\PeriodicExports\PeriodicBackupTask.cs:line 397
at Raven.Database.Bundles.PeriodicExports.PeriodicExportTask.<>c__DisplayClasse.<<TimerCallback>b__a>d__10.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Database\Bundles\PeriodicExports\PeriodicBackupTask.cs:line 248
Raven DB 版本为:
{
"ProductVersion": "3.0.0 / cdc39ac / ",
"BuildVersion": "3690"
}
这个错误可以修复吗?
非常感谢任何帮助。
更新
我在 GitHub repository 找到了相关构建版本的源代码。
该bug存在于下一个方法中:
public void PutBlob(string containerName, string key, Stream stream, Dictionary<string, string> metadata)
{
var url = GetUrl(containerName) + "/" + key;
var now = SystemTime.UtcNow;
var content = new StreamContent(stream)
{
Headers =
{
{ "x-ms-date", now.ToString("R") },
{ "x-ms-version", "2011-08-18" },
{ "x-ms-blob-type", "BlockBlob" },
{ "Content-Length", stream.Length.ToString(CultureInfo.InvariantCulture) }
}
};
foreach (var metadataKey in metadata.Keys)
content.Headers.Add("x-ms-meta-" + metadataKey.ToLower(), metadata[metadataKey]);
var client = GetClient(TimeSpan.FromHours(1));
client.DefaultRequestHeaders.Authorization = CalculateAuthorizationHeaderValue("PUT", url, content.Headers);
var response = client.PutAsync(url, content).ResultUnwrap();
if (response.IsSuccessStatusCode)
return;
throw ErrorResponseException.FromResponseMessage(response);
}
如您所见,此方法使用 Azure API 版本 2011-08-18。 Microsoft documentation 中描述了此 Azure 版本的限制。
关于文档“Maximum blob size via single write operation (via Put Blob)”正好是 64 MiB(67108864 字节)。所以 Azure 提供的异常是绝对正确的。
不幸的是,Raven Build-3690 有一个错误,该错误已在下一个版本中修复。有修复的源代码可以查看here。
【问题讨论】:
-
这应该在 v3.5 中工作。 github.com/ravendb/ravendb/blob/v3.5/Raven.Database/Client/… 请注意,v3.0 和 v3.5 已不受支持。
-
Build
3690是从 2015 年开始的。您需要使用最新的稳定版。 (3.0 或 3.5) -
这个问题有更新吗?此答案是否解决了您的问题?
-
@AjayKumarGhose-MT 请查看更新。