Skip to content

Worker crashes when using S3 / sites with very short DNS TTL #30

Open
@eriede

Description

@eriede

When a worker process connection times out after 2 * the DNS TTL period has passed the worker process may crash. (nginx 1.12). AWS S3 has a very short DNS timeout and exhibits the issue.

The issue is that the peer data structure is accessed after the dynamic server releases the peer.

I have created a patch which uses reference counting on active requests instead of the interleaving scheme currently used. This will ensure that the peer's memory remains valid during outstanding requests.

Activity

zhaofeng0019

zhaofeng0019 commented on Jun 21, 2020

@zhaofeng0019

i think your solution may cause memoy leak when there are requests can't end during a TTL -- the previous pool can't be free. And may not solve the memory crash when using upstream keepalive.
i think i may solve the problem
https://github.com/zhaofeng0019/nginx-upstream-dynamic-resolve-servers
and this solution is doing some references to your solution.
would you like to check it out? thanks a lot.

eriede

eriede commented on Jun 22, 2020

@eriede
Author
zhaofeng0019

zhaofeng0019 commented on Jun 22, 2020

@zhaofeng0019

or would you please see my pull request for this project? it solves all the memory problem and works well.

eriede

eriede commented on Jun 22, 2020

@eriede
Author
zhaofeng0019

zhaofeng0019 commented on Jun 22, 2020

@zhaofeng0019

you can see that in native nginx code , all the lb option will use round robin finally, including keepalive,
so you can see in my code, i only do ngx_http_upstream_init_round_robin function when the dns result changed, you can just save the function pointer of other lb option at the init_process function.

zhaofeng0019

zhaofeng0019 commented on Jun 22, 2020

@zhaofeng0019

if do in this way, support all the native nginx lb option, no crash, i tested.

eriede

eriede commented on Jun 22, 2020

@eriede
Author

I uploaded our keepalive solution that only works for round robin lb with 1.12, to get it out in the public domain. https://github.com/eriede/nginx-upstream-dynamic-servers/tree/round-robin-keepalive. I'm happy to do a code review on your code if you would like, but I don't have the time to do testing on the various nginx versions, so I can't accept pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @eriede@zhaofeng0019

        Issue actions

          Worker crashes when using S3 / sites with very short DNS TTL · Issue #30 · GUI/nginx-upstream-dynamic-servers