-
-
Notifications
You must be signed in to change notification settings - Fork 803
Fixed concurrency issue in MetaDb chunk expansion #9508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/Issue9500Tests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| using GreenDonut; | ||
| using HotChocolate.Types; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using static HotChocolate.Tests.TestHelper; | ||
|
|
||
| namespace HotChocolate.Execution.Integration.DataLoader; | ||
|
|
||
| public class Issue9500Tests | ||
| { | ||
| [Fact] | ||
| public async Task Composite_DataLoader_Result_Overflows_Selection_Buffer_When_Paging_Many_Nodes() | ||
| { | ||
| const int nodeCount = 100_000; | ||
|
|
||
| var executor = await CreateExecutorAsync( | ||
| c => c | ||
| .AddQueryType<Issue9500Query>() | ||
| .AddDataLoader<INoteDataLoader, NoteDataLoader>() | ||
| .ModifyRequestOptions(o => o.IncludeExceptionDetails = true)); | ||
|
|
||
| var result = await executor.ExecuteAsync( | ||
| OperationRequestBuilder.New() | ||
| .SetDocument( | ||
| $$""" | ||
| { | ||
| items(first: {{nodeCount}}) { | ||
| edges { | ||
| cursor | ||
| node { | ||
| id | ||
| note { | ||
| comment | ||
| dueDate | ||
| progress | ||
| assignee | ||
| status | ||
| priority | ||
| category | ||
| createdBy | ||
| updatedBy | ||
| title | ||
| summary | ||
| kind | ||
| owner | ||
| reviewer | ||
| milestone | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| """) | ||
| .Build()); | ||
|
|
||
| Assert.Empty(result.ExpectOperationResult().Errors); | ||
| } | ||
|
|
||
| public class Issue9500Query | ||
| { | ||
| [UsePaging(DefaultPageSize = 100000, MaxPageSize = 100000)] | ||
| public IEnumerable<Item> GetItems() | ||
| => Enumerable.Range(0, 100_000).Select(i => new Item(i)); | ||
| } | ||
|
michaelstaib marked this conversation as resolved.
|
||
|
|
||
| public class Item(int id) | ||
| { | ||
| public int Id { get; } = id; | ||
|
|
||
| public Task<Note?> GetNoteAsync( | ||
| INoteDataLoader dataLoader, | ||
| CancellationToken cancellationToken) | ||
| => dataLoader.LoadAsync(Id, cancellationToken); | ||
| } | ||
|
|
||
| public interface INoteDataLoader | ||
| : IDataLoader<int, Note>; | ||
|
|
||
| public class NoteDataLoader( | ||
| IBatchScheduler batchScheduler, | ||
| DataLoaderOptions options) | ||
| : BatchDataLoader<int, Note>(batchScheduler, options), INoteDataLoader | ||
| { | ||
| protected override Task<IReadOnlyDictionary<int, Note>> LoadBatchAsync( | ||
| IReadOnlyList<int> keys, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| return LoadAsync(keys, cancellationToken); | ||
| } | ||
|
|
||
| private static async Task<IReadOnlyDictionary<int, Note>> LoadAsync( | ||
| IReadOnlyList<int> keys, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| await Task.Delay(1, cancellationToken); | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
|
|
||
| return keys.ToDictionary( | ||
| key => key, | ||
| key => new Note( | ||
| $"Comment {key}", | ||
| $"2026-04-{(key % 28) + 1:00}", | ||
|
michaelstaib marked this conversation as resolved.
|
||
| key % 100, | ||
| $"Assignee {key}", | ||
| key % 2 == 0 ? "Open" : "Closed", | ||
| $"P{key % 5}", | ||
| $"Category {key % 7}", | ||
| $"Creator {key % 11}", | ||
| $"Updater {key % 13}", | ||
| $"Title {key}", | ||
| $"Summary {key}", | ||
| $"Kind {key % 3}", | ||
| $"Owner {key % 17}", | ||
| $"Reviewer {key % 19}", | ||
| $"Milestone {key % 23}")); | ||
| } | ||
| } | ||
|
|
||
| public record Note( | ||
| string Comment, | ||
| string DueDate, | ||
| int Progress, | ||
| string Assignee, | ||
| string Status, | ||
| string Priority, | ||
| string Category, | ||
| string CreatedBy, | ||
| string UpdatedBy, | ||
| string Title, | ||
| string Summary, | ||
| string Kind, | ||
| string Owner, | ||
| string Reviewer, | ||
| string Milestone); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.