Skip to content

[fix][table_view] Fix deadlock in IsEmpty caused by non-reentrant mutex - #1542

Merged
crossoverJie merged 3 commits into
apache:masterfrom
zjxxzjwang:master-fix1
Oct 20, 2026
Merged

crossoverJie merged 3 commits into
apache:masterfrom
zjxxzjwang:master-fix1

Conversation

@zjxxzjwang

Copy link
Copy Markdown
Contributor

Modifications

  • In IsEmpty(), replaced tv.Size() == 0 with len(tv.data) == 0 to read the
    map length directly while already holding dataMu, avoiding the re-entrant lock.

Verifying this change

This change added tests and can be verified as follows:

  • Added TestTableViewIsEmpty integration test that exercises IsEmpty(), Size(),
    ContainsKey(), and Keys() before and after publishing messages. Prior to this
    fix, the test would hang indefinitely due to the deadlock.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable
  • If a feature is not applicable for documentation, explain why? This is a bug fix for an existing API method.

@wolfstudy

Copy link
Copy Markdown
Member
Clipboard_Screenshot_1791857922

Since tv.Size is only called within IsEmpty, if it risks triggering a deadlock, you might consider removing the tv.Size function to prevent similar issues caused by accidental calls in the future.

@wolfstudy wolfstudy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@zjxxzjwang

Copy link
Copy Markdown
Contributor Author

@crossoverJie Hello, could you help me merge this PR

@crossoverJie

Copy link
Copy Markdown
Member

@zjxxzjwang The integration test has not been passed yet. Once it is passed, this PR will be merged.

@zjxxzjwang

Copy link
Copy Markdown
Contributor Author

Can you help me re trigger the test? It looks like a testing environment issue, not a code problem @crossoverJie

@crossoverJie

Copy link
Copy Markdown
Member

@zjxxzjwang Wait a moment, I'm dealing with this issue.

@zjxxzjwang

Copy link
Copy Markdown
Contributor Author

@zjxxzjwang Wait a moment, I'm dealing with this issue.

Hello, has the integration test been fixed? Can you help me trigger the test again @crossoverJie

@crossoverJie
crossoverJie merged commit 8b026e5 into apache:master Oct 20, 2026
7 checks passed
@crossoverJie

Copy link
Copy Markdown
Member

@zjxxzjwang Done

@nodece nodece added this to the 0.22.0 milestone Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants