Skip to content

Fix safe ts not updated#429

Merged
ti-chi-bot[bot] merged 7 commits intopingcap:raftstore-proxyfrom
CalvinNeo:try-fix-safe-ts
Mar 27, 2025
Merged

Fix safe ts not updated#429
ti-chi-bot[bot] merged 7 commits intopingcap:raftstore-proxyfrom
CalvinNeo:try-fix-safe-ts

Conversation

@CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Mar 20, 2025

What is changed and how it works?

Issue Number: ref pingcap/tiflash#10046

The problem is that coprocessor_host is Copy. However, the Copy trait is derived. So different copies of coprocessor_host are separated instances.

So we have to move tiflash_ob.register_to to a much earlier stage.

What's Changed:


Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note


Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/hold need manual test

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
@CalvinNeo CalvinNeo changed the title WIP Fix safe ts not updated Fix safe ts not updated Mar 26, 2025
@CalvinNeo
Copy link
Member Author

Tesed over pingcap/tiflash#10007

image

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/unhold

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
@CalvinNeo CalvinNeo requested a review from JaySon-Huang March 26, 2025 06:57
Copy link
Collaborator

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

IMO, some functions should return false according to the semantic

Comment on lines +225 to +227
} else {
true
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

/// Should be called everytime before we want to write apply state when
/// applying. Return a bool which indicates whether we can actually do
/// this write.
pub fn pre_write_apply_state(&self, region: &Region) -> bool {

Suggested change
} else {
true
}
} else {
false
}

Copy link
Member Author

Choose a reason for hiding this comment

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

    /// Should be called everytime before we want to write apply state when
    /// applying. Return a bool which indicates whether we can actually do
    /// this write.
    fn pre_write_apply_state(&self, _: &mut ObserverContext<'_>) -> bool {
        true
    }

The default returning value of pre_write_apply_state is true.

Comment on lines +217 to +219
} else {
true
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, it should return false according to the semantic

/// `pre_persist` is called we we want to persist data or meta for a region.
/// For example, in `finish_for` and `commit`,
/// we will separately call `pre_persist` with is_finished = true/false.
/// By returning false, we reject this persistence.
pub fn pre_persist(

Suggested change
} else {
true
}
} else {
false
}

Copy link
Member Author

Choose a reason for hiding this comment

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

    /// Should be called everytime before we write a WriteBatch into
    /// KvEngine. Returns false if we can't commit at this time.
    fn pre_persist(
        &self,
        _: &mut ObserverContext<'_>,
        _is_finished: bool,
        _cmd: Option<&RaftCmdRequest>,
    ) -> bool {
        true
    }

Comment on lines +235 to +237
} else {
true
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

/// Returns false if the message should not be stepped later.
pub fn on_raft_message(&self, msg: &RaftMessage) -> bool {

Suggested change
} else {
true
}
} else {
false
}

Copy link
Member Author

Choose a reason for hiding this comment

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

pub trait RaftMessageObserver: Coprocessor {
    /// Returns false if the message should not be stepped later.
    fn on_raft_message(&self, _: &RaftMessage) -> bool {
        true
    }
}

@CalvinNeo CalvinNeo requested a review from JaySon-Huang March 27, 2025 02:20
@ti-chi-bot ti-chi-bot bot added the lgtm label Mar 27, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 27, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-27 04:02:56.23263945 +0000 UTC m=+1105869.916875545: ☑️ agreed by JaySon-Huang.

@ti-chi-bot ti-chi-bot bot added the approved label Mar 27, 2025
@ti-chi-bot ti-chi-bot bot merged commit 9a6839a into pingcap:raftstore-proxy Mar 27, 2025
4 checks passed
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Apr 23, 2025
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
CalvinNeo added a commit to CalvinNeo/tidb-engine-ext that referenced this pull request Apr 23, 2025
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
ti-chi-bot bot pushed a commit that referenced this pull request Apr 24, 2025
ref pingcap/tiflash#10046

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
CalvinNeo added a commit that referenced this pull request Apr 24, 2025
* Fix safe ts not updated (#429)

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>

* fix

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>

---------

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
JaySon-Huang added a commit to pingcap/tiflash that referenced this pull request Apr 25, 2025
…#10134)

Note:
* This change to the FFI interface for proxy adaptation. And the related
issue is currently suspected to potentially cause fluctuations in
LearnerRead latency in some cases.
#9841,
#9882
* This change to the FFI interface for proxy adaptation
#9893
* Fix stale read can not eliminate the learner read
#10132


### What problem does this PR solve?

Issue Number: ref #4982, close
#10046

Problem Summary:
 update proxy to raftstore-proxy-8.1
 Proxy PR: 
 Including:\nSubmodule contrib/tiflash-proxy caa7a0c1dd..96545a2632:
  > Fix safe ts not updated (#429) (#434)

The leader_safe_ts, self_safe_ts are always 0 in the TiFlash side,
making TiFlash can not eliminate the learner read on region without any
updates.

### What is changed and how it works?

For detailed reasons why safe_ts failed to be updated, checkout the
description on pingcap/tidb-engine-ext#429.

### Check List

Tests <!-- At least one of them must be included. -->

- [ ] Unit test
- [ ] Integration test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No code

Side effects

- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Breaking backward compatibility

Documentation

- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ ] Contains variable changes
- [ ] Contains experimental features
- [ ] Changes MySQL compatibility

### Release note

<!-- bugfix or new feature needs a release note -->

```release-note
Fix the issue that `SELECT ... AS OF TIMESTAMP` can not eliminate the learner read on TiFlash as expected
```

---------

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Co-authored-by: Calvin Neo <CalvinNeo@users.noreply.github.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Co-authored-by: Calvin Neo <calvinneo1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants