Skip to content

Log when actor deserialization fails#881

Open
cacheburner wants to merge 1 commit into
mainfrom
milan/serialize-log
Open

Log when actor deserialization fails#881
cacheburner wants to merge 1 commit into
mainfrom
milan/serialize-log

Conversation

@cacheburner

Copy link
Copy Markdown
Contributor

We were failing to log this because we'd throw an exception before the log line.

@cacheburner cacheburner requested a review from bcaimano July 19, 2023 15:45
Comment thread src/workerd/api/actor-state.c++ Outdated
auto jsException = tryCatch.Exception();
if (!tryCatch.HasTerminated()) {
KJ_LOG(ERROR, "actor storage deserialization failed", errorMsg, jsException,
key, buf.size(), buf.slice(0, std::min(static_cast<size_t>(3), buf.size())));

@bcaimano bcaimano Jul 19, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please leave out at least buf if not also key! This could leak personally identifiable information or secrets to logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, what about the FAIL_ASSERTs below? I directly copied one of them so should that change too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, if you would. As long as we have identifying DO info from our log context, we can check the storage backend later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You absolutely sure? This comment indicates there was some thought put into this:

  // If we do hit a deserialization error, we log information that will be helpful in understanding
  // the problem but that won't leak too much about the customer's data. We include the key (to help
  // find the data in the database if it hasn't been deleted), the length of the value, and the
  // first three bytes of the value (which is just the v8-internal version header and the tag that
  // indicates the type of the value, but not its contents).

We were failing to log this because we'd throw an exception before the
log line.
@cacheburner cacheburner force-pushed the milan/serialize-log branch from 65281cf to 3a77155 Compare July 19, 2023 16:04
JSG_REQUIRE(!tryCatch.HasTerminated(),
Error, "isolate terminated while deserializing value from Durable Object storage; "
"contact us if you're wondering why you're seeing this");
auto jsException = tryCatch.Exception();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: While you're here, mind scrubbing mentions of "actor storage" or "durable object storage"? We're going to want to use this function outside of the storage api soon. 😄

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are situations where tryCatch.HasCaught() is true but tryCatch.Exception() returns an empty v8::Local. In such cases, we want to treat it the same as tryCatch.CanContinue() == false

auto jsException = tryCatch.Exception();
if (!tryCatch.HasTerminated()) {
KJ_LOG(ERROR, "actor storage deserialization failed", errorMsg, jsException,
key, buf.size(), buf.slice(0, std::min(static_cast<size_t>(3), buf.size())));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, if you would. As long as we have identifying DO info from our log context, we can check the storage backend later.

key, buf.size(), buf.slice(0, std::min(static_cast<size_t>(3), buf.size())));
JSG_FAIL_REQUIRE(Error,
"isolate terminated while deserializing value from Durable Object storage; "
"contact us if you're wondering why you're seeing this");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Failed to deserialize value into isolate", we were hoping to make this message less misleading!

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.

4 participants