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

Adding more logs around mutations and acks #12990

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions Firestore/Swift/Tests/Integration/QueryIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ class QueryIntegrationTests: FSTIntegrationTestCase {
matchesResult: ["doc2"])
}

func testFailedWriteBatch() throws {
let batch = db.batch()
.updateData(["a": 1, "b": 0], forDocument: documentRef())
let a = expectation(description: "wait for mutation")
batch.commit { [weak self] err in
XCTAssert(err != nil)
a.fulfill()
}
awaitExpectation(a)
}

func testOrQueriesWithIn() throws {
let collRef = collectionRef(
withDocuments: ["doc1": ["a": 1, "b": 0],
Expand Down
4 changes: 4 additions & 0 deletions Firestore/core/src/core/firestore_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,17 @@ void FirestoreClient::WriteMutations(std::vector<Mutation>&& mutations,
if (mutations.empty()) {
if (callback) {
user_executor_->Execute([=] { callback(Status::OK()); });
} else {
LOG_WARN("Skipping callback due to empty mutations");
}
} else {
sync_engine_->WriteMutations(
std::move(mutations), [this, callback](Status error) {
// Dispatch the result back onto the user dispatch queue.
if (callback) {
user_executor_->Execute([=] { callback(std::move(error)); });
} else {
LOG_WARN("Skipping callback due to null call back");
}
});
}
Expand Down
11 changes: 9 additions & 2 deletions Firestore/core/src/core/sync_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ void SyncEngine::HandleRejectedWrite(

DocumentMap changes = local_store_->RejectBatch(batch_id);

if (!changes.empty() && ErrorIsInteresting(error)) {
if (!changes.empty()) {
const DocumentKey& min_key = changes.min()->first;
LOG_WARN("Write at %s failed: %s", min_key.ToString(),
LOG_WARN("Write batch %s at %s failed: %s", batch_id, min_key.ToString(),
error.error_message());
}

Expand Down Expand Up @@ -469,6 +469,10 @@ void SyncEngine::NotifyUser(BatchId batch_id, Status status) {
// NOTE: Mutations restored from persistence won't have callbacks, so
// it's okay for this (or the callback below) to not exist.
if (it == mutation_callbacks_.end()) {
if (!status.ok()) {
LOG_WARN("Could not find mutation callback queue for user %s",
current_user_.uid());
}
return;
}

Expand All @@ -477,6 +481,9 @@ void SyncEngine::NotifyUser(BatchId batch_id, Status status) {
if (callback_it != callbacks.end()) {
callback_it->second(std::move(status));
callbacks.erase(callback_it);
} else if (!status.ok()) {
LOG_WARN("Could not find mutation callback for user %s and batch %s",
current_user_.uid(), batch_id);
}
}

Expand Down
Loading