-
Notifications
You must be signed in to change notification settings - Fork 31
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
Don't finish the lambda until all logs will appear in the output #64
Comments
will not just a stdout flush help? |
Does erlang have this? I tried to find this in the past and didn't find. |
Seems like the main reason why messages would appear only on a subsequent call is that messages are being processed asynchronously by I assume that a workaround like this would reduce the number of "missed" messages, waiting error_logger to process all the "log" messages before thaw kicks in: diff --git a/src/erllambda_poller.erl b/src/erllambda_poller.erl
index af9314d..36e7cf1 100644
--- a/src/erllambda_poller.erl
+++ b/src/erllambda_poller.erl
@@ -160,6 +160,7 @@ invoke_next(#state{runtime_addr = Addr, aws_cfg = AwsCfg}) ->
"/", ?API_VERSION/binary,
?INVOKE_NEXT_PATH/binary>>),
erllambda:message("Invoke Next path ~p ~s", [os:system_time(millisecond), FullPath]),
+ gen_event:sync_notify(error_logger, thaw),
%% infinity due to container Freeze/thaw behaviour
case request(FullPath, get, [], "", infinity, AwsCfg) of
{ok, {{200, _}, Hdrs, Rsp}} ->
@@ -179,6 +180,7 @@ invoke_success(#state{runtime_addr = Addr, aws_cfg = AwsCfg}, AwsReqId, Body) ->
"/", ?API_VERSION/binary,
(?INVOKE_REPLAY_SUCCESS_PATH(AwsReqId))/binary>>),
erllambda:message("Invoke Success path ~p ~s", [os:system_time(millisecond), FullPath]),
+ gen_event:sync_notify(error_logger, thaw),
%% infinity due to container Freeze/thaw behaviour
case request(FullPath, post, [], encode_body(Body), infinity, AwsCfg) of
{ok, {{202, _}, _Hdrs, _Rsp}} ->
@@ -201,6 +203,7 @@ invoke_error(#state{runtime_addr = Addr, aws_cfg = AwsCfg}, AwsReqId, Body) ->
"/", ?API_VERSION/binary,
(?INVOKE_REPLAY_ERROR_PATH(AwsReqId))/binary>>),
erllambda:message("Invoke Error path ~p ~s", [os:system_time(millisecond), FullPath]),
+ gen_event:sync_notify(error_logger, thaw),
%% infinity due to container Freeze/thaw behaviour
case request(FullPath, post, [], encode_body(Body), infinity, AwsCfg) of
{ok, {{202, _}, _Hdrs, _Rsp}} ->
|
@AntonZaets i thought you're on R21+. do you still see the issue? |
@motobob as far as I see it's still an issue (with 21.3.8.4). Do you know any workarounds for that? |
but the path ^ #64 (comment) is not applied as I see. try it |
@motobob looks like it's improving the situation with logs a lot |
in the expense of...? how much longer the invocation becomes? if < 50ms send a PR and let's close it |
my lambda communicates with other services so can't really say how invocation time has changed with this patch, it varies a lot from call to call.. need some synthetic tests I think. |
just measure the AVG...
|
Problem statement
Due to asynchronous nature of the output we have a situation when logs for the particular invocation doesn't appear between
START <invocation id>
andEND <invocation id>
:In the past (in
js
version) we waited for special sequence in the output of Erlang VM and later directly calledconsole.log
fromjs
. I don't exactly know why it worked better (maybe it was overloaded, maybe it prints synchronously).Example of the logs that was truncated:
e4031f8b-b8de-4dec-bde4-8804ceb606d4
really finished with an error{"Unhandled",<<"{\"errorMessage\":\"{{invalid_cast,{read,{error,{http_error,timeout}}}},\\n {gen_server,call,[<0.521.0>,next,30000]}}\",\"errorType\":\"HandlerFailure\"}">>}
- we see this in the place where lambda is called. However, there aren't any logs in the output.I see that the next invocation is failed with OOM (
Memory Size: 2048 Max Memory Used: 2048
) and perhaps this the cause why logs from previous execution didn't appear in the logs for a new invocation.Proposal
I propose to add some option to
erllambda
config likewait_for_logs
orsync_logs
with boolean value and that option will trigger mechanism for logs synchronisation. The mechanism should be found in experiments.@motobob @velimir what do you think, guys?
@lehoff FYI
The text was updated successfully, but these errors were encountered: