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

Report a distinct error code for sync connection timeouts #6932

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* None.
* Add a distinct error code for timeouts (SyncConnectTimeout) rather than using the same one as for less transient failures ([PR #6932](https://github.com/realm/realm-core/pull/6932)).

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
Expand Down
2 changes: 2 additions & 0 deletions src/realm/error_codes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ ErrorCategory ErrorCodes::error_categories(Error code)
return ErrorCategory().set(ErrorCategory::runtime_error).set(ErrorCategory::sync_error);

case SyncConnectFailed:
case SyncConnectTimeout:
case SyncProtocolNegotiationFailed:
case TlsHandshakeFailed:
return ErrorCategory()
Expand Down Expand Up @@ -383,6 +384,7 @@ static const MapElem string_to_error_code[] = {
{"SyncClientResetRequired", ErrorCodes::SyncClientResetRequired},
{"SyncCompensatingWrite", ErrorCodes::SyncCompensatingWrite},
{"SyncConnectFailed", ErrorCodes::SyncConnectFailed},
{"SyncConnectTimeout", ErrorCodes::SyncConnectTimeout},
{"SyncInvalidSchemaChange", ErrorCodes::SyncInvalidSchemaChange},
{"SyncPermissionDenied", ErrorCodes::SyncPermissionDenied},
{"SyncProtocolInvariantFailed", ErrorCodes::SyncProtocolInvariantFailed},
Expand Down
19 changes: 10 additions & 9 deletions src/realm/error_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,16 @@ typedef enum realm_errno {
RLM_ERR_SYNC_CLIENT_RESET_REQUIRED = 1032,
RLM_ERR_SYNC_COMPENSATING_WRITE = 1033,
RLM_ERR_SYNC_CONNECT_FAILED = 1034,
RLM_ERR_SYNC_INVALID_SCHEMA_CHANGE = 1035,
RLM_ERR_SYNC_PERMISSION_DENIED = 1036,
RLM_ERR_SYNC_PROTOCOL_INVARIANT_FAILED = 1037,
RLM_ERR_SYNC_PROTOCOL_NEGOTIATION_FAILED = 1038,
RLM_ERR_SYNC_SERVER_PERMISSIONS_CHANGED = 1039,
RLM_ERR_SYNC_USER_MISMATCH = 1040,
RLM_ERR_TLS_HANDSHAKE_FAILED = 1041,
RLM_ERR_WRONG_SYNC_TYPE = 1042,
RLM_ERR_SYNC_WRITE_NOT_ALLOWED = 1043,
RLM_ERR_SYNC_CONNECT_TIMEOUT = 1035,
RLM_ERR_SYNC_INVALID_SCHEMA_CHANGE = 1036,
RLM_ERR_SYNC_PERMISSION_DENIED = 1037,
RLM_ERR_SYNC_PROTOCOL_INVARIANT_FAILED = 1038,
RLM_ERR_SYNC_PROTOCOL_NEGOTIATION_FAILED = 1039,
RLM_ERR_SYNC_SERVER_PERMISSIONS_CHANGED = 1040,
RLM_ERR_SYNC_USER_MISMATCH = 1041,
RLM_ERR_TLS_HANDSHAKE_FAILED = 1042,
RLM_ERR_WRONG_SYNC_TYPE = 1043,
RLM_ERR_SYNC_WRITE_NOT_ALLOWED = 1044,
Comment on lines +76 to +85
Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully no one is relying on the actual numeric values...


RLM_ERR_SYSTEM_ERROR = 1999,

Expand Down
1 change: 1 addition & 0 deletions src/realm/error_codes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ErrorCodes {
SyncClientResetRequired = RLM_ERR_SYNC_CLIENT_RESET_REQUIRED,
SyncCompensatingWrite = RLM_ERR_SYNC_COMPENSATING_WRITE,
SyncConnectFailed = RLM_ERR_SYNC_CONNECT_FAILED,
SyncConnectTimeout = RLM_ERR_SYNC_CONNECT_TIMEOUT,
SyncInvalidSchemaChange = RLM_ERR_SYNC_INVALID_SCHEMA_CHANGE,
SyncPermissionDenied = RLM_ERR_SYNC_PERMISSION_DENIED,
SyncProtocolInvariantFailed = RLM_ERR_SYNC_PROTOCOL_INVARIANT_FAILED,
Expand Down
6 changes: 4 additions & 2 deletions src/realm/sync/noinst/client_impl_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,10 @@ void Connection::handle_connect_wait(Status status)

REALM_ASSERT_EX(m_state == ConnectionState::connecting, m_state);
logger.info("Connect timeout"); // Throws
involuntary_disconnect(SessionErrorInfo{Status{ErrorCodes::SyncConnectFailed, status.reason()}, IsFatal{false}},
ConnectionTerminationReason::sync_connect_timeout); // Throws
involuntary_disconnect(
SessionErrorInfo{Status{ErrorCodes::SyncConnectTimeout, "Sync connection was not fully established in time"},
IsFatal{false}},
ConnectionTerminationReason::sync_connect_timeout); // Throws
}


Expand Down