New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 774180 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 23
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

[Sync] FakeServer drops server_status, violates DCHECKs

Project Member Reported by s...@chromium.org, Oct 12 2017

Issue description

There's a lot of complexity and redundancy in the way status is returned from the request to the server, especially the FakeServer. We seem to have a sort of sandwich approach where the two ends, syncer_proto_util.cc and loopback_server.cc seem to use the pair of HttpResponse::ServerConnectionCode* server_status and int64_t* response_code, but in the middle we have the fake_server* that use int* error_code and int* response_code.

It isn't clear how the mapping between error+response <=> sttatus+response should work. Things that largely seem wrong include server_status being completely dropped [1] and response_code of -2 being treated as successful [2].

[1] https://cs.chromium.org/chromium/src/components/sync/test/fake_server/fake_server.cc?l=105
[2] https://cs.chromium.org/chromium/src/components/sync/engine_impl/net/sync_server_connection_manager.cc?l=82

If all tests are successful, we seem to avoid these inconsistencies. However, during recent test failures I hit this DCHECK [3]. You can easily repro this by modifying the loopback_server.cc to return false inside HandleGetUpdatesRequest or HandleCommitRequest, which should result in a failure that is elegantly handled by SyncerProtoUtil::PostClientToServerMessage and friends.

[3] https://cs.chromium.org/chromium/src/components/sync/engine_impl/syncer_proto_util.cc?l=389
 
Status: Available (was: Untriaged)
Could be a starter bug.

Comment 2 by gangwu@chromium.org, Jan 17 2018

Labels: Hotlist-GoodFirstBug

Comment 3 by pav...@chromium.org, Jan 29 2018

Labels: SyncHandoff2018
Labels: sync-fixit-2018q3
Labels: sync-fixit-2018q4
Owner: mastiz@chromium.org
Status: Started (was: Available)
Project Member

Comment 7 by bugdroid1@chromium.org, Nov 22

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/87645f4a76d5417dfb2525493a2e2dd3ee9515be

commit 87645f4a76d5417dfb2525493a2e2dd3ee9515be
Author: Mikel Astiz <mastiz@chromium.org>
Date: Thu Nov 22 13:31:08 2018

Move away support for net errors from FakeServer

A server shouldn't be capable of returning network errors; that belongs
some other layer that represents the network. This patch moves this
support to FakeServerHttpPostProvider which is arguably an improvement
already.

Bug:  774180 
Change-Id: I1e5ebae89ff82f2a1ece78555b79c9732a71ee02
Reviewed-on: https://chromium-review.googlesource.com/c/1348030
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610395}
[modify] https://crrev.com/87645f4a76d5417dfb2525493a2e2dd3ee9515be/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc
[modify] https://crrev.com/87645f4a76d5417dfb2525493a2e2dd3ee9515be/chrome/browser/sync/test/integration/two_client_uss_sync_test.cc
[modify] https://crrev.com/87645f4a76d5417dfb2525493a2e2dd3ee9515be/components/sync/test/fake_server/fake_server.cc
[modify] https://crrev.com/87645f4a76d5417dfb2525493a2e2dd3ee9515be/components/sync/test/fake_server/fake_server.h
[modify] https://crrev.com/87645f4a76d5417dfb2525493a2e2dd3ee9515be/components/sync/test/fake_server/fake_server_http_post_provider.cc
[modify] https://crrev.com/87645f4a76d5417dfb2525493a2e2dd3ee9515be/components/sync/test/fake_server/fake_server_http_post_provider.h

Project Member

Comment 8 by bugdroid1@chromium.org, Nov 22

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a4018c6b4fbe88b865c99347135ed25aa89592c5

commit a4018c6b4fbe88b865c99347135ed25aa89592c5
Author: Mikel Astiz <mastiz@chromium.org>
Date: Thu Nov 22 13:58:04 2018

Remove notion of ServerConnectionCode from fake server

HttpResponse::ServerConnectionCode (poorly named, because it includes
network status too) should not be exposed to the fake server (or any
server).

Instead, let the "client" construct that information based on the
network error and http response code. Specifically, the logic is moved
to LoopbackConnectionManager, which becomes more analogous to the
"production" ServerConnectionManager.

This removes some weirdness like FakeServer::SendToLoopbackServer()
dropping |server_status| altogether.

Bug:  774180 
Change-Id: I52e51925a63a08e592c40d840a9319ff2244616a
Reviewed-on: https://chromium-review.googlesource.com/c/1347286
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610402}
[modify] https://crrev.com/a4018c6b4fbe88b865c99347135ed25aa89592c5/components/sync/engine_impl/loopback_server/loopback_connection_manager.cc
[modify] https://crrev.com/a4018c6b4fbe88b865c99347135ed25aa89592c5/components/sync/engine_impl/loopback_server/loopback_server.cc
[modify] https://crrev.com/a4018c6b4fbe88b865c99347135ed25aa89592c5/components/sync/engine_impl/loopback_server/loopback_server.h
[modify] https://crrev.com/a4018c6b4fbe88b865c99347135ed25aa89592c5/components/sync/engine_impl/net/server_connection_manager.h
[modify] https://crrev.com/a4018c6b4fbe88b865c99347135ed25aa89592c5/components/sync/test/fake_server/fake_server.cc

Project Member

Comment 9 by bugdroid1@chromium.org, Nov 22

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3a64405fc3b7268b60051779deed86d09990533e

commit 3a64405fc3b7268b60051779deed86d09990533e
Author: Mikel Astiz <mastiz@chromium.org>
Date: Thu Nov 22 15:50:31 2018

Naming improvements for sync network error codes

As discussed in recent code reviews, let's emphasize the distinction
between network errors and HTTP status codes.

Bug:  774180 
Change-Id: Id9e38f5a340c887519d15d137f41facfc1f9dadb
Reviewed-on: https://chromium-review.googlesource.com/c/1348057
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610417}
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/browser_sync/test_http_bridge_factory.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/browser_sync/test_http_bridge_factory.h
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine/net/http_bridge.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine/net/http_bridge.h
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine/net/http_post_provider_interface.h
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/loopback_server/loopback_connection_manager.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/loopback_server/loopback_server.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/loopback_server/loopback_server.h
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/net/server_connection_manager.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/net/server_connection_manager.h
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/net/sync_server_connection_manager.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/net/sync_server_connection_manager_unittest.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/engine_impl/sync_manager_impl_unittest.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/test/fake_server/fake_server.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/test/fake_server/fake_server_http_post_provider.cc
[modify] https://crrev.com/3a64405fc3b7268b60051779deed86d09990533e/components/sync/test/fake_server/fake_server_http_post_provider.h

Project Member

Comment 10 by bugdroid1@chromium.org, Nov 22

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/633cd4943eb807d45d0eeb6849e6619e530da858

commit 633cd4943eb807d45d0eeb6849e6619e530da858
Author: Mikel Astiz <mastiz@chromium.org>
Date: Thu Nov 22 16:12:54 2018

Fix HTTP error codes returned by LoopbackServer

HTTP status codes were accidentally mixed up with network error codes.
The latter are negative numbers, and reproduced some DCHECK failures
given that HTTP status codes cannot be negative.

Bug:  774180 
Change-Id: I7e09d02e0b63b2e9c49019c9a538c21ed34c7291
Reviewed-on: https://chromium-review.googlesource.com/c/1348090
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610434}
[modify] https://crrev.com/633cd4943eb807d45d0eeb6849e6619e530da858/components/sync/engine_impl/loopback_server/loopback_connection_manager.cc
[modify] https://crrev.com/633cd4943eb807d45d0eeb6849e6619e530da858/components/sync/engine_impl/loopback_server/loopback_server.cc

Project Member

Comment 11 by bugdroid1@chromium.org, Nov 23

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2b062f34a6a34084889aac0e41642986a951a979

commit 2b062f34a6a34084889aac0e41642986a951a979
Author: Mikel Astiz <mastiz@chromium.org>
Date: Fri Nov 23 10:31:00 2018

Fix DCHECK failures in SyncerProtoUtil

If the HTTP request returns some status code other than 200, we treat
it as error in most relevant cases, e.g. in
ServerConnectionManager::PostBufferToPath().

We must do the very same in SyncBridgedConnection::Init() because we
otherwise enter an inconsistent state for errors like 3xx (redirects),
leading to DCHECK failures.

Bug:  774180 , 907896 
Change-Id: I6019442d0d30ee7d7e177d72974cec0eadb9a38f
Reviewed-on: https://chromium-review.googlesource.com/c/1349252
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610562}
[modify] https://crrev.com/2b062f34a6a34084889aac0e41642986a951a979/chrome/browser/sync/test/integration/sync_auth_test.cc
[modify] https://crrev.com/2b062f34a6a34084889aac0e41642986a951a979/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc
[modify] https://crrev.com/2b062f34a6a34084889aac0e41642986a951a979/components/sync/engine_impl/net/sync_server_connection_manager.cc
[modify] https://crrev.com/2b062f34a6a34084889aac0e41642986a951a979/components/sync/test/fake_server/fake_server.cc
[modify] https://crrev.com/2b062f34a6a34084889aac0e41642986a951a979/components/sync/test/fake_server/fake_server.h

Project Member

Comment 12 by bugdroid1@chromium.org, Nov 23

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1de5fe98f092af8eb038731e44c112e9edb4e6aa

commit 1de5fe98f092af8eb038731e44c112e9edb4e6aa
Author: Mikel Astiz <mastiz@chromium.org>
Date: Fri Nov 23 11:43:42 2018

Improve type safety and naming with net::HttpStatusCode

In order to avoid future issues like the one fixed recently in
https://chromium-review.googlesource.com/c/1348090, let's improve type
safety by adopting net::HttpStatusCode wherever possible.

This affects mostly server-related code (LoopbackServer and FakeServer).
Other layers are harder to change because URLFetcher itself handles ints
rather than enums.

Variable names have been updated accordingly.

Bug:  774180 
Change-Id: Ic65a8efde4038ce56bbd2dedebad8a7c890e1197
Reviewed-on: https://chromium-review.googlesource.com/c/1349310
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610575}
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/browser_sync/test_http_bridge_factory.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/browser_sync/test_http_bridge_factory.h
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine/net/http_bridge.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine/net/http_bridge.h
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine/net/http_post_provider_interface.h
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/loopback_server/loopback_connection_manager.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/loopback_server/loopback_server.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/loopback_server/loopback_server.h
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/net/server_connection_manager.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/net/server_connection_manager.h
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/net/sync_server_connection_manager.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/net/sync_server_connection_manager_unittest.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/engine_impl/sync_manager_impl_unittest.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/test/fake_server/fake_server.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/test/fake_server/fake_server.h
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/test/fake_server/fake_server_http_post_provider.cc
[modify] https://crrev.com/1de5fe98f092af8eb038731e44c112e9edb4e6aa/components/sync/test/fake_server/fake_server_http_post_provider.h

Status: Fixed (was: Started)

Sign in to add a comment