Skip to content

Broker cache eviction evicts entries that haven't been read by active consumers #16054

Closed

Description

@lhotari

Describe the bug

There's a performance regression with large fan-outs (large number of consumers).

#12045 changed cache eviction. The problem is that cache eviction is done to the position whatever happens to be the first cursor in the "heap" list in ManagedCursorContainer. There's a chance for a race condition: another cursor in the list might have an older position, but that hasn't been updated in the ordered data structure ("heap") when the method is called. The cache eviction will take the read position directly from the first cursor and it ignores and older positions.
When the consumer for the other cursor does a read, the entries are no more in the cache and there will be a cache miss.

To Reproduce

It should be possible to reproduce this in a multi-consumer scenario where the speed of the consumers varies.

Expected behavior

Cache eviction should properly consider all active consumers. This was the state before #12045 and #14985 changes.

Additional context
#12045, #14985, #16049

This impacts all maintenance branches since #12045 was cherry-picked to branch-2.7 (2.7.4), branch-2.8 (2.8.2) and branch-2.9 (2.9.0) at the time.

Activity

  1. added
    type/bug
    on Jun 14, 2022
  2. added this to the 2.11.0 milestone on Jun 14, 2022
  3. lhotari commented on Jun 14, 2022

    @lhotari
    MemberAuthor

    @315157973 @lordcheng10 @merlimat @codelipenghui What's your thoughts on this issue?

    I wonder if the need for #14985 was caused by the regression described in this issue?

  4. assigned and unassigned on Jun 14, 2022
  5. lhotari commented on Jul 12, 2022

    @lhotari
    MemberAuthor

    @315157973 @lordcheng10 @merlimat @codelipenghui please take a look at this issue since it seems that the broker cache is broken atm.

  6. eolivelli commented on Jul 12, 2022

    @eolivelli
    Contributor

    this is partially related
    #16421

  7. modified the milestones: 2.11.0, 2.12.0 on Jul 26, 2022
  8. lordcheng10 commented on Jul 27, 2022

    @lordcheng10
    Contributor

    I wonder if the need for #14985 was caused by the regression described in this issue?

    In #14985, miss cache is caused by data re-pushing due to restart of some consumer clients @lhotari

  9. added 3 commits that reference this issue on Aug 23, 2022
    c1220cb
    690d4d0
    8402e07
  10. added a commit that references this issue on Aug 31, 2022
    856ef15
  11. added a commit that references this issue on Oct 31, 2022
    bd27df4
  12. added a commit that references this issue on Nov 17, 2022
    3ab0b2d
  13. added a commit that references this issue on Dec 7, 2022
    aa1f660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/brokertype/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions