Skip to content

Commit 1ba8c8c

Browse files
authored
Merge branch 'scylladb:master' into invalid-number-of-shards
2 parents 7ffa870 + 426c16f commit 1ba8c8c

File tree

55 files changed

+1778
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1778
-297
lines changed

cassandra_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,21 +664,21 @@ func TestCAS(t *testing.T) {
664664
}
665665

666666
failBatch = session.Batch(LoggedBatch)
667-
failBatch.Query("UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
667+
failBatch.Query("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
668668
if _, _, err := session.ExecuteBatchCAS(failBatch, new(bool)); err == nil {
669669
t.Fatal("update should have errored")
670670
}
671671
// make sure MapScanCAS does not panic when MapScan fails
672672
casMap = make(map[string]interface{})
673673
casMap["last_modified"] = false
674-
if _, err := session.Query(`UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?`,
674+
if _, err := session.Query(`UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?`,
675675
modified).MapScanCAS(casMap); err == nil {
676676
t.Fatal("update should hvae errored", err)
677677
}
678678

679679
// make sure MapExecuteBatchCAS does not panic when MapScan fails
680680
failBatch = session.Batch(LoggedBatch)
681-
failBatch.Query("UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
681+
failBatch.Query("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
682682
casMap = make(map[string]interface{})
683683
casMap["last_modified"] = false
684684
if _, _, err := session.MapExecuteBatchCAS(failBatch, casMap); err == nil {

cluster.go

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ type ClusterConfig struct {
206206
// Also, it describes a maximum number of connections at the same time.
207207
// Default: 2
208208
NumConns int
209+
// The gocql driver may hold excess shard connections to reuse them when existing connections are dropped.
210+
// This configuration variable defines the limit for such excess connections. Once the limit is reached,
211+
// gocql starts dropping any additional excess connections.
212+
// The limit is computed as `MaxExcessShardConnectionsRate` * <number_of_shards>.
213+
MaxExcessShardConnectionsRate float32
209214
// Maximum cache size for prepared statements globally for gocql.
210215
// Default: 1000
211216
MaxPreparedStmts int
@@ -359,33 +364,34 @@ type Dialer interface {
359364
// the same host, and will not mark the node being down or up from events.
360365
func NewCluster(hosts ...string) *ClusterConfig {
361366
cfg := &ClusterConfig{
362-
Hosts: hosts,
363-
CQLVersion: "3.0.0",
364-
Timeout: 11 * time.Second,
365-
ConnectTimeout: 60 * time.Second,
366-
ReadTimeout: 11 * time.Second,
367-
WriteTimeout: 11 * time.Second,
368-
Port: 9042,
369-
NumConns: 2,
370-
Consistency: Quorum,
371-
MaxPreparedStmts: defaultMaxPreparedStmts,
372-
MaxRoutingKeyInfo: 1000,
373-
PageSize: 5000,
374-
DefaultTimestamp: true,
375-
DriverName: defaultDriverName,
376-
DriverVersion: defaultDriverVersion,
377-
MaxWaitSchemaAgreement: 60 * time.Second,
378-
ReconnectInterval: 60 * time.Second,
379-
ConvictionPolicy: &SimpleConvictionPolicy{},
380-
ReconnectionPolicy: &ConstantReconnectionPolicy{MaxRetries: 3, Interval: 1 * time.Second},
381-
InitialReconnectionPolicy: &NoReconnectionPolicy{},
382-
SocketKeepalive: 15 * time.Second,
383-
WriteCoalesceWaitTime: 200 * time.Microsecond,
384-
MetadataSchemaRequestTimeout: 60 * time.Second,
385-
DisableSkipMetadata: true,
386-
WarningsHandlerBuilder: DefaultWarningHandlerBuilder,
387-
Logger: &defaultLogger{},
388-
DNSResolver: defaultDnsResolver,
367+
Hosts: hosts,
368+
CQLVersion: "3.0.0",
369+
Timeout: 11 * time.Second,
370+
ConnectTimeout: 60 * time.Second,
371+
ReadTimeout: 11 * time.Second,
372+
WriteTimeout: 11 * time.Second,
373+
Port: 9042,
374+
MaxExcessShardConnectionsRate: 2,
375+
NumConns: 2,
376+
Consistency: Quorum,
377+
MaxPreparedStmts: defaultMaxPreparedStmts,
378+
MaxRoutingKeyInfo: 1000,
379+
PageSize: 5000,
380+
DefaultTimestamp: true,
381+
DriverName: defaultDriverName,
382+
DriverVersion: defaultDriverVersion,
383+
MaxWaitSchemaAgreement: 60 * time.Second,
384+
ReconnectInterval: 60 * time.Second,
385+
ConvictionPolicy: &SimpleConvictionPolicy{},
386+
ReconnectionPolicy: &ConstantReconnectionPolicy{MaxRetries: 3, Interval: 1 * time.Second},
387+
InitialReconnectionPolicy: &NoReconnectionPolicy{},
388+
SocketKeepalive: 15 * time.Second,
389+
WriteCoalesceWaitTime: 200 * time.Microsecond,
390+
MetadataSchemaRequestTimeout: 60 * time.Second,
391+
DisableSkipMetadata: true,
392+
WarningsHandlerBuilder: DefaultWarningHandlerBuilder,
393+
Logger: &defaultLogger{},
394+
DNSResolver: defaultDnsResolver,
389395
}
390396

391397
return cfg
@@ -545,6 +551,10 @@ func (cfg *ClusterConfig) Validate() error {
545551
return fmt.Errorf("DNSResolver is empty")
546552
}
547553

554+
if cfg.MaxExcessShardConnectionsRate < 0 {
555+
return fmt.Errorf("MaxExcessShardConnectionsRate should be positive number or zero")
556+
}
557+
548558
return cfg.ValidateAndInitSSL()
549559
}
550560

frame.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"io/ioutil"
3333
"net"
3434
"runtime"
35+
"strconv"
3536
"strings"
3637
"time"
3738
)
@@ -913,6 +914,22 @@ func (f *framer) readTypeInfo() TypeInfo {
913914
collection.Elem = f.readTypeInfo()
914915

915916
return collection
917+
case TypeCustom:
918+
if strings.HasPrefix(simple.custom, "org.apache.cassandra.db.marshal.VectorType") {
919+
spec := strings.TrimPrefix(simple.custom, "org.apache.cassandra.db.marshal.VectorType")
920+
spec = spec[1 : len(spec)-1] // remove parenthesis
921+
idx := strings.LastIndex(spec, ",")
922+
typeStr := spec[:idx]
923+
dimStr := spec[idx+1:]
924+
subType := getCassandraLongType(strings.TrimSpace(typeStr), f.proto, nopLogger{})
925+
dim, _ := strconv.Atoi(strings.TrimSpace(dimStr))
926+
vector := VectorType{
927+
NativeType: simple,
928+
SubType: subType,
929+
Dimensions: dim,
930+
}
931+
return vector
932+
}
916933
}
917934

918935
return simple

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/google/go-cmp v0.7.0
2222
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed
2323
github.com/klauspost/compress v1.18.1
24-
golang.org/x/net v0.46.0
24+
golang.org/x/net v0.47.0
2525
gopkg.in/inf.v0 v0.9.1
2626
sigs.k8s.io/yaml v1.6.0
2727
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
3030
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
3131
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
3232
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
33+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
34+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
3335
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3436
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3537
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=

0 commit comments

Comments
 (0)