Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
86522a9c
Unverified
Commit
86522a9c
authored
Sep 28, 2026
by
vercel-fleet-prod[bot]
Committed by
GitHub
Sep 28, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve queued snapshot work
Co-authored-by:
Luke Sandberg
<
210140+lukesandberg@users.noreply.github.com
>
parent
3ecbba4e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
8 deletions
+39
-8
storage.rs
turbopack/crates/turbo-tasks-backend/src/backend/storage.rs
+39
-8
No files found.
turbopack/crates/turbo-tasks-backend/src/backend/storage.rs
View file @
86522a9c
...
@@ -314,7 +314,10 @@ impl Storage {
...
@@ -314,7 +314,10 @@ impl Storage {
)
->
Vec
<
SnapshotShard
<
'l
,
P
>>
{
)
->
Vec
<
SnapshotShard
<
'l
,
P
>>
{
let
guard
=
Arc
::
new
(
guard
);
let
guard
=
Arc
::
new
(
guard
);
let
modified_count
=
self
.modified_count
.swap
(
0
,
Ordering
::
Relaxed
);
let
modified_count
=
self
.modified_count
.swap
(
0
,
Ordering
::
Relaxed
);
if
modified_count
==
0
&&
!
drain_entries
{
// `modified_count` is only a hint: an increment and its queue push are separate, and a
// crossing undo may saturating-decrement after a snapshot claimed its own increment. Only
// skip when both signals agree that there is no work.
if
modified_count
==
0
&&
self
.dirty_tasks
.is_empty
()
&&
!
drain_entries
{
return
Vec
::
new
();
return
Vec
::
new
();
}
}
...
@@ -392,7 +395,8 @@ impl Storage {
...
@@ -392,7 +395,8 @@ impl Storage {
// Enter snapshot mode first so concurrent modifications switch to the during-snapshot
// Enter snapshot mode first so concurrent modifications switch to the during-snapshot
// path and stop incrementing the pre-snapshot count.
// path and stop incrementing the pre-snapshot count.
self
.snapshot_mode
.store
(
true
,
Ordering
::
SeqCst
);
self
.snapshot_mode
.store
(
true
,
Ordering
::
SeqCst
);
let
has_modifications
=
self
.modified_count
.load
(
Ordering
::
Relaxed
)
>
0
;
let
has_modifications
=
self
.modified_count
.load
(
Ordering
::
Relaxed
)
>
0
||
!
self
.dirty_tasks
.is_empty
();
(
SnapshotGuard
::
new
(
self
),
has_modifications
)
(
SnapshotGuard
::
new
(
self
),
has_modifications
)
}
}
...
@@ -1513,6 +1517,27 @@ mod tests {
...
@@ -1513,6 +1517,27 @@ mod tests {
assert_eq!
(
storage
.map
.task_id_scan_count
(),
scans
+
1
);
assert_eq!
(
storage
.map
.task_id_scan_count
(),
scans
+
1
);
}
}
#[tokio
::
test(flavor
=
"multi_thread"
)]
async
fn
queued_dirty_task_is_not_hidden_by_zero_count_hint
()
{
let
storage
=
Storage
::
new
(
true
);
let
task_id
=
non_transient_task
(
1
);
{
let
mut
task
=
storage
.access_mut
(
task_id
);
task
.flags
.set_data_modified
(
true
);
}
storage
.dirty_tasks
.push
(
task_id
)
.unwrap
();
assert_eq!
(
storage
.modified_count
.load
(
Ordering
::
Relaxed
),
0
);
let
(
guard
,
has_modifications
)
=
storage
.start_snapshot
();
assert
!
(
has_modifications
);
let
items
:
Vec
<
_
>
=
storage
.take_snapshot
(
guard
,
&
dummy_process
,
false
)
.into_iter
()
.flat_map
(
IntoIterator
::
into_iter
)
.collect
();
assert_eq!
(
items
.len
(),
1
);
}
#[test]
#[test]
fn
dirty_counter_decrement_saturates_at_zero
()
{
fn
dirty_counter_decrement_saturates_at_zero
()
{
let
storage
=
Storage
::
new
(
true
);
let
storage
=
Storage
::
new
(
true
);
...
@@ -1558,12 +1583,18 @@ mod tests {
...
@@ -1558,12 +1583,18 @@ mod tests {
assert
!
(
!
guard
.flags
.any_modified
());
assert
!
(
!
guard
.flags
.any_modified
());
}
}
// Counter is back to zero: the next snapshot sees no modifications.
// The counter is back to zero, but the bounded work queue intentionally tolerates stale
let
(
_guard
,
has_modifications
)
=
storage
.start_snapshot
();
// IDs because it cannot remove by value. This may conservatively report work for one
assert
!
(
// cycle; the scan must still emit nothing and drain that stale entry.
!
has_modifications
,
assert_eq!
(
storage
.modified_count
.load
(
Ordering
::
Relaxed
),
0
);
"undo must decrement the dirty counter so no modifications remain"
let
(
guard
,
has_modifications
)
=
storage
.start_snapshot
();
);
assert
!
(
has_modifications
);
let
items
:
Vec
<
_
>
=
storage
.take_snapshot
(
guard
,
&
dummy_process
,
false
)
.into_iter
()
.flat_map
(
IntoIterator
::
into_iter
)
.collect
();
assert
!
(
items
.is_empty
(),
"undone work must not be persisted"
);
}
}
/// A second track on an already-modified category returns `NoChange`; undoing it is a no-op and
/// A second track on an already-modified category returns `NoChange`; undoing it is a no-op and
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment