[CDRIVER-4184] Assert in invalid topology in load balanced mode topology closed callback Created: 12/Oct/21  Updated: 28/Oct/23  Resolved: 02/Nov/21

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.19.2

Type: Bug Priority: Major - P3
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to CDRIVER-4254 Prohibit construction of invalid topo... Backlog
is related to CDRIVER-4145 Do not start background monitoring wh... Closed

 Description   

Background & Motivation

This assertion is hit in mongoc_client_pool_destroy under these conditions:

  • The topology type is LoadBalanced
  • The topology description fails to add the LoadBalancer server.
  • A TopologyClosed callback is set.

CDRIVER-4145 fixed a similar assertion on the TopologyOpening event. The solution was to not emit a TopologyOpening event if the topology is marked invalid (i.e. a failure to resolve any hosts, or invalid options applied through TXT lookup).

Reproducing

This can be reproduced by modifying the _test_dns_maybe_pooled function to set a topology closed callback with mongoc_apm_set_topology_closed_cb and running the test loadBalanced-replicaSet-errors.

Scope
Do not emit a TopologyClosed event if the topology is marked invalid. A TopologyOpening event is already not emitted in this case.



 Comments   
Comment by Githook User [ 04/Jan/22 ]

Author:

{'name': 'Jeremy Mikola', 'email': 'jmikola@gmail.com', 'username': 'jmikola'}

Message: CDRIVER-3723 finalize URI during client/pool construction (#921)

Introduces new mongoc_client_new_from_uri_with_error and mongoc_client_pool_new_with_error methods. Also addresses topology leak in mongoc_client_new_from_uri (CDRIVER-4251).

  • Remove redundant warnings about unused results
  • Explain why we need not handle null result from _mongoc_client_new_from_topology
  • Log URI errors in mongoc_client_new as warnings
  • Clear logs between /Client/max_staleness assertions
  • Set error instead of logging in mongoc_client_pool_new_with_error
  • Remove test expecting a client with an invalid topology
  • Revise assertions in /loadbalanced/client_uri_validation test

This no longer requires constructing a client and expecting an error through server selection.

  • Use tracing macro for return statement
  • Check MONGOC_ENABLE_SSL in mongoc_client_new_from_uri_with_error

Moving the check up from _mongoc_client_new_from_topology makes mongoc_client_new_from_uri_with_error consistent with mongoc_client_pool_new_with_error. Additionally, we add log message assertions to corresponding tests.

  • Anticipate null pool or client in SRV error tests
  • Remove obsolete tests for invalid LB topologies

These tests were previously introduced in CDRIVER-4184 but no longer apply now that we prohibit construction of clients and pools with an invalid topology.

  • _mongoc_client_new_from_topology should require a valid topology
  • Document precondition for _mongoc_client_new_from_topology

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Co-authored-by: Kevin Albertson <kevin.albertson@mongodb.com>
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/e7e15002d63cb57424f467c5f21eafa9ec0f018e

Comment by Githook User [ 02/Nov/21 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4184 don't emit closed on invalid topology (#884)
Branch: r1.19
https://github.com/mongodb/mongo-c-driver/commit/2d944671703171165b4505cdfef55450f2cf0fa0

Comment by Githook User [ 02/Nov/21 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4184 don't emit closed on invalid topology (#884)
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b93e345178a3a50352894b4be300928987f3d371

Comment by Kevin Albertson [ 31/Oct/21 ]

PR: https://github.com/mongodb/mongo-c-driver/pull/884

Generated at Wed Feb 07 21:20:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.