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

fix(worker): do not premature kill threads when not exiting #47

Merged
merged 1 commit into from
May 28, 2024

Conversation

bungle
Copy link
Member

@bungle bungle commented May 20, 2024

KAG-4480

chronolaw
chronolaw previously approved these changes May 21, 2024
Copy link
Collaborator

@chronolaw chronolaw left a comment

Choose a reason for hiding this comment

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

approved for #53 review.

@bungle bungle force-pushed the fix/worker-killing-events-prematurely branch from 56dc199 to 1a03dd9 Compare May 21, 2024 13:45
@bungle bungle force-pushed the fix/worker-killing-events-prematurely branch from 1a03dd9 to 12d74f6 Compare May 21, 2024 16:13
outsinre
outsinre previously approved these changes May 22, 2024
@outsinre
Copy link
Collaborator

outsinre commented May 27, 2024

@bungle @chronolaw can we merge this now?

@bungle bungle dismissed stale reviews from outsinre and chronolaw via d3bfdd0 May 27, 2024 08:52
@bungle bungle force-pushed the fix/worker-killing-events-prematurely branch 6 times, most recently from e37554c to 5fb3f1d Compare May 27, 2024 09:24
@bungle bungle force-pushed the fix/worker-killing-events-prematurely branch 2 times, most recently from 9d7e392 to 681cac7 Compare May 27, 2024 10:05
ngx.shared.dict:set("broker-pid", ngx.worker.pid())
end

if id == 0 or id == 1 then
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about the id == 2? The broker itself also receive the event.

Copy link
Member Author

@bungle bungle May 28, 2024

Choose a reason for hiding this comment

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

@outsinre, broker runs on id=2, see (and in this test I am not interested in broker as that is what is about to crash and hard to make it with current design reliable):
https://github.com/Kong/lua-resty-events/pull/47/files#diff-f8f62b1b0529d11f96be1a1f25b7f11df85ce86fb864528bd0d623f14bf22278R23

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, worker 0 and worker 1 will output debug logs for testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just wonder if we should test broker's output as well.

Since broker is down in this test case, it is OK without it.

@chronolaw
Copy link
Collaborator

There are some commented code in test case, I suggest to remove them before it merged.

@bungle bungle force-pushed the fix/worker-killing-events-prematurely branch from 681cac7 to d570fd7 Compare May 28, 2024 06:38
@bungle
Copy link
Member Author

bungle commented May 28, 2024

There are some commented code in test case, I suggest to remove them before it merged.

@chronolaw, It is left for further enhancements, when we get them done. Not to be removed (I added comment about it).

@bungle bungle force-pushed the fix/worker-killing-events-prematurely branch from d570fd7 to 2af6d7e Compare May 28, 2024 06:41
ngx.shared.dict:set("broker-pid", ngx.worker.pid())
end

if id == 0 or id == 1 then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, worker 0 and worker 1 will output debug logs for testing.

@bungle bungle merged commit 0f820d5 into Kong:main May 28, 2024
8 checks passed
@bungle bungle deleted the fix/worker-killing-events-prematurely branch May 28, 2024 07:13
bungle added a commit to bungle/lua-resty-events that referenced this pull request May 28, 2024
### Summary

- fix(tests): fix tests to not be order dependent on multi-worker scenario (Kong#46)
- chore(callback): remove unnecessary assert when the type is already checked (Kong#50)
- chore(queue): rename DEFAULT_QUEUE_LEN to more meaningful MAX_QUEUE_PREALLOCATE (Kong#52)
- chore(callback): split get_callback_list to two functions to avoid unnecessary table creation (Kong#51)
- fix(worker): do not premature kill threads when not exiting (Kong#47)
- fix(broker): do not premature kill threads when not exiting (Kong#48)
- fix(worker): separate communication and event processing to different timers (Kong#53) - caused by Kong#47
@bungle bungle mentioned this pull request May 28, 2024
bungle added a commit to bungle/lua-resty-events that referenced this pull request May 28, 2024
### Summary

- fix(tests): fix tests to not be order dependent on multi-worker scenario (Kong#46)
- chore(callback): remove unnecessary assert when the type is already checked (Kong#50)
- chore(queue): rename DEFAULT_QUEUE_LEN to more meaningful MAX_QUEUE_PREALLOCATE (Kong#52)
- chore(callback): split get_callback_list to two functions to avoid unnecessary table creation (Kong#51)
- fix(worker): do not premature kill threads when not exiting (Kong#47)
- fix(broker): do not premature kill threads when not exiting (Kong#48)
- fix(worker): separate communication and event processing to different timers (Kong#53) - caused by Kong#47
bungle added a commit to bungle/lua-resty-events that referenced this pull request May 28, 2024
### Summary

- fix(tests): fix tests to not be order dependent on multi-worker scenario (Kong#46)
- chore(callback): remove unnecessary assert when the type is already checked (Kong#50)
- chore(queue): rename DEFAULT_QUEUE_LEN to more meaningful MAX_QUEUE_PREALLOCATE (Kong#52)
- chore(callback): split get_callback_list to two functions to avoid unnecessary table creation (Kong#51)
- fix(worker): do not premature kill threads when not exiting (Kong#47)
- fix(broker): do not premature kill threads when not exiting (Kong#48)
- fix(worker): separate communication and event processing to different timers (Kong#53) - caused by Kong#47
bungle added a commit that referenced this pull request May 28, 2024
### Summary

- fix(tests): fix tests to not be order dependent on multi-worker scenario (#46)
- chore(callback): remove unnecessary assert when the type is already checked (#50)
- chore(queue): rename DEFAULT_QUEUE_LEN to more meaningful MAX_QUEUE_PREALLOCATE (#52)
- chore(callback): split get_callback_list to two functions to avoid unnecessary table creation (#51)
- fix(worker): do not premature kill threads when not exiting (#47)
- fix(broker): do not premature kill threads when not exiting (#48)
- fix(worker): separate communication and event processing to different timers (#53) - caused by #47
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.

3 participants