From a209a0d9720c05a6383973ef375f6506eb90ee2b Mon Sep 17 00:00:00 2001 From: sylwiaszunejko Date: Wed, 19 Jun 2024 09:36:53 +0200 Subject: [PATCH 1/2] Bump scylla version to 6.0.0 and use it for all of the nodes Remove {dclocal_,}read_repair_chance options from tests as they are deprecated in scylladb/scylladb#18087. Remove `tablets` and `consistent-topology-feature` experimental flags as they are not longer experimental. --- .github/workflows/main.yml | 2 +- docker-compose.yml | 12 +++--------- metadata_cassandra.go | 2 -- metadata_scylla.go | 4 ---- recreate.go | 2 -- testdata/config/scylla.yaml | 2 -- testdata/recreate/index_golden.cql | 2 -- testdata/recreate/materialized_views_golden.cql | 6 ------ testdata/recreate/secondary_index_golden.cql | 2 -- testdata/recreate/table.cql | 3 +-- testdata/recreate/table_golden.cql | 8 -------- 11 files changed, 5 insertions(+), 40 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c2fe6b8e..53fcc1d1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: name: Build runs-on: ubuntu-latest env: - SCYLLA_IMAGE: scylladb/scylla:5.4.6 + SCYLLA_IMAGE: scylladb/scylla:6.0.0 steps: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 diff --git a/docker-compose.yml b/docker-compose.yml index e23a1e15d..77ad6b8b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,10 +33,8 @@ services: timeout: 5s retries: 18 node_2: - image: scylladb/scylla-nightly:6.0.0-rc2-0.20240602.cbf47319c1f7 + image: ${SCYLLA_IMAGE} command: | - --experimental-features consistent-topology-changes - --experimental-features tablets --smp 2 --memory 1G --seeds 192.168.100.12 @@ -49,10 +47,8 @@ services: timeout: 5s retries: 18 node_3: - image: scylladb/scylla-nightly:6.0.0-rc2-0.20240602.cbf47319c1f7 + image: ${SCYLLA_IMAGE} command: | - --experimental-features consistent-topology-changes - --experimental-features tablets --smp 2 --memory 1G --seeds 192.168.100.12 @@ -68,10 +64,8 @@ services: node_2: condition: service_healthy node_4: - image: scylladb/scylla-nightly:6.0.0-rc2-0.20240602.cbf47319c1f7 + image: ${SCYLLA_IMAGE} command: | - --experimental-features consistent-topology-changes - --experimental-features tablets --smp 2 --memory 1G --seeds 192.168.100.12 diff --git a/metadata_cassandra.go b/metadata_cassandra.go index 08723ddb4..4886fdab5 100644 --- a/metadata_cassandra.go +++ b/metadata_cassandra.go @@ -994,7 +994,6 @@ func getMaterializedViewsMetadata(session *Session, keyspaceName string) ([]Mate compaction, compression, crc_check_chance, - dclocal_read_repair_chance, default_time_to_live, extensions, gc_grace_seconds, @@ -1003,7 +1002,6 @@ func getMaterializedViewsMetadata(session *Session, keyspaceName string) ([]Mate max_index_interval, memtable_flush_period_in_ms, min_index_interval, - read_repair_chance, speculative_retry FROM %s WHERE keyspace_name = ?`, tableName) diff --git a/metadata_scylla.go b/metadata_scylla.go index b675b6c8c..7996a254e 100644 --- a/metadata_scylla.go +++ b/metadata_scylla.go @@ -553,13 +553,11 @@ func getTableMetadata(session *Session, keyspaceName string) ([]TableMetadata, e "compaction": &table.Options.Compaction, "compression": &table.Options.Compression, "crc_check_chance": &table.Options.CrcCheckChance, - "dclocal_read_repair_chance": &table.Options.DcLocalReadRepairChance, "default_time_to_live": &table.Options.DefaultTimeToLive, "gc_grace_seconds": &table.Options.GcGraceSeconds, "max_index_interval": &table.Options.MaxIndexInterval, "memtable_flush_period_in_ms": &table.Options.MemtableFlushPeriodInMs, "min_index_interval": &table.Options.MinIndexInterval, - "read_repair_chance": &table.Options.ReadRepairChance, "speculative_retry": &table.Options.SpeculativeRetry, "flags": &table.Flags, "extensions": &table.Extensions, @@ -772,13 +770,11 @@ func getViewMetadata(session *Session, keyspaceName string) ([]ViewMetadata, err "compaction": &view.Options.Compaction, "compression": &view.Options.Compression, "crc_check_chance": &view.Options.CrcCheckChance, - "dclocal_read_repair_chance": &view.Options.DcLocalReadRepairChance, "default_time_to_live": &view.Options.DefaultTimeToLive, "gc_grace_seconds": &view.Options.GcGraceSeconds, "max_index_interval": &view.Options.MaxIndexInterval, "memtable_flush_period_in_ms": &view.Options.MemtableFlushPeriodInMs, "min_index_interval": &view.Options.MinIndexInterval, - "read_repair_chance": &view.Options.ReadRepairChance, "speculative_retry": &view.Options.SpeculativeRetry, "extensions": &view.Extensions, }) { diff --git a/recreate.go b/recreate.go index 045fd3a0f..738d898a1 100644 --- a/recreate.go +++ b/recreate.go @@ -319,13 +319,11 @@ func (h toCQLHelpers) tableOptionsToCQL(ops TableMetadataOptions) ([]string, err "bloom_filter_fp_chance": ops.BloomFilterFpChance, "comment": ops.Comment, "crc_check_chance": ops.CrcCheckChance, - "dclocal_read_repair_chance": ops.DcLocalReadRepairChance, "default_time_to_live": ops.DefaultTimeToLive, "gc_grace_seconds": ops.GcGraceSeconds, "max_index_interval": ops.MaxIndexInterval, "memtable_flush_period_in_ms": ops.MemtableFlushPeriodInMs, "min_index_interval": ops.MinIndexInterval, - "read_repair_chance": ops.ReadRepairChance, "speculative_retry": ops.SpeculativeRetry, } diff --git a/testdata/config/scylla.yaml b/testdata/config/scylla.yaml index 945d184bd..68ee54a9e 100644 --- a/testdata/config/scylla.yaml +++ b/testdata/config/scylla.yaml @@ -8,5 +8,3 @@ client_encryption_options: keyfile: /etc/scylla/db.key truststore: /etc/scylla/ca.crt require_client_auth: true -# when using 5.4.x we have to specify force_schema_commit_log option -force_schema_commit_log: true diff --git a/testdata/recreate/index_golden.cql b/testdata/recreate/index_golden.cql index b902acbdb..25cdbe50e 100644 --- a/testdata/recreate/index_golden.cql +++ b/testdata/recreate/index_golden.cql @@ -16,13 +16,11 @@ CREATE TABLE gocqlx_idx.menus ( AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; CREATE INDEX menus_name_idx ON gocqlx_idx.menus (name); diff --git a/testdata/recreate/materialized_views_golden.cql b/testdata/recreate/materialized_views_golden.cql index 9e1e9408d..4ade3e5f8 100644 --- a/testdata/recreate/materialized_views_golden.cql +++ b/testdata/recreate/materialized_views_golden.cql @@ -14,13 +14,11 @@ CREATE TABLE gocqlx_mv.mv_buildings ( AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; CREATE MATERIALIZED VIEW gocqlx_mv.mv_building_by_city AS @@ -35,13 +33,11 @@ CREATE MATERIALIZED VIEW gocqlx_mv.mv_building_by_city AS AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; CREATE MATERIALIZED VIEW gocqlx_mv.mv_building_by_city2 AS @@ -59,11 +55,9 @@ CREATE MATERIALIZED VIEW gocqlx_mv.mv_building_by_city2 AS AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; diff --git a/testdata/recreate/secondary_index_golden.cql b/testdata/recreate/secondary_index_golden.cql index 274395432..579963bcf 100644 --- a/testdata/recreate/secondary_index_golden.cql +++ b/testdata/recreate/secondary_index_golden.cql @@ -16,13 +16,11 @@ CREATE TABLE gocqlx_sec_idx.menus ( AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; CREATE INDEX menus_name_idx ON gocqlx_sec_idx.menus ((location), name); diff --git a/testdata/recreate/table.cql b/testdata/recreate/table.cql index bd4bc26c3..9a649f8fb 100644 --- a/testdata/recreate/table.cql +++ b/testdata/recreate/table.cql @@ -8,8 +8,7 @@ CREATE TABLE gocqlx_table.monkeySpecies ( common_name text, population varint, average_size int -) WITH comment='Important biological records' - AND read_repair_chance = 1.0; +) WITH comment='Important biological records'; CREATE TABLE gocqlx_table.timeline ( userid uuid, diff --git a/testdata/recreate/table_golden.cql b/testdata/recreate/table_golden.cql index a70e8e81c..93df4eca3 100644 --- a/testdata/recreate/table_golden.cql +++ b/testdata/recreate/table_golden.cql @@ -16,13 +16,11 @@ CREATE TABLE gocqlx_table.loads ( AND compaction = {'class':'TimeWindowCompactionStrategy','compaction_window_size':'14','compaction_window_unit':'DAYS'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; CREATE TABLE gocqlx_table.monkeyspecies ( @@ -36,13 +34,11 @@ CREATE TABLE gocqlx_table.monkeyspecies ( AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 1 AND speculative_retry = '99.0PERCENTILE'; CREATE TABLE gocqlx_table.timeline ( @@ -59,13 +55,11 @@ CREATE TABLE gocqlx_table.timeline ( AND compaction = {'class':'LeveledCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; CREATE TABLE gocqlx_table.users_picture ( @@ -81,11 +75,9 @@ CREATE TABLE gocqlx_table.users_picture ( AND compaction = {'class':'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1 - AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0 AND speculative_retry = '99.0PERCENTILE'; From 76878dbe31cc71704aa5f0faa922a830d9691fd2 Mon Sep 17 00:00:00 2001 From: sylwiaszunejko Date: Thu, 6 Jun 2024 08:13:27 +0200 Subject: [PATCH 2/2] Fix setting up connection to non-IP sockets --- control.go | 6 +++- control_integration_test.go | 71 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 1 + integration.sh | 2 ++ testdata/config/scylla.yaml | 1 + 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 control_integration_test.go diff --git a/control.go b/control.go index 3806f45a3..5a21baf26 100644 --- a/control.go +++ b/control.go @@ -270,7 +270,11 @@ type connHost struct { func (c *controlConn) setupConn(conn *Conn) error { // we need up-to-date host info for the filterHost call below iter := conn.querySystemLocal(context.TODO()) - host, err := c.session.hostInfoFromIter(iter, conn.host.connectAddress, conn.conn.RemoteAddr().(*net.TCPAddr).Port) + defaultPort := 9042 + if tcpAddr, ok := conn.conn.RemoteAddr().(*net.TCPAddr); ok { + defaultPort = tcpAddr.Port + } + host, err := c.session.hostInfoFromIter(iter, conn.host.connectAddress, defaultPort) if err != nil { return err } diff --git a/control_integration_test.go b/control_integration_test.go new file mode 100644 index 000000000..1705730e7 --- /dev/null +++ b/control_integration_test.go @@ -0,0 +1,71 @@ +//go:build integration && scylla +// +build integration,scylla + +package gocql + +import ( + "context" + "fmt" + "net" + "testing" +) + +// unixSocketDialer is a special dialer which connects only to the maintenance_socket. +type unixSocketDialer struct { + dialer net.Dialer + socketPath string +} + +func (d unixSocketDialer) DialContext(_ context.Context, _, _ string) (net.Conn, error) { + return d.dialer.Dial("unix", d.socketPath) +} + +func TestUnixSockets(t *testing.T) { + socketPath := "/tmp/scylla/cql.m" + + c := createCluster() + c.NumConns = 1 + c.DisableInitialHostLookup = true + c.ProtoVersion = 3 + c.ReconnectInterval = 0 + c.WriteCoalesceWaitTime = 0 + + c.Events.DisableNodeStatusEvents = true + c.Events.DisableTopologyEvents = true + c.Events.DisableSchemaEvents = true + + d := net.Dialer{ + Timeout: c.Timeout, + } + if c.SocketKeepalive > 0 { + d.KeepAlive = c.SocketKeepalive + } + + c.Dialer = unixSocketDialer{ + dialer: d, + socketPath: socketPath, + } + + sess, err := c.CreateSession() + if err != nil { + panic(fmt.Sprintf("unable to create session: %v", err)) + } + + defer sess.Close() + + keyspace := "test1" + + err = createTable(sess, `DROP KEYSPACE IF EXISTS `+keyspace) + if err != nil { + t.Fatal("unable to drop keyspace if exists:", err) + } + + err = createTable(sess, fmt.Sprintf(`CREATE KEYSPACE %s + WITH replication = { + 'class' : 'SimpleStrategy', + 'replication_factor' : 1 + }`, keyspace)) + if err != nil { + t.Fatal("unable to create keyspace:", err) + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 77ad6b8b8..5a8ef974c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: public: ipv4_address: 192.168.100.11 volumes: + - /tmp/scylla:/var/lib/scylla/ - type: bind source: ./testdata/config/scylla.yaml target: /etc/scylla/scylla.yaml diff --git a/integration.sh b/integration.sh index 51f6eeb04..07d67f64b 100755 --- a/integration.sh +++ b/integration.sh @@ -27,6 +27,8 @@ function scylla_restart() { scylla_restart +sudo chmod 0777 /tmp/scylla/cql.m + readonly clusterSize=1 readonly multiNodeClusterSize=3 readonly scylla_liveset="192.168.100.11" diff --git a/testdata/config/scylla.yaml b/testdata/config/scylla.yaml index 68ee54a9e..676d513cc 100644 --- a/testdata/config/scylla.yaml +++ b/testdata/config/scylla.yaml @@ -8,3 +8,4 @@ client_encryption_options: keyfile: /etc/scylla/db.key truststore: /etc/scylla/ca.crt require_client_auth: true +maintenance_socket: workdir