Skip to content

Commit

Permalink
Update to version v4.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
graveart committed Oct 13, 2023
1 parent fbe8ce3 commit d0afc09
Show file tree
Hide file tree
Showing 375 changed files with 17,199 additions and 5,096 deletions.
21 changes: 16 additions & 5 deletions bindings/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ type Logger interface {
Printf(level int, fmt string, msg ...interface{})
}

var logger Logger
// Separate mutexes for logger object itself and for reindexer_enable_logger call:
// logMtx provides safe access to the logger
// logEnableMtx provides atomic logic for (enable + set) and (disable + reset) procedures
var logMtx sync.RWMutex
var logEnableMtx sync.Mutex
var logger Logger

var enableDebug bool

var bufPool sync.Pool
Expand Down Expand Up @@ -605,18 +610,24 @@ func CGoLogger(level int, msg string) {
}
}

func (binding *Builtin) EnableLogger(log bindings.Logger) {
func (binding *Builtin) setLogger(log bindings.Logger) {
logMtx.Lock()
defer logMtx.Unlock()
logger = log
}

func (binding *Builtin) EnableLogger(log bindings.Logger) {
logEnableMtx.Lock()
defer logEnableMtx.Unlock()
binding.setLogger(log)
C.reindexer_enable_go_logger()
}

func (binding *Builtin) DisableLogger() {
logMtx.Lock()
defer logMtx.Unlock()
logEnableMtx.Lock()
defer logEnableMtx.Unlock()
C.reindexer_disable_go_logger()
logger = nil
binding.setLogger(nil)
}

func (binding *Builtin) ReopenLogFiles() error {
Expand Down
16 changes: 7 additions & 9 deletions bindings/builtinserver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ type StorageConf struct {
}

type NetConf struct {
HTTPAddr string `yaml:"httpaddr"`
RPCAddr string `yaml:"rpcaddr"`
WebRoot string `yaml:"webroot"`
Security bool `yaml:"security"`
RAFTCluster bool `yaml:"enable_cluster"`
HTTPAddr string `yaml:"httpaddr"`
RPCAddr string `yaml:"rpcaddr"`
WebRoot string `yaml:"webroot"`
Security bool `yaml:"security"`
}

type LoggerConf struct {
Expand Down Expand Up @@ -71,10 +70,9 @@ func DefaultServerConfig() *ServerConfig {
Autorepair: false,
},
Net: NetConf{
HTTPAddr: "0.0.0.0:9088",
RPCAddr: "0.0.0.0:6534",
Security: false,
RAFTCluster: false,
HTTPAddr: "0.0.0.0:9088",
RPCAddr: "0.0.0.0:6534",
Security: false,
},
Logger: LoggerConf{
ServerLog: "stdout",
Expand Down
2 changes: 1 addition & 1 deletion bindings/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package bindings

const CInt32Max = int(^uint32(0) >> 1)

const ReindexerVersion = "v4.11.0"
const ReindexerVersion = "v4.12.0"

// public go consts from type_consts.h and reindexer_ctypes.h
const (
Expand Down
30 changes: 24 additions & 6 deletions bindings/cproto/cproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (

const (
defConnPoolSize = 8
defConnPoolLBAlgorithm = bindings.LBRoundRobin
pingerTimeoutSec = 60
defConnPoolLBAlgorithm = bindings.LBPowerOfTwoChoices
pingerTimeoutSec = uint32(60)
pingResponseTimeoutSec = uint32(20)
defAppName = "Go-connector"

opRd = 0
Expand Down Expand Up @@ -841,7 +842,11 @@ func (binding *NetCProto) rpcCallNoResults(ctx context.Context, op int, cmd int,
func (binding *NetCProto) pinger() {
timeout := time.Second
ticker := time.NewTicker(timeout)
var ticksCount uint16
var ticksCount uint32
pingTimeoutSec := pingResponseTimeoutSec
if uint32(binding.timeouts.RequestTimeout/time.Second) > pingTimeoutSec {
pingTimeoutSec = uint32(binding.timeouts.RequestTimeout / time.Second)
}
for now := range ticker.C {
ticksCount++
select {
Expand All @@ -852,15 +857,28 @@ func (binding *NetCProto) pinger() {
if ticksCount == pingerTimeoutSec {
ticksCount = 0
conns := binding.getAllConns()
var wg sync.WaitGroup
cmpl := func(buf bindings.RawBuffer, err error) {
wg.Done()
if buf != nil {
buf.Free()
}
}
for _, conn := range conns {
if conn.hasError() {
continue
}
if conn.lastReadTime().Add(timeout).Before(now) {
buf, _ := conn.rpcCall(context.TODO(), cmdPing, uint32(binding.timeouts.RequestTimeout/time.Second))
buf.Free()
if !conn.lastReadTime().Add(timeout).Before(now) {
continue
}
seqs := conn.getSeqs()
if cap(seqs)-len(seqs) > 0 {
continue
}
wg.Add(1)
conn.rpcCallAsync(context.TODO(), cmdPing, pingTimeoutSec, cmpl)
}
wg.Wait()
}
}
}
2 changes: 1 addition & 1 deletion bindings/cproto/cproto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestCprotoPool(t *testing.T) {
u, err := url.Parse(dsn)
require.NoError(t, err)
c := new(NetCProto)
err = c.Init([]url.URL{*u})
err = c.Init([]url.URL{*u}, reindexer.WithConnPoolLoadBalancing(bindings.LBRoundRobin))
require.NoError(t, err)

conns := make(map[connection]bool)
Expand Down
44 changes: 42 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# Version 4.12.0 *beta* (13.10.2023)
## Sharding
- [fea] Added [commands](sharding.md#runtime-sharding-configuration) for the runtime sharding configuration (on the empty namespaces)

## Go connector
- [fix] Fixed potential deadlock in builtin binding, when `SetLogger` method is called multiple

## Ported
- [fea/fix] Ported all the fixes from [v3.17.0](https://github.com/Restream/reindexer/releases/tag/v3.17.0), [v3.18.0](https://github.com/Restream/reindexer/releases/tag/v3.18.0) and [v3.19.0](https://github.com/Restream/reindexer/releases/tag/v3.19.0)

## Face
- [fea] Improved the drop-down section behavior on the Query builder page
- [fea] Added a link to the online documentation
- [fea] Added new proc settings to the Index config
- [fea] Changed the scale window icon for textareas
- [fea] Added the background color to the Close icon in the search history on the Namespace page
- [fea] Improved the buttons' behavior on the Query builder page
- [fea] Added the database name size limit
- [fea] Added the ability to use spaces for JSON paths
- [fea] Changed the numeric values position in the Grid
- [fix] Fixed the columns' settings resetting after the Perfstats page reloading
- [fix] Removed the double requests on the Perfstats page
- [fix] Fixed the JSON Paths tooltip description
- [fix] Fixed the pie chart position in Safari
- [fix] Fixed the popup window size for the long text
- [fix] Fixed the bottom padding on the statistics legend window
- [fix] Fixed the modal window to inform about disabled memory statistics
- [fix] Fixed the filter removal
- [fix] Fixed the filter result page when the filter is removed
- [fix] Fixed the redirect to the wrong page after all items were removed
- [fix] Fixed the Statistics chart for undefined replication.wal_size
- [fix] Fixed the column set for the namespace items during the namespace switching
- [fix] Fixed the JSON paths view for values included spaces
- [fix] Changed the value format for width on the integer for sqlquery
- [fix] Fixed the bug related to the query history on the Namespace Items list
- [fix] Fixed the column titles in the table settings menu on the Performance page
- [fix] Added the validation of the negative values for the index settings
- [fix] Fixed the SQL query result table
- [fix] Fixed the aggrigation panel
- [fix] Fixed the items sorting
- [fix] Fixed the last column settings

# Version 4.11.0 *beta* (09.06.2023)
## Server
- [fix] Fixed HTTP-transactions timeout handling
Expand Down Expand Up @@ -1669,5 +1711,3 @@ Storages for v3 and v4 are compatible in both ways.
- [ref] EnableStorage method was deprecated
- [fix] Query builder did not reset opOR after InnerJoin

## Misc

50 changes: 38 additions & 12 deletions cjson/creflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cjson
import (
"fmt"
"reflect"
"strings"
"unsafe"

"github.com/restream/reindexer/v4/bindings"
Expand Down Expand Up @@ -114,17 +113,44 @@ func (pl *payloadIface) ptr(field, idx, typ int) unsafe.Pointer {
const hexChars = "0123456789abcdef"

func createUuid(v [2]uint64) string {
var b strings.Builder
b.Grow(36)
for i, j := 0, 0; i < 36; i++ {
switch i {
case 8, 13, 18, 23: b.WriteByte('-')
default:
b.WriteByte(hexChars[(v[j / 16] >> ((15 - j % 16) * 4)) & 0xF])
j++
}
}
return b.String()
buf := make([]byte, 36)
buf[0] = hexChars[(v[0] >> 60) & 0xF];
buf[1] = hexChars[(v[0] >> 56) & 0xF];
buf[2] = hexChars[(v[0] >> 52) & 0xF];
buf[3] = hexChars[(v[0] >> 48) & 0xF];
buf[4] = hexChars[(v[0] >> 44) & 0xF];
buf[5] = hexChars[(v[0] >> 40) & 0xF];
buf[6] = hexChars[(v[0] >> 36) & 0xF];
buf[7] = hexChars[(v[0] >> 32) & 0xF];
buf[8] = '-';
buf[9] = hexChars[(v[0] >> 28) & 0xF];
buf[10] = hexChars[(v[0] >> 24) & 0xF];
buf[11] = hexChars[(v[0] >> 20) & 0xF];
buf[12] = hexChars[(v[0] >> 16) & 0xF];
buf[13] = '-';
buf[14] = hexChars[(v[0] >> 12) & 0xF];
buf[15] = hexChars[(v[0] >> 8) & 0xF];
buf[16] = hexChars[(v[0] >> 4) & 0xF];
buf[17] = hexChars[v[0] & 0xF];
buf[18] = '-';
buf[19] = hexChars[(v[1] >> 60) & 0xF];
buf[20] = hexChars[(v[1] >> 56) & 0xF];
buf[21] = hexChars[(v[1] >> 52) & 0xF];
buf[22] = hexChars[(v[1] >> 48) & 0xF];
buf[23] = '-';
buf[24] = hexChars[(v[1] >> 44) & 0xF];
buf[25] = hexChars[(v[1] >> 40) & 0xF];
buf[26] = hexChars[(v[1] >> 36) & 0xF];
buf[27] = hexChars[(v[1] >> 32) & 0xF];
buf[28] = hexChars[(v[1] >> 28) & 0xF];
buf[29] = hexChars[(v[1] >> 24) & 0xF];
buf[30] = hexChars[(v[1] >> 20) & 0xF];
buf[31] = hexChars[(v[1] >> 16) & 0xF];
buf[32] = hexChars[(v[1] >> 12) & 0xF];
buf[33] = hexChars[(v[1] >> 8) & 0xF];
buf[34] = hexChars[(v[1] >> 4) & 0xF];
buf[35] = hexChars[v[1] & 0xF];
return string(buf)
}

func (pl *payloadIface) getInt(field, idx int) int {
Expand Down
6 changes: 4 additions & 2 deletions cjson/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type Decoder struct {
logger Logger
}

const MaxIndexes = 256

func fieldByTag(t reflect.Type, tag string) (result reflect.StructField, ok bool) {
if t.Kind() == reflect.Ptr {
t = t.Elem()
Expand Down Expand Up @@ -674,7 +676,7 @@ func (dec *Decoder) DecodeCPtr(cptr uintptr, dest interface{}) (err error) {
}
}()

fieldsoutcnt := make([]int, 64, 64)
fieldsoutcnt := make([]int, MaxIndexes)
ctagsPath := make([]int, 0, 8)

dec.decodeValue(pl, ser, reflect.ValueOf(dest), fieldsoutcnt, ctagsPath)
Expand Down Expand Up @@ -709,7 +711,7 @@ func (dec *Decoder) Decode(cjson []byte, dest interface{}) (err error) {
}
}()

fieldsoutcnt := make([]int, 64, 64)
fieldsoutcnt := make([]int, MaxIndexes)
ctagsPath := make([]int, 0, 8)

dec.decodeValue(nil, ser, reflect.ValueOf(dest), fieldsoutcnt, ctagsPath)
Expand Down
Loading

0 comments on commit d0afc09

Please sign in to comment.