Skip to content

Enable logical replication on SerenDB projects via Console API during sync #27

@taariq

Description

@taariq

Summary

When a user runs sync against a SerenDB target and the target's wal_level is not set to logical, the command fails with an error asking the user to manually enable logical replication in their SerenDB project settings.

We should automate this by integrating with the SerenDB Console API to:

  1. Check if logical replication is enabled on the project
  2. Offer to enable it if not enabled
  3. Wait for the setting to take effect before proceeding with sync

User Story

As a user of the database replicator, I want the sync command to automatically detect and offer to enable logical replication on my SerenDB project so I don't have to manually configure it in the Console.

Technical Details

SerenDB Console API Endpoints

  • GET /api/projects/{project_id} - Returns project info including enable_logical_replication field
  • PATCH /api/projects/{project_id} - Can set enable_logical_replication: true

Authentication

  • Uses same API key format as remote execution: Authorization: Bearer seren_<key_id>_<secret>

Implementation Plan

  1. Phase 1 (Interim): Add --project-id <uuid> flag to sync command

    • User provides their SerenDB project ID
    • CLI checks and offers to enable logical replication via Console API
  2. Phase 2 (Future): Auto-detect project from endpoint hostname

    • Requires new serencore endpoint: GET /api/endpoints/by-hostname/{hostname}
    • Extracts endpoint name from connection URL and looks up project

Notes

  • Enabling logical replication will briefly suspend all active endpoints
  • Once enabled, logical replication cannot be disabled
  • Console API base URL: https://console.serendb.com

Acceptance Criteria

  • Add --project-id flag to sync command
  • Create SerenDB Console API client module
  • Check enable_logical_replication status when --project-id is provided
  • Prompt user to enable logical replication if not enabled
  • Enable logical replication via API if user confirms
  • Wait for endpoints to restart before retrying sync
  • Update documentation with new flag

Related

  • User report: sync fails with "Target database wal_level is set to 'replica', but 'logical' is required"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions