Skip to content

Commit ef68092

Browse files
author
reindexer-bot
committed
[upd] Update pdqsort (fixes potential overflow)
1 parent f814227 commit ef68092

1,080 files changed

Lines changed: 147499 additions & 27495 deletions

File tree

Some content is hidden

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

.github/workflows/test.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,35 @@ jobs:
66
runs-on: windows-latest
77
strategy:
88
matrix:
9-
compiler: ["Visual Studio 17 2022"]
9+
compiler: ["Visual Studio 17 2022", "MinGW Makefiles"]
1010
fail-fast: false
11+
env:
12+
EXTRA_FLAGS: "${{ matrix.compiler == 'Visual Studio 17 2022' && '-Ax64' || '' }}"
1113
steps:
1214
- name: Checkout repository
1315
uses: actions/checkout@v4
1416
- name: Build Reindexer
1517
run: |
1618
mkdir build && cd build
17-
cmake -G "${{matrix.compiler}}" .. -Ax64
19+
cmake -G "${{matrix.compiler}}" -DBUILD_ANN_INDEXES=builtin .. $EXTRA_FLAGS
1820
cmake --build . --config Release
1921
cmake --build . --config Release --target face
2022
cmake --build . --config Release --target swagger
2123
cpack
22-
- name: Upload Artifacts
23-
uses: actions/upload-artifact@v4
24-
with:
25-
name: windows-latest
26-
path: build/*.exe
27-
if-no-files-found: error
2824
2925
build-windows-2019:
3026
runs-on: windows-2019
3127
strategy:
3228
matrix:
33-
compiler: ["Visual Studio 16 2019", "MinGW Makefiles"]
29+
compiler: ["Visual Studio 16 2019"]
3430
fail-fast: false
3531
steps:
3632
- name: Checkout repository
3733
uses: actions/checkout@v4
3834
- name: Build Reindexer
3935
run: |
4036
mkdir build && cd build
41-
cmake -G "${{matrix.compiler}}" ..
37+
cmake -G "${{matrix.compiler}}" -DBUILD_ANN_INDEXES=none ..
4238
cmake --build . --config Release
4339
cmake --build . --config Release --target face
4440
cmake --build . --config Release --target swagger
@@ -82,7 +78,7 @@ jobs:
8278
mkdir build && cd build
8379
if [[ $OS == ubuntu-latest ]]; then
8480
if [[ $SANITIZER == 'ASAN' ]]; then
85-
cmake -DENABLE_GRPC=ON -DWITH_${{matrix.sanitizer}}=On -DGTEST_SKIP_SHARDING=On ..
81+
cmake -DENABLE_GRPC=ON -DWITH_${{matrix.sanitizer}}=On -DGTEST_SKIP_ASAN_MEMORY_HEAVY=On ..
8682
else
8783
cmake -DENABLE_GRPC=ON -DWITH_${{matrix.sanitizer}}=On ..
8884
fi
@@ -124,9 +120,6 @@ jobs:
124120
sanitizer: ASAN
125121
test: 'GO'
126122
# - os: ubuntu-latest
127-
# sanitizer: TSAN
128-
# cc: gcc-12
129-
# cxx: g++-12
130123
# test: 'C++'
131124
- os: ubuntu-latest
132125
sanitizer: TSAN
@@ -183,7 +176,12 @@ jobs:
183176
if [[ -z "$SANITIZER" ]]; then
184177
go test -timeout 15m ./test/... -bench . -benchmem -benchtime 100ms -seedcount 50000
185178
else
186-
go test -timeout 35m ./test/... -bench . -benchmem -benchtime 100ms -seedcount 50000
179+
export TSAN_OPTIONS="halt_on_error=1 suppressions=$PWD/test/tsan/builtin.tsan.suppressions"
180+
mkdir gotests
181+
# Using preocompiled tests to get readable Thread sanitizer backtraces from builtin C++ library
182+
go test ./test/... -c -o gotests -tags tiny_vectors
183+
./gotests/test.test -test.timeout 35m -test.bench . -test.benchmem -test.benchtime 100ms -seedcount 50000
184+
./gotests/ft.test -test.bench . -test.benchmem -test.benchtime 100ms -seedcount 50000
187185
fi
188186
else
189187
cd build
@@ -219,9 +217,9 @@ jobs:
219217
run: |
220218
cd build
221219
if [[ $OS == ubuntu* ]]; then
222-
sudo dpkg -i reindexer-4-dev*.deb
220+
sudo dpkg -i reindexer-dev*.deb
223221
sudo apt-get install -f
224-
sudo dpkg -i reindexer-4-server*.deb
222+
sudo dpkg -i reindexer-server*.deb
225223
sudo apt-get install -f
226224
else
227225
for f in reindexer-*.tar.gz; do tar -xvzf "$f"; done

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ __pycache__
1919
*.so
2020
.pytest_cache/
2121
qa_tests/logs/
22-
qa_tests/logs/
2322
qa_tests/venv/
23+
qa_tests/.venv/
2424

2525
#ignore directory with compile commands
2626
.cache

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
cmake_minimum_required(VERSION 3.10..3.13)
1+
cmake_minimum_required(VERSION 3.18)
22

33
project(reindexer)
44

55
enable_testing()
66
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
77
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
8+
set(CMAKE_PCH_WARN_INVALID OFF)
89
set(REINDEXER_SOURCE_PATH ${PROJECT_SOURCE_DIR}/cpp_src)
910

1011
add_subdirectory(cpp_src)

appveyor.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

bindings.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"github.com/prometheus/client_golang/prometheus"
1212
otelattr "go.opentelemetry.io/otel/attribute"
1313

14-
"github.com/restream/reindexer/v4/bindings"
15-
"github.com/restream/reindexer/v4/bindings/builtinserver/config"
16-
"github.com/restream/reindexer/v4/cjson"
14+
"github.com/restream/reindexer/v5/bindings"
15+
"github.com/restream/reindexer/v5/bindings/builtinserver/config"
16+
"github.com/restream/reindexer/v5/cjson"
1717
)
1818

1919
const (
@@ -32,6 +32,10 @@ func (db *reindexerImpl) modifyItem(ctx context.Context, namespace string, ns *r
3232
}
3333
}
3434

35+
if item == nil {
36+
return 0, fmt.Errorf("rq: nil value in item modify call for '%s' namespace", namespace)
37+
}
38+
3539
for tryCount := 0; tryCount < 2; tryCount++ {
3640
ser := cjson.NewPoolSerializer()
3741
defer ser.Close()

bindings/builtin/builtin.go

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"time"
1919
"unsafe"
2020

21-
"github.com/restream/reindexer/v4/bindings"
22-
"github.com/restream/reindexer/v4/cjson"
21+
"github.com/restream/reindexer/v5/bindings"
22+
"github.com/restream/reindexer/v5/cjson"
2323
)
2424

2525
const defCgoLimit = 2000
@@ -250,12 +250,13 @@ func (binding *Builtin) Init(u []url.URL, eh bindings.EventsHandler, options ...
250250
caps := *bindings.DefaultBindingCapabilities().
251251
WithResultsWithShardIDs(true).
252252
WithQrIdleTimeouts(true).
253-
WithIncarnationTags(true)
253+
WithIncarnationTags(true).
254+
WithFloatRank(true)
254255
ccaps := C.BindingCapabilities{
255256
caps: C.int64_t(caps.Value),
256257
}
257258

258-
return err2go(C.reindexer_connect_v4(binding.rx, str2c(u[0].Host+u[0].Path), opts, str2c(bindings.ReindexerVersion), ccaps))
259+
return err2go(C.reindexer_connect(binding.rx, str2c(u[0].Host+u[0].Path), opts, str2c(bindings.ReindexerVersion), ccaps))
259260
}
260261

261262
func (binding *Builtin) StartWatchOnCtx(ctx context.Context) (CCtxWrapper, error) {
@@ -677,6 +678,7 @@ func (binding *Builtin) Finalize() error {
677678
if binding.eventsHandler != nil && binding.rx != 0 {
678679
binding.eventsHandler.Unsubscribe(binding.rx)
679680
}
681+
bufFree.free_buffers_sync()
680682
C.destroy_reindexer(binding.rx)
681683
binding.rx = 0
682684
if binding.cgoLimiterStat != nil {
@@ -716,6 +718,10 @@ func (binding *Builtin) Unsubscribe(ctx context.Context) error {
716718
return binding.eventsHandler.Unsubscribe(binding.rx)
717719
}
718720

721+
func (binding *Builtin) DBMSVersion() (string, error) {
722+
return C.GoString(C.reindexer_version()), nil
723+
}
724+
719725
func newBufFreeBatcher() (bf *bufFreeBatcher) {
720726
bf = &bufFreeBatcher{
721727
bufs: make([]*RawCBuffer, 0, 100),
@@ -732,35 +738,46 @@ type bufFreeBatcher struct {
732738
cbufs []C.reindexer_resbuffer
733739
lock sync.Mutex
734740
kickCh chan struct{}
735-
}
736741

737-
func (bf *bufFreeBatcher) loop() {
738-
for {
739-
<-bf.kickCh
742+
rxTerminationLock sync.Mutex
743+
}
740744

741-
bf.lock.Lock()
742-
if len(bf.bufs) == 0 {
743-
bf.lock.Unlock()
744-
continue
745-
}
746-
bf.bufs, bf.bufs2 = bf.bufs2, bf.bufs
745+
func (bf *bufFreeBatcher) free_buffers_impl() {
746+
bf.rxTerminationLock.Lock()
747+
defer bf.rxTerminationLock.Unlock()
748+
bf.lock.Lock()
749+
if len(bf.bufs) == 0 {
747750
bf.lock.Unlock()
751+
return
752+
}
753+
bf.bufs, bf.bufs2 = bf.bufs2, bf.bufs
754+
bf.lock.Unlock()
748755

749-
for _, buf := range bf.bufs2 {
750-
bf.cbufs = append(bf.cbufs, buf.cbuf)
751-
}
756+
for _, buf := range bf.bufs2 {
757+
bf.cbufs = append(bf.cbufs, buf.cbuf)
758+
}
752759

753-
C.reindexer_free_buffers(&bf.cbufs[0], C.int(len(bf.cbufs)))
760+
C.reindexer_free_buffers(&bf.cbufs[0], C.int(len(bf.cbufs)))
754761

755-
for _, buf := range bf.bufs2 {
756-
buf.cbuf.results_ptr = 0
757-
bf.toPool(buf)
758-
}
759-
bf.cbufs = bf.cbufs[:0]
760-
bf.bufs2 = bf.bufs2[:0]
762+
for _, buf := range bf.bufs2 {
763+
buf.cbuf.results_ptr = 0
764+
bf.toPool(buf)
765+
}
766+
bf.cbufs = bf.cbufs[:0]
767+
bf.bufs2 = bf.bufs2[:0]
768+
}
769+
770+
func (bf *bufFreeBatcher) loop() {
771+
for {
772+
<-bf.kickCh
773+
bf.free_buffers_impl()
761774
}
762775
}
763776

777+
func (bf *bufFreeBatcher) free_buffers_sync() {
778+
bf.free_buffers_impl()
779+
}
780+
764781
func (bf *bufFreeBatcher) add(buf *RawCBuffer) {
765782
if buf.cbuf.results_ptr != 0 {
766783
bf.toFree(buf)

bindings/builtin/builtin_posix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package builtin
55

66
// #cgo pkg-config: libreindexer
7-
// #cgo CXXFLAGS: -std=c++17 -g -O2 -Wall -Wpedantic -Wextra
7+
// #cgo CXXFLAGS: -std=c++20 -g -O2 -Wall -Wpedantic -Wextra
88
// #cgo CFLAGS: -std=c99 -g -O2 -Wall -Wpedantic -Wno-unused-variable
99
// #cgo LDFLAGS: -g
1010
import "C"

bindings/builtin/builtin_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
package builtin
55

6-
// #cgo CXXFLAGS: -std=c++17 -g -O2 -Wall -Wpedantic -Wextra -I../../cpp_src
6+
// #cgo CXXFLAGS: -std=c++20 -g -O2 -Wall -Wpedantic -Wextra -I../../cpp_src
77
// #cgo CFLAGS: -std=c99 -g -O2 -Wall -Wpedantic -Wno-unused-variable -I../../cpp_src
8-
// #cgo LDFLAGS: -L${SRCDIR}/../../build/cpp_src/ -lreindexer -lleveldb -lsnappy -g -lshlwapi -ldbghelp -lws2_32
8+
// #cgo LDFLAGS: -L${SRCDIR}/../../build/cpp_src/ -lreindexer -lleveldb -lsnappy -g -lgomp -lshlwapi -ldbghelp -lws2_32
99
import "C"

bindings/builtin/cgoeventshandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"time"
1313
"unsafe"
1414

15-
"github.com/restream/reindexer/v4/bindings"
15+
"github.com/restream/reindexer/v5/bindings"
1616
)
1717

1818
type CGOEventsHandler struct {

bindings/builtin/posix_config.go.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
package builtin
55

6-
// #cgo CXXFLAGS: -std=c++17 -g -O2 -Wall -Wpedantic -Wextra @cgo_cxx_flags@
6+
// #cgo CXXFLAGS: -std=c++20 -g -O2 -Wall -Wpedantic -Wextra @cgo_cxx_flags@
77
// #cgo CFLAGS: -std=c99 -g -O2 -Wall -Wpedantic -Wno-unused-variable @cgo_c_flags@
88
// #cgo LDFLAGS: @cgo_ld_flags@ -g
99
import "C"

0 commit comments

Comments
 (0)