Skip to content

Conversation

@EmmyMiao87
Copy link
Contributor

@EmmyMiao87 EmmyMiao87 commented Apr 21, 2021

Although the table lock can control the simultaneous modification of the table by different threads.
But it cannot control the drop operation of the table by other threads.
For example, when drop table and table update occur at the same time.

  1. get table object by thread 1
  2. drop table by thread 2 with table lock
  3. update table object by thread 1

The above process is possible.
At this time, step 3 actually operates a table that no longer exists, which will eventually cause NullPointerException.

In fact, the modified table log after the drop table can be ignored. The reason is that it is meaningless to modify information on a table that no longer exists.

Fixed #5687

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have created an issue on (Fix Replay update replica failed when table has been dropped #5687) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If these changes need document changes, I have updated the document
  • Any dependent changes have been merged

@EmmyMiao87 EmmyMiao87 added area/catalog Issues or PRs related to catalog management kind/fix Categorizes issue or PR as related to a bug. labels Apr 21, 2021
@caiconghui
Copy link
Contributor

can we just simply skip replayUpdateReplica if table has been dropped. because someone may drop db, so we still need to lock catalog?

@morningman
Copy link
Contributor

If this problem occurs, there is something wrong with the metadata access mechanism itself.
And this error may happen again.
I think a simpler way is to judge if table is null in the unprotectUpdateReplica() method of Catalog, return directly.

@EmmyMiao87
Copy link
Contributor Author

can we just simply skip replayUpdateReplica if table has been dropped. because someone may drop db, so we still need to lock catalog?

Indeed, if we have to add db locks for this situation, basically table locks are of little significance.
I will consider skipping the replay log if the table does not exist.

@EmmyMiao87 EmmyMiao87 changed the title [Bug-fix] lock db when get table from catalog [Bug-fix] ignore modified table log when table has been dropped Apr 22, 2021
@EmmyMiao87 EmmyMiao87 changed the title [Bug-fix] ignore modified table log when table has been dropped [Bug-fix] Ignore modified table log when table has been dropped Apr 22, 2021
caiconghui
caiconghui previously approved these changes Apr 22, 2021
Copy link
Contributor

@caiconghui caiconghui left a comment

Choose a reason for hiding this comment

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

LGTM

morningman
morningman previously approved these changes Apr 22, 2021
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman added the approved Indicates a PR has been approved by one committer. label Apr 22, 2021
Although the table lock can control the simultaneous modification of the table by different threads.
But it cannot control the drop operation of the table by other threads.
For example, when drop table and table update occur at the same time.

1. get table object by thread 1
2. drop table by thread 2 with table lock
3. update table object by thread 1

The above process is possible.
At this time, step 3 actually operates a table that no longer exists, which will eventually cause the wrong metadata to be recorded.

Fixed apache#5687
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman merged commit 827f5c0 into apache:master Apr 27, 2021
EmmyMiao87 added a commit to EmmyMiao87/incubator-doris that referenced this pull request May 14, 2021
…he#5688)

[Merge from github][doris-1077][827f5c0]

Although the table lock can control the simultaneous modification of the table by different threads.
But it cannot control the drop operation of the table by other threads.
For example, when drop table and table update occur at the same time.

1. get table object by thread 1
2. drop table by thread 2 with table lock
3. update table object by thread 1

The above process is possible.
At this time, step 3 actually operates a table that no longer exists, which will eventually cause the wrong metadata to be recorded.

Fixed apache#5687

Change-Id: If0bc36efacc0188eb68d42f609b0eb80f24ea38e
morningman pushed a commit that referenced this pull request Sep 3, 2021
…6416)

fix #5378 #5391 #5688 #5973 #6155 and all replay NPE. All replay method can now throw MetaNotFoundException and caught to log a warning for potential inconsistent metadata cases.

try to establish a clear notice for future developer to check null.
w41ter pushed a commit to w41ter/incubator-doris that referenced this pull request Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/catalog Issues or PRs related to catalog management area/editlog-replay kind/fix Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replay update replica failed when table has been dropped

4 participants