Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일

ICOMAdminCatalog::GetCollection에서 CO_E_ISOLEVELMISMATCH(0x8004E02F) 오류 발생

제가 만든 코드에서 다음과 같이 COM+ Admin 객체를 사용합니다.

HRESULT hr = ::CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID *)&pUnknown);
if (hr != S_OK)
{
    break;
}

CComQIPtr<ICOMAdminCatalog> pComAdminCatalog = pUnknown;
if (pComAdminCatalog == NULL)
{
    break;
}

CComPtr<ICatalogCollection> pAppColl = NULL;
CComBSTR ApplicationName = Value_Applications;
hr = pComAdminCatalog->GetCollection(ApplicationName, (IDispatch **)&pAppColl);

그런데 특정 COM+ 객체에서 저 코드가 호출되는 경우 hr 반환값이 0x8004E02F로 나옵니다. 이 오류 코드의 의미는,

0x8004E02F (CO_E_ISOLEVELMISMATCH)

Failed to get ICatalogCollection
The TxIsolation Level property for the COM+ component being created is stronger than the TxIsolationLevel for the "root" component for the transaction. The creation failed.


이렇다고 하는데... 흠~~~ ^^;

일단, 이론적으로 문제 분석을 해보겠습니다. 재현 코드를 만들어 보는 것이 좋겠지요? ^^ TxIsolation 레벨에 따라 이런 오류가 발생하려면 COM+ 객체가 2개 있어야 합니다. 그중에서 첫 번째 활성화되는 (A라고 하는) COM+ 객체가 트랜잭션에 대한 '문맥(context)'을 생성합니다. 그리고, 그 트랜잭션을 따르는 (B라고 하는) COM+ 객체가 TxIsolationLevel을 A 객체가 생성한 문맥보다 더 높은 안정성을 요구해야 합니다.

일례로 다음과 같은 문맥 설정이 됩니다.

A COM+: TransactionOption.Required, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Required, TransactionIsolationLevel.Serializable

또는 이런 식입니다.

A COM+: TransactionOption.Required, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Supported, TransactionIsolationLevel.Serializable

이런 설정으로 구성된 경우, A COM+의 메서드 내에서 B COM+의 메서드를 호출하면 CO_E_ISOLEVELMISMATCH 오류가 발생합니다.

반면 다음과 같은 식에서는 문제가 없습니다. (테스트는 안 해봤습니다. 아마도! ^^)

A COM+: TransactionOption.Disabled, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Required, TransactionIsolationLevel.Serializable

A COM+: TransactionOption.NotSupported, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Required, TransactionIsolationLevel.Serializable

A COM+: TransactionOption.Required, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.RequiresNew, TransactionIsolationLevel.Serializable

왜냐하면, A COM+ 객체가 생성한 문맥의 트랜잭션 환경을 B COM+ 객체에서 따르지 않기 때문에 TransactionIsolationLevel의 영향이 없습니다.




그런데, 재미있는 것은 제 경우에 COM+ 메서드 내에서 활성화되긴 하지만 제가 활성화하려는 ICOMAdminCatalog는 COM+에 직접적으로 등록되어 있지 않기 때문에 위의 상황과 별개로 보입니다. 그래서 좀 혼란스러웠는데요, 다행히 다음의 문서에서 문제의 원인을 찾을 수 있었습니다.

Accessing the COM+ Catalog
; https://docs.microsoft.com/en-us/windows/win32/cossdk/accessing-the-com--catalog

When you initiate programmatic administration by instantiating a COMAdminCatalog object, this object opens a session with the local catalog server. Requests for collections or collection items on the local catalog are handled by the local catalog server. When you connect to a remote machine, you are communicating with the catalog server on that machine.


즉, COMAdminCatalog는 내부적으로 "the local catalog server"를 이용하고 있으며 이것은 "COM+ Applications"에서 늘 활성화되어 있는 "System Application"의 "Catsrv.CatalogServer"를 지칭하는 것으로 보입니다. 예상할 수 있듯이, 이는 Serializable로 되어 있습니다.

complus_getcatalog_error_0.png

실제로 이 코드가 문제를 일으키는지 테스트를 해봐야 할 텐데요. 이를 위해 예전에 만들어 두었던 COM+를,

관리자 권한이 필요한 작업을 COM+에 대행
; https://www.sysnet.pe.kr/2/0/1290

문제가 되었던 COM+ 객체의 환경처럼 TransactionIsolationLevel을 ReadCommitted로 설정한 후,

complus_getcatalog_error_1.png

테스트해보면 정확히 ICOMAdminCatalog::GetCollection 호출에서 "0x8004E02F (CO_E_ISOLEVELMISMATCH)" 예외가 발생합니다.

(첨부 파일은 ReadCommitted로 설정된 COM+ 예제 코드를 포함합니다.)



[2016-12-19 추가] 제가 요즘 정신이 없군요. ^^; 위의 글에 대한 우회 해결책을 적는다는 것을 깜빡했습니다.

위와 같은 상황에서 Catalog 객체를 정상적으로 접근하고 싶다면 해당 코드 자체를 별도의 스레드 위에서 실행하면 됩니다. 대충 이런 식으로. ^^

std::thread t([&]()
{
    CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
    
    // ... Catalog 코드

    CoUninitialize();
});

t.join();




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 6/11/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12196정성태3/17/20208774오류 유형: 608. The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).
12195정성태3/16/202010476.NET Framework: 902. C# - 프로세스의 모든 핸들을 열람 - 세 번째 이야기
12194정성태3/16/202012811오류 유형: 607. PostgreSQL - Npgsql.NpgsqlException: sorry, too many clients already
12193정성태3/16/20209468개발 환경 구성: 485. docker - SAP Adaptive Server Enterprise 컨테이너 실행 [1]
12192정성태3/14/202011928개발 환경 구성: 484. docker - Sybase Anywhere 16 컨테이너 실행
12191정성태3/14/202012261개발 환경 구성: 483. docker - OracleXE 컨테이너 실행 [1]
12190정성태3/14/20208459오류 유형: 606. Docker Desktop 업그레이드 시 "The process cannot access the file 'C:\Program Files\Docker\Docker\resources\dockerd.exe' because it is being used by another process."
12189정성태3/13/202013264개발 환경 구성: 482. Facebook OAuth 처리 시 상태 정보 전달 방법과 "유효한 OAuth 리디렉션 URI" 설정 규칙
12188정성태3/13/202015442Windows: 169. 부팅 시점에 실행되는 chkdsk 결과를 확인하는 방법
12187정성태3/12/20208208오류 유형: 605. NtpClient was unable to set a manual peer to use as a time source because of duplicate error on '...'.
12186정성태3/12/20209314오류 유형: 604. The SysVol Permissions for one or more GPOs on this domain controller and not in sync with the permissions for the GPOs on the Baseline domain controller.
12185정성태3/11/20209943오류 유형: 603. The browser service was unable to retrieve a list of servers from the browser master...
12184정성태3/11/202011420오류 유형: 602. Automatic certificate enrollment for local system failed (0x800706ba) The RPC server is unavailable. [3]
12183정성태3/11/20209755오류 유형: 601. Warning: DsGetDcName returned information for \\[...], when we were trying to reach [...].
12182정성태3/11/202011007.NET Framework: 901. C# Windows Forms - Vista/7 이후의 Progress Bar 업데이트가 느린 문제파일 다운로드1
12181정성태3/11/202011852기타: 76. 재현 가능한 최소한의 예제 프로젝트란? - 두 번째 예제파일 다운로드1
12180정성태3/10/20208440오류 유형: 600. "Docker Desktop for Windows" - EXPOSE 포트가 LISTENING 되지 않는 문제
12179정성태3/10/202019815개발 환경 구성: 481. docker - PostgreSQL 컨테이너 실행
12178정성태3/10/202011272개발 환경 구성: 480. Linux 운영체제의 docker를 위한 tcp 바인딩 추가 [1]
12177정성태3/9/202010949개발 환경 구성: 479. docker - MySQL 컨테이너 실행
12176정성태3/9/202010363개발 환경 구성: 478. 파일의 (sha256 등의) 해시 값(checksum) 확인하는 방법
12175정성태3/8/202010447개발 환경 구성: 477. "Docker Desktop for Windows"의 "Linux Container" 모드를 위한 tcp 바인딩 추가
12174정성태3/7/20209995개발 환경 구성: 476. DockerDesktopVM의 파일 시스템 접근 [3]
12173정성태3/7/202011017개발 환경 구성: 475. docker - SQL Server 2019 컨테이너 실행 [1]
12172정성태3/7/202015881개발 환경 구성: 474. docker - container에서 root 권한 명령어 실행(sudo)
12171정성태3/6/202010815VS.NET IDE: 143. Visual Studio - ASP.NET Core Web Application의 "Enable Docker Support" 옵션으로 달라지는 점 [1]
... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...