Skip to content
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

ext: fix issues in net gc task #7904

Merged
merged 4 commits into from
Oct 23, 2024
Merged

ext: fix issues in net gc task #7904

merged 4 commits into from
Oct 23, 2024

Conversation

fantix
Copy link
Member

@fantix fantix commented Oct 22, 2024

  • don't run on dropping databases
  • don't call asyncio.wait([])
  • fix wrong logging without decoding JSON

Refs #7888

* don't run on dropping databases
* don't call asyncio.wait([])
* fix wrong logging without decoding JSON
@fantix fantix requested a review from scotttrinh October 22, 2024 18:38
Copy link
Contributor

@scotttrinh scotttrinh left a comment

Choose a reason for hiding this comment

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

🙏

@@ -382,7 +387,8 @@ async def gc(server: edbserver.BaseServer) -> None:
if tenant.accept_new_tasks
]
try:
await asyncio.wait(tasks)
if tasks:
await asyncio.wait(tasks)
Copy link
Member

Choose a reason for hiding this comment

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

Why aren't we using a TaskGroup here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I guess we can; this was a carried-over from an old commit, let me try again so that we know for sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah it's just unnecessary, because the Task we're in here is safe without cancellation - the server doesn't need to wait for gc() itself to clean up anything, while all child Tasks are already managed by the TaskGroup in each Tenant (by tenant.create_task()).

We would need an extra coroutine wrapper to use TaskGroup here:

async def _await_task(task: asyncio.Task):
    return await task


async def gc(server: edbserver.BaseServer) -> None:
    while True:
        try:
            async with asyncio.TaskGroup() as g:
                for tenant in server.iter_tenants():
                    if tenant.accept_new_tasks:
                        task = tenant.create_task(
                            _gc(tenant, NET_HTTP_REQUEST_TTL),
                            interruptable=False,
                        )
                        g.create_task(_await_task(task))
...

@msullivan
Copy link
Member

... looks like this doesn't fix that DROP flake though

msullivan added a commit that referenced this pull request Oct 22, 2024
When in dev/test mode, dump out all the info about the other
connections.  Hopefully this will let us figure out where they are
coming from.

See also #7904
msullivan added a commit that referenced this pull request Oct 22, 2024
When in dev/test mode, dump out all the info about the other
connections.  Hopefully this will let us figure out where they are
coming from.

See also #7904
@fantix fantix merged commit a72c8d9 into master Oct 23, 2024
23 checks passed
@fantix fantix deleted the fix-net-gc branch October 23, 2024 18:05
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.

4 participants