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

When there are multiple upstream servers, the memory of the adguardhome will gradually increase until it goes down #6438

Closed
4 tasks done
6aink opened this issue Nov 19, 2023 · 25 comments
Assignees
Labels
bug external libs Issues that require changes in external libraries. P2: High
Milestone

Comments

@6aink
Copy link

6aink commented Nov 19, 2023

Prerequisites

Platform (OS and CPU architecture)

Linux, AMD64 (aka x86_64)

Installation

GitHub releases or script from README

Setup

On one machine

AdGuard Home version

v0.108.0-a.762+388583ce

Action

When there are multiple upstream servers, the memory of the adguardhome will gradually increase until it goes down

Expected result

Memory no longer rises and can be used normally

Actual result

memory explosion

Additional information and/or screenshots

No response

@ainar-g
Copy link
Contributor

ainar-g commented Nov 20, 2023

Unfortunately, we cannot reproduce that. Can you provide the upstreams you're using?

@ainar-g ainar-g added the waiting for data Waiting for users to provide more data. label Nov 20, 2023
@6aink
Copy link
Author

6aink commented Nov 20, 2023

You can try replicating it this way by turning off the cache and setting it to any number of upstream streams, with a request rate of 1000qps. At this point, you will see significant memory growth and the increased memory will not be reclaimed

@6aink

This comment was marked as duplicate.

@ainar-g
Copy link
Contributor

ainar-g commented Nov 22, 2023

We do not see this behaviour in our tests. The only thing that's growing are things like query log and statistics buffers and safe browsing/parental control hash caches.

If you do feel like there could be a resource leak, please collect the memory profile from your AGH by setting http.pprof.enabled to true and saving the contents of http://127.0.0.1:6060/debug/pprof/heap?debug=1.

@6aink

This comment was marked as duplicate.

@6aink

This comment was marked as duplicate.

@6aink

This comment was marked as duplicate.

@6aink
Copy link
Author

6aink commented Nov 22, 2023

@6aink
Copy link
Author

6aink commented Nov 22, 2023

this is debug log file

@6aink
Copy link
Author

6aink commented Nov 23, 2023

Memory leaks occur when parallel requests are used.

@6aink

This comment was marked as duplicate.

@duckxx
Copy link

duckxx commented Nov 23, 2023

这种情况出现在v0.108.0-b.50,有可能不是多个上游导致的,更新后,服务器4G内存在半个小时内只剩下10%的可用,CPU涨到了50%。并且只是更新,没有修改任何数据。

@6aink
Copy link
Author

6aink commented Nov 23, 2023

请问有什么办法避免这个问题吗

@duckxx
Copy link

duckxx commented Nov 23, 2023

请问有什么办法避免这个问题吗

在v0.108.0-b.49或以下版本未出现这种异常。可以尝试使用v0.108.0-b.49或以下版本。

@6aink
Copy link
Author

6aink commented Nov 23, 2023

I didn't find a memory leak with a single upstream. I suspect it has something to do with their new upstream feature in b50. Hopefully the adguardhome team can fix this memory leak.

@ainar-g
Copy link
Contributor

ainar-g commented Nov 23, 2023

Thank you for the profiles, we've been able to reproduce the goroutine leak.

@EugeneOne1, this is reproduceable using e.g. godnsbench -a udp://127.0.0.1:53 -c 100000 -q '{random}.example.com' with no cache and parallel requests for plain UDP upstreams. Please fix asap.

@ainar-g ainar-g added bug P2: High external libs Issues that require changes in external libraries. and removed waiting for data Waiting for users to provide more data. labels Nov 23, 2023
@ainar-g ainar-g added this to the v0.107.42 milestone Nov 23, 2023
@6aink
Copy link
Author

6aink commented Nov 23, 2023

Okay, thank you very much.

adguard pushed a commit to AdguardTeam/dnsproxy that referenced this issue Nov 23, 2023
Updates AdguardTeam/AdGuardHome#6438.

Squashed commit of the following:

commit 3dbe47f
Merge: dc6b77c 8f0cbea
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Nov 23 19:43:43 2023 +0300

    Merge branch 'master' into 6438-fix-leak

commit dc6b77c
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Nov 23 17:35:51 2023 +0300

    upstream: fix goroutines leak
adguard pushed a commit that referenced this issue Nov 23, 2023
Updates #6438.

Squashed commit of the following:

commit dba0750
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Nov 23 19:57:46 2023 +0300

    all: upd proxy
@EugeneOne1
Copy link
Member

@6aink, hello again. We've pushed an edge build that should fix this leak. Could you please try it out?

@6aink
Copy link
Author

6aink commented Nov 23, 2023

OK, wait a minute.

@6aink
Copy link
Author

6aink commented Nov 23, 2023

I probably observed for ten minutes, the memory has no upward trend, the problem has been solved, thank you.

@6aink
Copy link
Author

6aink commented Nov 23, 2023

I see that the memory is rising again, but not very fast. I will try to watch it for another hour.

@6aink
Copy link
Author

6aink commented Nov 23, 2023

I tested it for a few hours, and the memory stabilized at 300m, and there was no problem.

@EugeneOne1
Copy link
Member

@6aink, thanks for testing! We'll include this to the following beta release.

annguyen0 pushed a commit to annguyen0/AdGuardHome that referenced this issue Nov 27, 2023
Updates AdguardTeam#6438.

Squashed commit of the following:

commit dba0750
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Nov 23 19:57:46 2023 +0300

    all: upd proxy
@schzhn schzhn mentioned this issue Nov 29, 2023
4 tasks
@Adgbeta
Copy link

Adgbeta commented Dec 4, 2023

Edge build looks like fixed the issue so far, testing for over 4 hours, no increase of memory use.

@ainar-g ainar-g modified the milestones: v0.107.43, v0.107.42 Dec 7, 2023
@ainar-g ainar-g mentioned this issue Dec 7, 2023
4 tasks
@04bondgoods
Copy link

04bondgoods commented Dec 31, 2023

seems this issue still persists in 108.b51 version.
I encountered:

  1. agh memory cost grew to ~ 2G (~50% of total mem of 4G) after roughly 1 month
  2. after restarting agh 1 day ago, memory has grown to ~ 450MB (~12% of total memory) now
  3. memory usage should be ~ 60MB normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug external libs Issues that require changes in external libraries. P2: High
Projects
None yet
Development

No branches or pull requests

6 participants