首页 文章

Azure角色回收 - 无限繁忙状态

提问于
浏览
0

此问题始于2017年1月24日星期二 . 在此日期之前,我从未遇到过 Worker 角色回收问题 .

美国东部时间晚上9点左右,我的 Worker 角色进入繁忙状态 . CPU达到90% . 它保持这种方式超过10个小时 . 它从一个角色开始,然后传播给其他角色 . 我的软件在白天工作正常 . 我的工作者角色使用标准A0超小尺寸 . 我尝试将大小增加到小标准A1,但错误仍然存在 .

我的代码说StorageConnectionString . 我运行了一个调试器,我只看到一次这个错误:

System.Data.dll中出现“System.Data.SqlClient.SqlException”类型的异常,但未在用户代码中处理

附加信息:已成功与服务器 Build 连接,但在登录前握手期间发生错误 . (提供程序:TCP提供程序,错误:0 - 远程主机强制关闭现有连接 . )

这导致异常并且角色停止 . 不过,我再也没见过它了 .

我必须将我的站点部署到登台服务器,停止 生产环境 服务器,然后单击交换以使其工作 . 它在当天晚些时候晚上9点再次破裂 .

当我的角色忙时,这是我收到的错误:

忙碌(稳定角色...... [01 / 28T13:28Z]角色将循环使用 . 最后OnRoleRun优雅地返回 . 最后退出时间:

我把远程桌面放到了事件日志中 . 这是我收到的错误:

WaWorkerHost无法加载角色程序集:XX.TaskRole,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null

enter image description here

这是我的worker角色代码:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Net;
using System.Threading;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Queue;
using Microsoft.Azure;

namespace XX.TaskRole
{
    public class WorkerRole : RoleEntryPoint
    {
        string conString = ConfigurationManager.ConnectionStrings["XX"].ConnectionString;
        CloudQueue queue;

        public WorkerRole()
        {
            ServicePointManager.DefaultConnectionLimit = 12;
            

        }

        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            while (true)
            {
                GetTasks();
                Thread.Sleep(30000);
                Trace.TraceInformation("Working", "Information");
            }
        }

        public override bool OnStart()
        {
            try
            {
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("StorageConnectionString"));

                // Create the queue client.
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

                // Retrieve a reference to a queue.
                queue = queueClient.GetQueueReference("taskqueue");
                return base.OnStart();
            }
            catch (Exception e)
            {
                // Exception Handling & Logging
                // Return false for OnStart
                
                return false;
            }
        }

        public void GetTasks()
        {
            if (queue == null)
                return;

            try
            {
                //Pull 10 - 15 rows from database. Just numbers and letters. No XML.
            }
            catch (Exception ex)
            {
                
            }
        }
    }
}

2 回答

  • 0

    此问题始于2017年1月24日星期二 . 在此日期之前,我从未遇到过 Worker 角色回收问题 . 美国东部时间晚上9点左右,我的 Worker 角色进入繁忙状态 . CPU达到90% . 它保持这种方式超过10个小时 . 它从一个角色开始,然后传播给其他角色

    操作系统升级后似乎没有达到就绪状态 . 更多信息,我们可以参考document .

    忙碌(稳定角色... [01 / 28T13:28Z]角色将回收 . 最后一次OnRoleRun正常返回 . 上次退出时间:WaWorkerHost无法加载角色程序集:XX.TaskRole,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = NULL

    根据您提到的错误信息,它表示缺少运行时依赖性 . 以下是从Common issues that cause roles to recycle剪断的 .

    •如果使用Visual Studio,请确保项目中不属于Azure SDK或.NET Framework的每个引用程序集的“复制本地”属性设置为“True” . •确保web.config文件未引用编译元素中的任何未使用的程序集 . •每个.cshtml文件的Build Action都设置为Content . 这可确保文件在包中正确显示,并使其他引用的文件显示在包中 .

    我还找到另一个article关于"Cloud Services roles recycling with the error" System.IO.FileLoadException: Could not load file or assembly . 更多细节信息请参考 .

  • 0

    Microsoft.WindowsAzure.ServiceRuntime存在程序集引用错误 . 正确的引用是\ packages \ Microsoft.WindowsAzure.SDK.2.9.0 \ lib \ Microsoft.WindowsAzure.ServiceRuntime.dll . 相反,我引用了我的C:驱动器上的那个 . 我使用NuGet将组件添加到我的项目中并且它有效 .

相关问题