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

Server panics due to convert unhashable struct to connnect.Error #944

Closed
blurfx opened this issue Jul 25, 2024 · 2 comments · Fixed by #951
Closed

Server panics due to convert unhashable struct to connnect.Error #944

blurfx opened this issue Jul 25, 2024 · 2 comments · Fixed by #951
Assignees
Labels
bug 🐞 Something isn't working critical 🚨 Event that must be dealt with to ensure the system

Comments

@blurfx
Copy link
Member

blurfx commented Jul 25, 2024

What happened:
During the process of handling errors by converting them to connect.Error, a panic occurs when a non-hashable error, such as mongo.CommandError, is passed.

The issue arises at the following line:

connectCode, ok := errorToConnectCode[cause]

What you expected to happen:
The server should not panic and handle non-hashable errors gracefully.

How to reproduce it:

This issue can be reproduced in the same way as #943

  1. Pass a non-hashable error, such as mongo.CommandError, in the error handling process.
  2. Observe the panic occurring when trying to handle the non-hashable error.

Anything else we need to know:

For example, mongo.CommandError struct is defined like below, and type bson.Raw(alias of []byte) and []string is unhashable. So mongo.CommandError is unhashable struct.

type CommandError struct {
	Code    int32
	Message string
	Labels  []string // Categories to which the error belongs
	Name    string   // A human-readable name corresponding to the error code
	Wrapped error    // The underlying error, if one exists.
	Raw     bson.Raw // The original server response containing the error.
}

Environment:

  • Operating system:
  • Browser and version:
  • Yorkie version: v0.4.28
  • Yorkie JS SDK version:
@blurfx blurfx added the bug 🐞 Something isn't working label Jul 25, 2024
@blurfx blurfx self-assigned this Jul 25, 2024
@hackerwins hackerwins moved this to Backlog in Yorkie Project - 2024 Jul 25, 2024
@blurfx
Copy link
Member Author

blurfx commented Jul 26, 2024

Unhashable errors are not going to have a common interface, so it's probably better to handle panic in that context with recover.

Considering just mongo for example, mongo.CommandError and mongo.WriteError, mongo.WriteException, and mongo.BulkWriteException do not have a common field, so interface checking is not possible.

@devleejb devleejb moved this from Backlog to In progress in Yorkie Project - 2024 Jul 27, 2024
@krapie
Copy link
Member

krapie commented Aug 3, 2024

We have experienced this issue while we are doing Weekly Sync.
This killed the server, so we couldn't access to the document for a while (about few seconds).

image

I think we need to prioritize this issue and fix it ASAP.

@krapie krapie added the critical 🚨 Event that must be dealt with to ensure the system label Aug 3, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Yorkie Project - 2024 Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working critical 🚨 Event that must be dealt with to ensure the system
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants