Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[.net 6] System.TimeZoneNotFoundException: The time zone ID 'Asia/Almaty' was not found on the local computer. #68

Open
Yerkon opened this issue Oct 20, 2022 · 7 comments
Assignees

Comments

@Yerkon
Copy link

Yerkon commented Oct 20, 2022

Hello,
After upgrading project from .net 5 to .net 6, error occurs on Windows Server 2019.

`

System.TimeZoneNotFoundException: The time zone ID 'Asia/Almaty' was not found on the local computer.
at System.TimeZoneInfo.FindSystemTimeZoneById(String id)
at Octonica.ClickHouseClient.Utils.TimeZoneHelper.GetTimeZoneInfo(String timeZone)
at Octonica.ClickHouseClient.Types.DateTimeTypeInfo.GetTimeZone()
at Octonica.ClickHouseClient.Types.DateTimeTypeInfo.CreateColumnWriter[T](String columnName, IReadOnlyList1 rows, ClickHouseColumnSettings columnSettings) at Octonica.ClickHouseClient.ClickHouseParameter.ParameterColumnWriterBuilder.Dispatch[T]() at Octonica.ClickHouseClient.Utils.TypeDispatcher.Dispatcher1.Dispatch[T](ITypeDispatcher1 dispatcher) at Octonica.ClickHouseClient.Utils.TypeDispatcher.Dispatch[TOut](Type type, ITypeDispatcher1 dispatcher)
at Octonica.ClickHouseClient.ClickHouseParameter.CreateParameterColumnWriter(IClickHouseTypeInfoProvider typeInfoProvider)
at Octonica.ClickHouseClient.ClickHouseCommand.<>c__DisplayClass88_0.b__0(ClickHouseParameter p)
at System.Linq.Enumerable.SelectIListIterator2.ToList() at Octonica.ClickHouseClient.ClickHouseTableWriter..ctor(String tableName, Int32 rowCount, IEnumerable1 columns)
at Octonica.ClickHouseClient.ClickHouseCommand.CreateParameterTableWriter(IClickHouseTypeInfoProvider typeInfoProvider, String tableName)
at Octonica.ClickHouseClient.ClickHouseCommand.SendQuery(Session session, CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Octonica.ClickHouseClient.ClickHouseCommand.SendQuery(Session session, CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Octonica.ClickHouseClient.ClickHouseCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean ignoreProfileEvents, Boolean async, CancellationToken cancellationToken)
at Octonica.ClickHouseClient.ClickHouseCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean ignoreProfileEvents, Boolean async, CancellationToken cancellationToken)
at Octonica.ClickHouseClient.ClickHouseCommand.ExecuteReaderAsync()
at Marketing.Utils.Database.Clickhouse.ClickhouseHelper.<>c__DisplayClass26_0.<b__0>d.MoveNext() in
--- End of stack trace from previous location ---

`

"Octonica.ClickHouseClient" Version="2.2.9"
For "Octonica.ClickHouseClient" Version="2.2.8" the same

@Yerkon
Copy link
Author

Yerkon commented Oct 20, 2022

But when running locally (Windows 10), it works

@Yerkon
Copy link
Author

Yerkon commented Oct 20, 2022

I fixed it by forcing local ICU through nuget App-local ICU. Probably, there is no ICU installed on Windows server 2019

@MrDoe
Copy link
Contributor

MrDoe commented Feb 5, 2024

I have the same problem on Windows 10 with " System.TimeZoneNotFoundException: The time zone ID 'Europe/Berlin' was not found on the local computer.".
@Yerkon How did you solve the problem? I added the following lines in my .csproj file, but I still get the error.

<ItemGroup>
    <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="72.1.0.3" />
    <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
</ItemGroup>

@Yerkon
Copy link
Author

Yerkon commented Feb 6, 2024

@MrDoe, only include in Windows platform:

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
   <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9"/>
   <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2"/>
</ItemGroup>

Also, in program you can check if IcuMode enabled with method:

 private static bool IcuMode()
 {
     SortVersion sortVersion = CultureInfo.InvariantCulture.CompareInfo.Version;
     byte[] bytes = sortVersion.SortId.ToByteArray();
     int version = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];

     return version != 0 && version == sortVersion.FullVersion;
 }

@MrDoe
Copy link
Contributor

MrDoe commented Feb 7, 2024

@Yerkon Thanks for your answer! I tried this, the IcuMode works, but I still get the error. Maybe it is an issue with .NET 8 running on Windows 10.

I debugged the library and changed

[MethodImpl(MethodImplOptions.AggressiveInlining)]
 static partial void GetTimeZoneInfoImpl(string timeZone, ref TimeZoneInfo? timeZoneInfo)
 {
     timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
 }

to

[MethodImpl(MethodImplOptions.AggressiveInlining)]  
 static partial void GetTimeZoneInfoImpl(string timeZone, ref TimeZoneInfo? timeZoneInfo)  
 {  
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))  
     {  
         timeZone = TZConvert.IanaToWindows(timeZone);  
     }  
     timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone);  
 }

in TimeZoneHelper.Net6.0.cs.

Now it works, but I get another error: ""TODO: add support for custom serialization."
But I guess this is another issue. Do you know by chance what "custom serialization" means?

The error is occuring when I try to select a DateTime64 column. As a workaround, I'm currently using toString(myDateTime64Column) in my queries.

@Yerkon
Copy link
Author

Yerkon commented Feb 9, 2024

@MrDoe, maybe @victor-sushko will help?

@SergeyMirvoda
Copy link
Contributor

Now it works, but I get another error: ""TODO: add support for custom serialization." But I guess this is another issue. Do you know by chance what "custom serialization" means?

The error is occuring when I try to select a DateTime64 column. As a workaround, I'm currently using toString(myDateTime64Column) in my queries.

In recent versions ClickHouse "breaks" wire protocol.
You can disable sparse columns feature or wait for release with sparse column see #85 (couple of days)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants