From a1eb1dcd7ba9f3ee0771e83af31241a91bb51127 Mon Sep 17 00:00:00 2001 From: Callum Morris Date: Fri, 24 May 2024 12:43:45 +1200 Subject: [PATCH 1/2] fix: set DisableInitialHostLookup to false In an effort to prevent the intermittent error seen in https://github.com/GeoNet/tickets/issues/15591 --- aws/keyspaces/keyspaces.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aws/keyspaces/keyspaces.go b/aws/keyspaces/keyspaces.go index 5f49a81..3eb07d3 100644 --- a/aws/keyspaces/keyspaces.go +++ b/aws/keyspaces/keyspaces.go @@ -68,8 +68,11 @@ func New(host, certPath string) (Keyspaces, error) { } // Override default Consistency to LocalQuorum cluster.Consistency = gocql.LocalQuorum - // Disable initial host lookup - cluster.DisableInitialHostLookup = true + + // Enable initial host lookup. + // see https://github.com/gocql/gocql/issues/915 + // When set to true, we were seeing this error intermittently. + cluster.DisableInitialHostLookup = false } // Create session. From 697593f96ea6909c565a6b8f5a938c3c87eae446 Mon Sep 17 00:00:00 2001 From: Callum Morris Date: Fri, 24 May 2024 13:45:08 +1200 Subject: [PATCH 2/2] feat: set port explicitly Makes session creation much faster, and matches AWS Keyspaces documentation --- aws/keyspaces/keyspaces.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aws/keyspaces/keyspaces.go b/aws/keyspaces/keyspaces.go index 3eb07d3..65deb04 100644 --- a/aws/keyspaces/keyspaces.go +++ b/aws/keyspaces/keyspaces.go @@ -54,6 +54,9 @@ func New(host, certPath string) (Keyspaces, error) { cluster := gocql.NewCluster(host) ksClient.cluster = cluster + // Set port. + cluster.Port = 9142 + // When host is localhost, for example in a test environment, we don't need these settings. if host != "localhost" { authenticator, err := generateAuthenticator()