Maintain long-lived bucket connections for persistent config

Description

Overview

Sync Gateway's ServerContext contains a reference to a "BootstrapConnection" interface, which has 4 methods:

  • List available buckets

  • Get, Insert, and Update a database config within a given bucket

The current persistent config implementation (CouchbaseCluster) opens a new SDK connection for each operation it does (list buckets, get config, etc.)

This was to work around an issue where a single SDK connection cannot operate on different buckets, but is too expensive to open for each operation we do (~2 seconds)

Proposed implementation

At a high-level, we should make the implementation initialize connections for a) the cluster (to list buckets), and b) for each bucket we find/use.

We need to handle the cases where:

  • buckets are dropped or added to the server whilst this code is still running

    • We can probably do this by making "GetConfigBuckets" add/remove connections to buckets based on the list returned

  • the connection is dropped, due to a network blip

    • It might be that on an error, we retry, or we just log about it, remove the now invalid connection reference, and let the code re-initialize it

We don't need to consider using these bucket connections for other SG database operations, as those can use different authentication credentials than the bootstrap/config process.

Acceptance criteria

Functionality remains the same.
As a side-effect, persistent config loads are quicker as they do not need to set up an entirely new SDK connection every time...

Handles the above exceptional cases gracefully (bucket added/removed, connection drops) without needing to restart SG

Activity

Show:

Ben Brooks February 15, 2023 at 2:20 PM

bulk close resolves issues

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Labels

Story Points

Components

Sprint

Fix versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created June 30, 2022 at 5:14 PM
Updated August 31, 2024 at 10:58 AM
Resolved October 17, 2022 at 5:06 PM
Instabug