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

suber is freeze. #2839

Open
FrenzyPig opened this issue Jan 17, 2025 · 3 comments
Open

suber is freeze. #2839

FrenzyPig opened this issue Jan 17, 2025 · 3 comments

Comments

@FrenzyPig
Copy link

FrenzyPig commented Jan 17, 2025

pub:

using System;
using StackExchange.Redis;

class Publisher
{
    static void Main()
    {
        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("172.16.1.50");
        ISubscriber pub = redis.GetSubscriber();
        while (true)
        {
            pub.Publish(RedisChannel.Literal("channel1"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
        }
    }
}

sub:

using System;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Redis;

class Subscriber

{
    static int id = 0;
    //[System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)]
    static void Main()
    {
        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("172.16.1.50");
        ISubscriber sub = redis.GetSubscriber();

        Task.Run(async () => await sub.SubscribeAsync(RedisChannel.Literal("channel1"), HandleMessage));

        while (true)
        {
            Thread.Sleep(1000);
        }
    }
    static void HandleMessage(RedisChannel channel, RedisValue message)
    {
        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + $" id:{id++}  Received from {channel}: {message}");
    }
}

run in debug mode ,all fine!
but run in release mode, after a while,the sub program is freeze.
I add [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)] to Main(),run fine.
I dont know why... I need help,thx!

@philon-msft
Copy link
Collaborator

Are you running the latest version 2.8.24 of StackExchange.Redis? Recent versions contain improvements for subscription connection resilience.

@FrenzyPig
Copy link
Author

yes ,use the latest version.

Image

@NickCraver
Copy link
Collaborator

I'd advise taking a memory dump here to see what's happening, the best way to investigate what the freeze is would be to inspect the dump (Visual Studio is good for this, as I see in your screenshot used) and use the Debug > Windows > Threads view to see what they're stalled on.

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

3 participants