Skip to content

Add tests for cancellation in fixpoints#1085

Closed
Veykril wants to merge 1 commit into
salsa-rs:masterfrom
Veykril:veykril/push-nkqvvltwzplm
Closed

Add tests for cancellation in fixpoints#1085
Veykril wants to merge 1 commit into
salsa-rs:masterfrom
Veykril:veykril/push-nkqvvltwzplm

Conversation

@Veykril

@Veykril Veykril commented Apr 16, 2026

Copy link
Copy Markdown
Member

revision_bump_clears_poisoned_memo replicates the issue discussed in #1063

@netlify

netlify Bot commented Apr 16, 2026

Copy link
Copy Markdown

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit a3590b7
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/69e09fdd6f025b000845aba4

let t2 = thread::spawn({
let mut db_writer = db_writer;
move || {
db_writer.trigger_lru_eviction();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess we have the same problem when someone calls trigger_cancellation, since it doesn't bump a new revision either.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea, both of those have the same issue. We don't really need to merge this right now, just put this up so I don't lose it. So yea, unsure what we wanna do here, either we need to remove these functions (which would be a shame, their point is that they do not bump the revision), or we need to figure out how to handle poisoning differently. In r-a we'll avoid calling these for now as the gain from their use is marginal.

@MichaReiser

Copy link
Copy Markdown
Contributor

What makes cycle recovery tricky is that there's no guarantee that queries will be executed in the same order after they've been cancelled. E.g., if we have a -> b -> a ' and the query gets canceled, there's a chance that the execution plan now is executed b -> a -> b`.

A possibility is to walk the entire dependency tree and nuke all memos.

@Veykril

Veykril commented Apr 16, 2026

Copy link
Copy Markdown
Member Author

You mean the plan changes the next time someone enters the cycle? What would be the issue with it changing?

@MichaReiser

Copy link
Copy Markdown
Contributor

You mean the plan changes the next time someone enters the cycle? What would be the issue with it changing?

Yes, because the user calls a different root query.

The issue with it is that it requires invalidating all provisional memoized values that participated in the query because the iteration count isn't sufficient to distinguish a provisional memoized value that was computed when entering from a from one computed when entering from b (and the values from iteration 2 could be different dependend on what the root query is)

@MichaReiser

Copy link
Copy Markdown
Contributor

I believe we're now also seeing instances of this in ty (astral-sh/ty#3339 (comment))

If I remember correctly, why we saw a hang previously was that a query that now should re-execute never did because validate_same_iteration always returned true.

https://github.com/MichaReiser/salsa/blob/d1c1ee10a464a7644c5b27bf7350b56fd771997e/src/function/maybe_changed_after.rs#L606-L625

But maybe this is no longer an issue, now that we rewrote cycle handling.

@MichaReiser

Copy link
Copy Markdown
Contributor

I added the tests as part of #1100

@MichaReiser MichaReiser closed this Jun 4, 2026
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

Successfully merging this pull request may close these issues.

2 participants