-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(core/worker_events): overwrite the post
method of worker_events
#10862
Conversation
This one is waiting for a co-related PR Kong/lua-resty-events#28 to be merged and bumped |
3002db3
to
53e5a92
Compare
53e5a92
to
b146668
Compare
post
method of worker_eventspost
method of worker_events
lua-resty-events has bumped to 0.1.5. See: #10883 |
b146668
to
2da3444
Compare
c3a336b
to
7a97443
Compare
335e3ea
to
440d025
Compare
kong/global.lua
Outdated
if err == PAYLOAD_TOO_BIG_ERR then | ||
if type(data) == "string" then | ||
-- truncate the payload and send it again | ||
data = PAYLOAD_TOO_BIG_ERR .. ", truncated payload: " .. string.sub(data, 1, PAYLOAD_MAX_LEN - LEN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we send this too-big truncated payload?
Since it is truncated, could it be string.sub(data, 1, 1024)
or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a valuable thinking for the length. In my feel, any length to be truncated is not convincing enough except that we try our best and keep the content as enough as we can or we can just tell the fact that the payload is truncated without any information about the original payload. And I think try our best
would be better.
So that's my opinion, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the event receiver do something with this truncated data? if not, I think it may not make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think whether the receiver could do something or not, it depends on the receiver. The sender just try his best, and the senders don't know the ability and behavior of the receiver.
And since we have such a limit, in my feel like it should be always ok to send a payload like that size anytime.
cf564c1
to
eb7fa18
Compare
post
method of worker_eventspost
method of worker_events
post
method of worker_eventspost
method of worker_events
959454b
to
99f97b9
Compare
In a real world, where do we have this issue happening? The description says:
But where exactly, and why DAO crud event can be so big? Should we make it a bit more intelligent? E.g. truncate the fields or something? Or fix it at the source of event? |
For some plugin objects whose fields are not size-limited may be too large. As FTI-4963 suggested, the config field of
I'm afraid it would be a bit flaky to try to truncate large fields of an entity, fields to be truncated might vary with the specific entities.
Fixing it at the source of event means we have to limit the size of fields that are unlimited initially, this would introduce a breaking change which might not such necessary at this moment. |
to be sent in events lib. In some cases, Kong needs to send big payload. For example dao:crud rely on events to invalidate cache. In these cases, the size of the payload may exceeds the limit due to a large dao entity. In this PR, the `post` method of the worker_events is overwritten to take a retry action when we get the 'payload too big' error message, and the retry action is just to re-post the event with a truncated payload so that the subsequent logic that relies on the event could have a chance to be informed rather than unware at all. Based on this purpose, the retry action is taken and only takn once when the error happens. FTI-4963 KAG-1523
Co-authored-by: Chrono <[email protected]>
Co-authored-by: Chrono <[email protected]>
Co-authored-by: Chrono <[email protected]>
Co-authored-by: Chrono <[email protected]>
Co-authored-by: Chrono <[email protected]>
Co-authored-by: Chrono <[email protected]>
99f97b9
to
deca824
Compare
This PR could be closed as we had another approach for this, referring to Kong/lua-resty-events#37 |
Summary
There is a limit for the size of payload allowed to be send in events lib. In some cases, Kong needs to send big payload. For example DAO:crud rely on events to invalidate cache. In these cases, the size of the payload may exceeds the limit due a large dao entity.
In this PR, the
post
method of the worker_events is overwritten to take a retry action when we get the 'payload too big' error message, and the retry action is just to re-post the event with a truncated payload so that the subsequent logic that relies on the event could have a chance to be informed rather than unaware at all. Based on this purpose, the retry action is taken and only taken once when the error happens.The limit for the size of payload is defined inside the overwritten
post
method as a conventional value.Checklist
Full changelog
Issue reference
FTI-4963
KAG-1523