Q&A

  • MYDAC시 오류 메세지에 대해서
<!--CodeS-->
function TfrmTransMGR.GetLeastConvPCNo : Integer;
var
  i            : Integer;
  j            : Integer;
  CurCount     : Integer;
  leastNo      : Integer;
  intCountFile : Integer;
  CurNo        : Integer;
  intSum       : Integer;
  bFound       : Boolean;
begin

  Result   := -1;
  CurCount := 1000;
  leastNo  := 0;
  intSum   := 0;    
  
  try
    G_CountCritical.Enter;
    G_Critical_sstDB.Enter;
    try
      G_CurCountCheckTime := GetTickCount;

      if PC_DBConnet then
      begin  
        My_etc_Query.Close;
        My_etc_Query.SQL.Clear;
        My_etc_Query.SQL.Text := 'select * from pc_list_high where enable = 1 and enable_cnt >= current_count order by enable_cnt desc, current_count asc'; //사양 좋은 컴이 먼저 쿼리된다.
        My_etc_Query.Open;
      end
      else
      begin
        WritePRGLogforMGR( 69, 'GetLeastConvPCNo Conection Error' );
      end;

      //pc_list 등록된 변환 PC가 없다면
      if My_etc_Query.RecordCount = 0 then
      begin
        WritePRGLogforMGR( 69, 'pc_list_high Record Count Zero..' );
        Exit;
      end;

      bFound := False;
      
      My_etc_Query.First;

      for i := 0 to  My_etc_Query.RecordCount -1 do
      begin
        for j := 0 to Length(G_Socket) - 1 do
        begin
          if ( My_etc_Query.FieldByName('enable').AsInteger = 1 )
              and (Trim(G_Socket[j].Host) = Trim(My_etc_Query.FieldByName('ip').AsString))
              and (Trim(G_Socket[j].Host) <> G_LastCMD_IP )
              and (My_etc_Query.FieldByName('current_count').AsInteger <=  My_etc_Query.FieldByName('enable_cnt').AsInteger)  //1개 여유분
              then
          begin
            if G_Socket[j].Client.Connected and ( G_Socket[j].Status = S_CONNECTED ) then
            begin
              Result       := j;
              bFound       := True;
              G_LastCMD_IP :=  Trim(G_Socket[j].Host); //맨 마지막에 처리했던 Host정보를 넘겨준다.
              WritePRGLogforMGR( 69, 'GetLeastConvPCNo Found PC. PC No = '+ IntToStr(j) + ' IP = ' + My_etc_Query.FieldByName('ip').AsString );
              Break;
            end;
          end;
        end;

        if bFound then Break;
        My_etc_Query.Next;
      end;

      if not bFound then
      begin
        Result := -1;
        Exit;
      end;

      //=============================================================================================//
      //아래 로직은 현재 변환개수와 대기개수를 로그로 표시하기 위한 로직
      //=============================================================================================//
      bFound := False;
      CurNo  := 0;

      //DB커서를 처음으로 돌린다.
      My_etc_Query.First;

      for i := 0 to  My_etc_Query.RecordCount - 1 do
      begin
        //현재 모든 PC에서 변환하고 있는 개수를 누적한다.
        intSum := intSum + My_etc_Query.FieldByName('current_count').AsInteger;

        for j := 0 to Length(G_Socket) - 1 do
        begin
          if Trim(G_Socket[j].Host) = Trim(My_etc_Query.FieldByName('ip').AsString) then
          begin
            bFound := True;
            CurNo  := j;
            break;
          end;
        end;

        if not bFound then Continue;

        if (My_etc_Query.FieldByName('enable').AsInteger = 1 )  then
        begin
          G_Socket[ CurNo ].Enable       := True;
          G_Socket[ CurNo ].CurConvCount := My_etc_Query.FieldByName('current_count').AsInteger;

          //연결되어 있지 않으면 다시 연결해본다.
          if not G_Socket[ CurNo ].Client.Connected then
          begin
            try
              G_Socket[CurNo].Client.Host := G_Socket[CurNo].Host;
              G_Socket[CurNo].Client.Port := G_Socket[CurNo].Port;
              G_Socket[CurNo].Client.Connect(1000);
              WritePRGLogforMGR( i, 'Convert Socket Connected Sock2' );
            except
              on E : Exception do
              begin
                WriteErrLogforMGR( i, 'IP ' + G_Socket[CurNo].Host + ' : ' + E.Message );
              end;
            end;
          end;
          WriteCurConvLogforMGR( 'Enable Converting Count=' + IntToStr(G_Socket[ CurNo ].CurConvCount) + ', IP=' + My_etc_Query.FieldByName('ip').AsString );
        end
        else
        begin
          G_Socket[ CurNo ].Enable := False;
          WriteCurConvLogforMGR( 'Unable PC IP=' + My_etc_Query.FieldByName('ip').AsString );
        end;

        My_etc_Query.Next;
      end;

    except
      on E : Exception do
      begin
        WritePRGLogforMGR( 225, 'GetLeastConvPCNo 1 Error=' + E.Message );
      end;
    end;
    G_CurConv  := intSum;
    WritePRGLogforMGR( 225, 'G_CurConv  count=' + IntToStr(G_CurConv) );
    intNowPCNo := leastNo;
  finally
    G_Critical_sstDB.Leave;
    G_CountCritical.Leave;
  end;

  //왜 두번 하는지 모르겠음  unknown
  try
    for i := 0 to Length(G_Socket) - 1 do
    begin
      try
        intCountFile := 0;
        for j := 0 to Length(G_Socket[i].ConvFiles) - 1 do
        begin
          if G_Socket[i].Enable and G_Socket[i].Client.Connected and (G_Socket[i].Status = S_CONNECTED ) and
            ( (G_Socket[i].ConvFiles[j].SockData.Status = F_FLVCONVERTING)  or (G_Socket[i].ConvFiles[j].SockData.Status = F_MP4CONVERTING) ) then
          begin
            Inc(intCountFile);
          end;
        end;

        if G_Socket[i].Client.Connected and (G_Socket[i].Status = S_CONNECTED) and ( intCountFile <= CurCount)  then
        begin
          CurCount := intCountFile;
          leastNo  := i;
        end;

      except
        on E : Exception do
        begin
          WritePRGLogforMGR( 225, 'GetLeastConvPCNo 2 Error=' + E.Message );
        end;
      end
    end;
    WriteCurConvLogforMGR( 'Total Converting Count=' + IntToStr(G_CurConv) + ', Wating List Count=' + IntToStr(G_QconvList.Count) );
  except
    on E : Exception do
    begin
      WritePRGLogforMGR( 225, 'GetLeastConvPCNo 3 Error=' + E.Message);
    end;
  end;

end;

<!--CodeE-->

위의 코드에서


2009-06-10 23:59:59 Sock No = 225 GetLeastConvPCNo 1 Error=Assertion failure (D:\Projects\Delphi\Mydac\Source\MySqlNet.pas, line 577)

아래와 같은 로그가 찍힙니다..

Assertion failure (D:\Projects\Delphi\Mydac\Source\MySqlNet.pas, line 577)

이 부분이 무슨 예외를 말하는지 모르겠네요??

자료를 찾다보니깐...Lock문제인것 같기도 하고여...

원래 테이블에 Key가 없다가 지금 새로 Key를 만들었습니다..

혹시 저와 비슷한 오류를 경험하신 분 계시면 조언 좀 부탁드립니다...수고하세요

0  COMMENTS