Skip to content

StreamGroupInfo does not report group lag as null, but 0 when lag is unavailable. #2901

@robhop

Description

@robhop

In the special case where consumer group lag is unavailable XINFO GROUPS lag is reported as null.
The Lag property on StreamGroupInfo is long?, so the type is correct.
But when this happens, the value is set to 0 and not null.

Test using Xunit.

 public class LagTest
{
    [Theory]
    [InlineData(false)]
    [InlineData(true)]
    public void GroupLagTest(bool deleteLastEntry)
    {
        // Arrange
        const string stream = "stream";
        const string group = "group";
        NameValueEntry entry = new NameValueEntry("name", "value");

        var db = ConnectionMultiplexer.Connect("localhost").GetDatabase();
        db.Execute("FLUSHDB");
        db.StreamCreateConsumerGroup("stream", "group");
        db.StreamAdd("stream", [entry]);
        db.StreamReadGroup(stream, group, "consumer", "0-0", 1);
        db.StreamAdd("stream", [entry]);

        // Act
        var streamInfo = db.StreamInfo("stream");
        if (deleteLastEntry)
        {
            db.StreamDelete(stream, [streamInfo.LastEntry.Id]);
        }

        // Assert
        var groupInfo = db.StreamGroupInfo("stream").Single(g => g.Name == "group");
        var redisResult = db.Execute("XINFO", "GROUPS", stream);
        long? lag = (long?)redisResult[0][11];

        Assert.Equal(lag, groupInfo.Lag);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions