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

kaf topic lag not working #303

Open
rveve opened this issue Feb 16, 2024 · 10 comments
Open

kaf topic lag not working #303

rveve opened this issue Feb 16, 2024 · 10 comments

Comments

@rveve
Copy link

rveve commented Feb 16, 2024

Hi All, any example of the new lag command, it is not working for me.

 > kaf --version
kaf version 0.2.7 (c0058a7f9e17512d2a4e195e0a5e15cd3f3c6539)

> kaf topic lag kafResource
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x181019e]

goroutine 1 [running]:
main.glob..func30(0x20e95c0?, {0xc00007e8c0, 0x5?, 0x8?})
	/home/runner/work/kaf/kaf/cmd/kaf/topic.go:372 +0x69e
github.com/spf13/cobra.(*Command).execute(0x20e95c0, {0xc000035200, 0x5, 0x8})
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0x20e64e0)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x425
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
main.main()
	/home/runner/work/kaf/kaf/cmd/kaf/kaf.go:150 +0x25
 

Thank you.

@jackcipher
Copy link
Contributor

normal case

image

empty group case

image

@rveve
Copy link
Author

rveve commented Feb 17, 2024

I do not see what is wrong, I am using confluent brokers.

[nonprod]> 
[nonprod]> kaf topic create demo3 -p3 -r3
✅ Created topic!
      Topic Name:            demo3
      Partitions:            3
      Replication Factor:    3
      Cleanup Policy:        delete
[nonprod]> 
[nonprod]> kaf produce demo3
a
Sent record to partition 0 at offset 0.
b
Sent record to partition 0 at offset 1.
^C
[nonprod]> kaf consume demo3 -g demo3test
Partition:   0
Offset:      0
Timestamp:   2024-02-17 14:08:58.083 -0500 EST
a
Partition:   0
Offset:      1
Timestamp:   2024-02-17 14:09:06.509 -0500 EST
b
^C
[nonprod]> kaf topic lag demo3
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x181019e]

goroutine 1 [running]:
main.glob..func30(0x20e95c0?, {0xc00007e8c0, 0x5?, 0x8?})
	/home/runner/work/kaf/kaf/cmd/kaf/topic.go:372 +0x69e
github.com/spf13/cobra.(*Command).execute(0x20e95c0, {0xc000035200, 0x5, 0x8})
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0x20e64e0)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x425
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
main.main()
	/home/runner/work/kaf/kaf/cmd/kaf/kaf.go:150 +0x25
[nonprod]> 

@rveve
Copy link
Author

rveve commented Feb 17, 2024

[nonprod]> kaf topic describe demo3
Name:        demo3   
Internal:    false   
Compacted:   false   
Partitions:
  Partition  High Watermark  Leader  Replicas  ISR      
  ---------  --------------  ------  --------  ---      
  0          2               4       [0 4 8]   [0 4 8]  
  1          0               6       [1 5 6]   [1 5 6]  
  2          0               5       [4 5 6]   [4 5 6]  
Summed HighWatermark:  2
Config:
  Name                                     Value                                                     ReadOnly  Sensitive  
  ----                                     -----                                                     --------  ---------  
  confluent.value.schema.validation        false                                                     false     false      
  leader.replication.throttled.replicas                                                              true      false      
  message.downconversion.enable            true                                                      true      false      
  min.insync.replicas                      2                                                         false     false      
  local.retention.ms                       -2                                                        true      false      
  confluent.value.subject.name.strategy    io.confluent.kafka.serializers.subject.TopicNameStrategy  false     false      
  segment.bytes                            104857600                                                 false     false      
...

[nonprod]> kaf group describe demo3test
Group ID:        demo3test
State:           Empty
Protocol:        
Protocol Type:   consumer
Offsets:         
Members:
[nonprod]> exit

@jackcipher
Copy link
Contributor

Hi,it's a bug.I've added an error check and It's been merged.
Could you please try it again with the latest version?

@rveve
Copy link
Author

rveve commented Feb 20, 2024

HI @jackcipher , I confirm it is working now with the new fix.
Thank you a lot.

[]> kaf topic lag membersession-joined
GROUP ID                                         LAG
searchbar-actions   0
[]> 
[]> kaf group describe searchbar-actions 
Group ID:        searchbar-actions
State:           Stable
Protocol:        RoundRobinAssigner
Protocol Type:   consumer
Offsets:
  membersession-joined:
    Partition  Group Offset  High Watermark  Lag  Metadata
    ---------  ------------  --------------  ---  --------
    0          12812         12812           0    
    1          20228         20228           0    
    2          11938         11938           0
    3          152           152             0
    4          178           178             0
    5          167           167             0
    Total      45475                         0    
Members:

@rveve
Copy link
Author

rveve commented Feb 20, 2024

Also, not sure why I am getting a negative lag though.

[aws]> kaf topic lag mobile-members-membersession-joined
GROUP ID                                  LAG
bie-group-1                              -48211232598
mobile-searchbar-actions                  685566
[aws]> 

@jackcipher
Copy link
Contributor

jackcipher commented Feb 20, 2024

Negative lag mostly arises on the server side, such as when restarting Kafka incorrectly or having insufficient disk capacity. The root cause is that the consumer group's offset is lower than the high watermark of a specific topic partition.

Troubleshooting such issue can be challenging in most cases. However, to resolve it directly, try resetting the group offset to the latest available offset.

For more details, see:
https://github.com/birdayz/kaf?tab=readme-ov-file#offset-reset

@rveve
Copy link
Author

rveve commented Mar 1, 2024

Sure, Thank you a lot, but I see some discrepancy between the lag number reported by "kaf topic lag" and "kaf group describe" kaf group describe lag info is different than the one of kaf topic lag, please see below.

[prod-aws]> kaf topic lag mobile-members-membersession-joined
GROUP ID                                  LAG
bie-uas-1                                 27022
mobile-searchbar-actions                  -56
[prod-aws]> 

[prod-aws]> kaf group describe mobile-searchbar-actions
Group ID:        mobile-searchbar-actions
State:           Stable
Protocol:        RoundRobinAssigner
Protocol Type:   consumer
Offsets:         
  mobile-members-membersession-joined:
    Partition  Group Offset  High Watermark  Lag     Metadata  
    ---------  ------------  --------------  ---     --------
    0          985686126     985686176       50      
    1          985466201     985466238       37      
    2          984810884     985290724       479840  
    3          104107623     104107672       49      
    4          104131392     104131417       25      
    5          104149244     104149289       45      
    Total      3268351470                    480046  
Members:


And Again

[prod-aws]> kaf topic lag mobile-members-membersession-joined
GROUP ID                                  LAG
bie-uas-1                                 -48349471708
mobile-searchbar-actions                  -64
[prod-aws]> 

[prod-aws]> kaf group describe mobile-searchbar-actions
Group ID:        mobile-searchbar-actions
State:           Stable
Protocol:        RoundRobinAssigner
Protocol Type:   consumer
Offsets:         
  mobile-members-membersession-joined:
    Partition  Group Offset  High Watermark  Lag     Metadata  
    ---------  ------------  --------------  ---     --------
    0          985688139     985688225       86      
    1          985467922     985467949       27      
    2          984812825     985292543       479718  
    3          104109397     104109436       39      
    4          104133200     104133236       36      
    5          104151214     104151364       150     
    Total      3268362697                    480056  

@imcheck
Copy link

imcheck commented Apr 9, 2024

I faced a similar issue 😢.
The result of kaf topic lag is too big compared to kaf group describe <GROUP> --topic <TOPIC>.
Is this a bug?

@rveve
Copy link
Author

rveve commented Apr 15, 2024

It sounds a bug, I was hoping to use this new 'lag' feature of kaf instead using kafkactl to get this info.

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