Compare commits

...
2886 Commits
Author SHA1 Message Date
benschermel 6ad5cabe15 update deb pkg references and changelog 2022-05-25 01:10:56 -04:00
benschermel a9ec2fc738 update dockerfiles 2022-05-25 01:08:24 -04:00
John Sully 2c38667ecf Revert ci.yml to unstable branch version 2022-05-23 14:56:45 -04:00
John Sully 38310ec9f6 On Alpine we must have a reasonable stack size 2022-05-20 16:40:20 -04:00
John Sully ea4941a3e7 Fix crash in expire when a snapshot is in flight. Caused by a perf optimization getting the expire map out of sync with the val 2022-05-20 13:07:26 -04:00
John Sully 5dbf1f6bd6 Fix O(n^2) algorithm in the GC cleanup logic 2022-05-19 21:46:55 -04:00
John Sully ba1275f653 Fix TSAN warnings on the repl backlog 2022-05-17 15:37:22 -04:00
John Sully 20766a02b8 Disable async commands by default 2022-05-17 15:37:22 -04:00
John Sully a9d3490f9c Silence TSAN errors on ustime and mstime. Every CPU we support is atomic on aligned ints, but correctness matters 2022-05-17 15:37:22 -04:00
John Sully 8405c99017 Add fence barriers for the repl backlog (important for AARCH64 and other weak memory models) 2022-05-17 15:37:22 -04:00
John Sully 027ad50581 Dictionary use correct acquire/release semantics 2022-05-17 15:37:22 -04:00
John Sully e38537202e Avoid unnecessary rehashing when a rehash is abandoned 2022-05-17 15:37:22 -04:00
John Sully 8d8aabb978 Prevent us from starting a rehash when one wasn't already in progress. This can cause severe issues for snapshots 2022-05-17 15:37:22 -04:00
John Sully 418356c03a Initialize noshrink, it was dangling 2022-05-17 15:37:22 -04:00
John Sully 3caf6060c4 Prevent crash on shutdown by avoiding dtors (they are unnecessary anyways) 2022-05-17 15:37:22 -04:00
John Sully 9e138815a1 Fix assertion in async rehash 2022-05-17 15:37:22 -04:00
John Sully 51d3e2cbbc Fix reference counting failure in the dict. This is caused by std::swap also swapping refcounts 2022-05-17 15:37:22 -04:00
jfinity 242d6aabb2 Fix Readme typo from github org transition
Replace mention of scratch-file-path with db-s3-object
2022-05-12 16:55:14 -04:00
John Sully e2e1b4d5d5 Update license 2022-05-12 13:27:46 -04:00
benschermel 03287d69be update deb master changelog 2022-05-12 13:27:46 -04:00
John Sully a2ac9fec3b Delete COPYING to replace with BSD license 2022-05-12 13:16:59 -04:00
John Sully 442c3de350 Limit max overage to 20% during RDB save 2022-05-10 18:30:12 +00:00
John Sully f747044034 Merge pull request #70 from Snapchat/update_readme
Update readme & remove Enterprise references
2022-05-10 14:26:36 -04:00
benschermel 1b22cebe02 remove Enterprise references 2022-05-10 12:58:59 -04:00
benschermel 1ff1d05690 update readme 2022-05-10 11:30:00 -04:00
benschermel 7bbb50c599 update readme 2022-05-10 11:21:55 -04:00
John Sully 481ab76987 Remove unnecessary libs 2022-05-06 17:34:14 +00:00
John Sully b423e1050e Fix musl/Alpine build failures 2022-05-06 17:05:04 +00:00
John Sully 4141746f8f Fix crash in save of masterinfo 2022-05-06 16:29:27 +00:00
John Sully 39974223eb Disable FLASH 2022-05-06 01:20:06 +00:00
John Sully 1f958ac63d Disable async for hget commands as it is not ready 2022-05-05 20:50:44 +00:00
John Sully e16dc2840c Merge pull request #68 from Snapchat/psync_mm_fixes
Fix PSYNC test crashes
2022-05-05 10:32:18 -04:00
John Sully cb6831308d Ensure we force moves not copies when ingesting bulk insert files 2022-05-04 16:51:48 +00:00
John Sully 41b282803a Fix PSYNC test crashes 2022-05-04 01:37:40 +00:00
John Sully ffa8a74d3b Merge pull request #67 from Snapchat/vsaini_psync_test_additions
Quick fix to make psync tests work
2022-05-02 23:11:56 -04:00
Vivek Saini eaeadc5427 Quick fix to make psync tests work 2022-05-03 00:41:30 +00:00
John Sully a1051fd435 Merge pull request #66 from Snapchat/psync_multimaster_fixes
Psync multimaster fixes
2022-05-02 20:24:28 -04:00
John Sully cefba25d0e active-rep test reliability 2022-05-03 00:02:22 +00:00
John Sully cfcb9df71c Merge branch 'keydbpro' into psync_multimaster_fixes 2022-05-02 22:19:22 +00:00
John Sully 15531af421 Merge branch 'psync_multimaster_fixes' of https://github.sc-corp.net/Snapchat/keydb-internal into psync_multimaster_fixes 2022-05-02 22:17:26 +00:00
John Sully 63e5507dfe Merge branch 'keydbpro' of https://github.sc-corp.net/Snapchat/keydb-internal into keydbpro 2022-05-02 22:14:31 +00:00
Vivek Saini faf9359e10 Merge pull request #60 from Snapchat/merge_os_apr_13
Merge in changes from Open Source.

For the most part, this encompasses two changes:

- Adding partial sync capabilities to multi-master
- Adding ReadWrite locks to prevent global lock issues when forking threads, specifically with regards to the time thread.
2022-05-02 13:26:21 -04:00
Vivek Saini c45c77b0ef Updated test replica configs so tests make sense 2022-04-28 21:58:35 +00:00
Vivek Saini cd59462dca Cleanup test suite 2022-04-28 21:36:01 +00:00
Vivek Saini 72c033c9af Inclusive language fix 2022-04-28 21:34:10 +00:00
Vivek Saini c0eeda86e1 Converted some existing PSYNC tests for multimaster 2022-04-28 21:30:40 +00:00
John Sully 6e4e75af9c Ensure recreated tables use the same settings as ones made at boot 2022-04-27 23:38:55 +00:00
John Sully cfa9ba8eb1 Ensure we are responsive during storagecache clears 2022-04-27 17:32:40 +00:00
John Sully 48128dd4c7 Merge branch 'keydbpro' of https://github.sc-corp.net/Snapchat/keydb-internal into keydbpro 2022-04-27 17:00:35 +00:00
Zhaozhen Liang 6b795bf62e Merge pull request #64 from Snapchat/setup-machamp-ci
setup Machamp ci
2022-04-26 16:35:39 -06:00
John Sully b37a68c8f1 PSYNC production fixes 2022-04-26 02:07:28 +00:00
John Sully 5ce8bcd511 Merge branch 'merge_os_apr_13' of https://github.sc-corp.net/Snapchat/keydb-internal into merge_os_apr_13 2022-04-26 02:06:43 +00:00
John Sully 1bf92015dc acceptTLS is threadsafe like the non TLS version 2022-04-26 01:55:22 +00:00
John Sully 914da1f62c With TLS throttle accepts if server is under heavy load - do not change non TLS behavior 2022-04-26 01:55:22 +00:00
John Sully dcaca5d79c Make active client balancing a configurable option 2022-04-26 01:55:22 +00:00
Vivek Saini 54f746f99b Removed mergeReplicationId 2022-04-26 01:55:22 +00:00
Vivek Saini 78efb2f629 call aeThreadOnline() earlier 2022-04-26 01:55:22 +00:00
Vivek Saini d441901c39 Inclusive language 2022-04-26 01:55:22 +00:00
Vivek Saini 09f216fb03 Remove asserts, RW lock can go below zero in cases of aeAcquireLock 2022-04-26 01:55:22 +00:00
Vivek Saini b1b6d31305 placement new instead of memcpy 2022-04-26 01:55:22 +00:00
Christian Legge 0f26a14276 Save and restore master info in rdb to allow active replica partial sync (#371)
* save replid for all masters in rdb

* expanded rdbSaveInfo to hold multiple master structs

* parse repl-masters from rdb

* recover replid info from rdb in active replica mode, attempt partial sync

* save offset from rdb into correct variable

* don't change replid based on master in active rep

* save and load psync info from correct fields
2022-04-26 01:55:22 +00:00
Vivek Saini cde7939fe1 Defensive asserts for RWLock 2022-04-26 01:55:22 +00:00
Vivek Saini 3fadb9787a Integrate readwritelock with Pro Code 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran bdfd34cf10 use atomic_load for g_pserver->mstime 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran 8f6c6bb6a4 need to include stdint for uintptr_t 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran 2c881b390a cannot mod a pointer 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran f189bbb4e4 remove nullptr subtraction 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran e0548b4722 check ziplist len to avoid crash on empty ziplist convert 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran 60a85737e6 remove unused var in networking.cpp 2022-04-26 01:55:22 +00:00
John Sully f7ea8bf0f1 Eliminate firewall dialogs on mac for regular and cluster tests. There are still issues with the sentinel tests but attempting to bind only to localhost causes failures 2022-04-26 01:55:22 +00:00
John Sully f59cd18e8c Fix module test break 2022-04-26 01:55:22 +00:00
John Sully 9dad9f6ef4 Fix MALLOC=memkind build issues 2022-04-26 01:55:22 +00:00
benschermel e0d08c62e5 update README resource links 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran 78086d6293 set thread as offline when waiting for time thread lock 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran aa07287c05 time thread lock uses fastlock instead of std::mutex 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran 24a586cdf1 only need to include readwritelock in ae 2022-04-26 01:55:22 +00:00
Malavan Sotheeswaran 4d4acaa155 hide forklock object in ae 2022-04-26 01:55:22 +00:00
malavan 52402c4786 fork lock for all threads, use fastlock for readwritelock 2022-04-26 01:55:21 +00:00
John Sully 84b57684b0 Update ci.yml
Change min tested version to 18.04
2022-04-26 01:55:21 +00:00
zliang 6ab1c2deec update builder image 2022-04-25 18:55:01 -06:00
zliang aedd1d4ca8 revert back changes 2022-04-25 15:32:37 -06:00
zliang 408191f831 debug with old img 2022-04-25 15:23:51 -06:00
zliang 465892a357 try remove multi arch for debugging 2022-04-25 15:10:00 -06:00
zliang 7b18695ead support multi arch build and tests 2022-04-25 14:49:14 -06:00
Vivek Saini 836c9b200b Added multimaster test 2022-04-25 20:32:44 +00:00
zliang a564504b6a remove multi arch for now it is not working 2022-04-22 19:06:10 -06:00
zliang c750cb155c add multi arch for machamp ci 2022-04-22 18:36:40 -06:00
zliang d5b6530f4f break into tests into steps 2022-04-22 18:03:42 -06:00
zliang 935d96fe69 fix the Machamp build 2022-04-22 16:46:41 -06:00
John Sully 6bf79b69c6 PSYNC production fixes 2022-04-22 22:43:20 +00:00
zliang 2431c646cd make build_test.sh executable 2022-04-22 12:31:13 -06:00
zliang 89275cad1f fix typo 2022-04-22 12:24:27 -06:00
zliang 8f6a2b7d3b setup Machamp ci 2022-04-22 12:08:39 -06:00
John Sully aefff904ef øMerge branch 'keydbpro' into merge_os_apr_13 2022-04-21 19:54:01 +00:00
John Sully ae5110ba79 acceptTLS is threadsafe like the non TLS version 2022-04-21 19:53:16 +00:00
Ben Schermel 090ac04f1a Merge pull request #63 from Snapchat/pkg_update
Packaging Updates
2022-04-21 13:21:14 -04:00
Vivek Saini 9f81cc0385 Removed mergeReplicationId 2022-04-21 01:18:12 +00:00
John Sully 0fb5e74339 Merge branch 'keydbpro' of https://github.sc-corp.net/Snapchat/keydb-internal into keydbpro 2022-04-20 21:19:34 +00:00
Vivek Saini eaf76b5944 call aeThreadOnline() earlier 2022-04-20 20:46:48 +00:00
benschermel 19d3076467 update deb copyright 2022-04-20 16:17:43 -04:00
benschermel 9253611008 update copyright 2022-04-20 16:07:37 -04:00
benschermel 9f0474e73d update changelog to use replica as terminology 2022-04-20 14:28:18 -04:00
Vivek Saini 08f88f7a59 Fix KeyDB not building with TLS < 1.1.1 2022-04-20 14:24:50 -04:00
Vivek Saini dc5dd7ee36 Only run the tls-name-validation test if --tls is passed into runtest 2022-04-20 12:15:19 -04:00
John Sully 0c3fd61928 With TLS throttle accepts if server is under heavy load - do not change non TLS behavior 2022-04-18 23:07:36 +00:00
John Sully 95c0146ec9 Make active client balancing a configurable option 2022-04-18 23:07:15 +00:00
benschermel 825dfb19dc modify dockerfile to build within image 2022-04-15 23:10:31 -04:00
benschermel 0cc2a59f8c update packaging for OS merge 2022-04-15 23:09:44 -04:00
Vivek Saini 609a8dc194 Inclusive language 2022-04-14 23:54:05 +00:00
Vivek Saini faefec28a7 Remove asserts, RW lock can go below zero in cases of aeAcquireLock 2022-04-14 22:34:02 +00:00
Vivek Saini a827158d27 placement new instead of memcpy 2022-04-14 21:05:10 +00:00
Christian Legge 264429c997 Save and restore master info in rdb to allow active replica partial sync (#371)
* save replid for all masters in rdb

* expanded rdbSaveInfo to hold multiple master structs

* parse repl-masters from rdb

* recover replid info from rdb in active replica mode, attempt partial sync

* save offset from rdb into correct variable

* don't change replid based on master in active rep

* save and load psync info from correct fields
2022-04-14 20:17:18 +00:00
Vivek Saini 88341c3672 Defensive asserts for RWLock 2022-04-14 17:21:50 +00:00
Vivek Saini a4a886428f Integrate readwritelock with Pro Code 2022-04-14 17:15:19 +00:00
Malavan Sotheeswaran 9486f16857 use atomic_load for g_pserver->mstime 2022-04-13 14:10:58 -04:00
Malavan Sotheeswaran b2a1b8cd0c need to include stdint for uintptr_t 2022-04-13 14:10:58 -04:00
Malavan Sotheeswaran 7d3c604280 cannot mod a pointer 2022-04-13 14:10:58 -04:00
Malavan Sotheeswaran b0f4454851 remove nullptr subtraction 2022-04-13 14:10:58 -04:00
Malavan Sotheeswaran 8f02c51f2e check ziplist len to avoid crash on empty ziplist convert 2022-04-13 14:08:44 -04:00
Malavan Sotheeswaran b73ece90f5 remove unused var in networking.cpp 2022-04-13 14:08:43 -04:00
John Sully e36bd49cf2 Eliminate firewall dialogs on mac for regular and cluster tests. There are still issues with the sentinel tests but attempting to bind only to localhost causes failures 2022-04-13 14:07:14 -04:00
John Sully 0b80316514 Fix module test break 2022-04-13 14:07:14 -04:00
John Sully 8af58be5cd Fix MALLOC=memkind build issues 2022-04-13 14:07:14 -04:00
benschermel 2347f89e6c update README resource links 2022-04-13 14:07:14 -04:00
Malavan Sotheeswaran b1f0d8ddf5 set thread as offline when waiting for time thread lock 2022-04-13 14:06:58 -04:00
Malavan Sotheeswaran 395eb1fd3a time thread lock uses fastlock instead of std::mutex 2022-04-13 14:05:26 -04:00
Malavan Sotheeswaran 2e4d50fbc4 only need to include readwritelock in ae 2022-04-13 14:04:07 -04:00
Malavan Sotheeswaran 09c1b0d5fc hide forklock object in ae 2022-04-13 14:04:02 -04:00
malavan 53c89372aa fork lock for all threads, use fastlock for readwritelock 2022-04-13 13:52:41 -04:00
John Sully 6689604d3d Update ci.yml
Change min tested version to 18.04
2022-04-13 13:34:18 -04:00
John Sully c910471914 Fix leaked reference count to dict 2022-04-13 12:51:00 -04:00
John Sully cb4d9401ae Improve connect performance by reducing lock contention, I'm seeing 50-100% improvements 2022-04-13 12:51:00 -04:00
John Sully c9d70ca62d Do not send updates to servers overly frequently during load 2022-04-13 12:51:00 -04:00
John Sully 55dbb698e7 SSL connections are expensive, do not do them overly frequently 2022-04-13 12:51:00 -04:00
John Sully 2987bb62c7 Handle RREPLAY errors gracefully 2022-04-13 12:51:00 -04:00
John SullyandJohn Sully 52b8c153f8 Make multithread load configurable and disabled by default (#57)
Co-authored-by: John Sully <john@csquare.ca>
2022-04-07 13:20:38 -04:00
John Sully 6a483cc7ae Log the connected masters in the INFO command 2022-04-02 01:20:45 -04:00
John Sully be777f9e7a Fix test failures due to async command slip 2022-04-01 05:08:41 +00:00
John Sully 5344e39488 Do not save while loading 2022-04-01 05:08:08 +00:00
John Sully 24f03b501e Fix test failure 2022-03-31 17:48:37 -04:00
John Sully f7476575a1 Support dynamic runtime modification of tls-allowlist, and add config rewrite support 2022-03-31 17:48:37 -04:00
Vivek Saini 5d833a7173 Changed term whitelist to allowlist (#54) 2022-03-31 14:15:03 -04:00
John Sully f220004ece Merge pull request #53 from Snapchat/freeClientLockFix
Fix lock inversion in freeClientAsync
2022-03-29 12:37:12 -04:00
John Sully 7fb077ff2f Fix issue with AE unlocking in beforeSleep 2022-03-29 12:17:13 -04:00
John Sully 8eaede1c61 Fix lock inversion in freeClientAsync - make it not dependent on the AE Lock 2022-03-29 00:19:49 -04:00
John Sully 91b77ccf4c Merge pull request #51 from jsully/keydbpro
KeyDB Pro Collab Bug Fixes and Mac Build
2022-03-08 18:00:28 -05:00
John Sully f73ce412c8 Fix mac build warnings 2022-03-07 19:28:39 -05:00
John Sully 650553255c Fix spurious warnings about unclean RocksDB databases on startup 2022-03-07 16:42:37 -05:00
John Sully f6ec157551 Fix FLASH Read performance after data is loaded from fastsync (the rocksdb files have compression enabled when written by the bulkWrite function 2022-03-07 16:41:51 -05:00
John Sully 6eaefb7895 Fix test instability caused by MVCC slip with lfence command when async commands are enabled 2022-03-07 16:40:56 -05:00
John Sully 6fbf6f8ed1 Fix fast-sync perf issue while server is under load (batch size too small) 2022-03-07 16:40:01 -05:00
John Sully 5df39b56ac Fix cluster test fail 2022-03-07 16:39:01 -05:00
John Sully 4697923f41 Optimize async command snapshot creation, and make slip configurable 2022-03-07 16:00:48 -05:00
John Sully 0d917c8580 Fix mac build breaks and remove license checks (won't work on mac) 2022-03-07 14:50:31 -05:00
Vivek Saini 9ca488bc63 TLS Name Validation (#48)
Added TLS Name Validation
2022-03-03 13:59:07 -05:00
Artem Danilov 7e057b5856 enable TLS build by default (#43)
* enable TLS build by default

* move export to src folder

* fix comments
2022-02-11 16:36:42 -08:00
John Sully e37cb4c925 Merge pull request #42 from Snapchat/keepttl-failure
fix intermittent KEEPTTL test failure
2022-02-10 12:53:59 -05:00
adanilov be0abf08ca fix intermittent KEEPTTL test failure 2022-02-10 16:37:13 +00:00
Vivek Saini 2677899cd4 Merge pull request #40 from Snapchat/tls_cert_rotation
Added support for TLS certificate rotation.
2022-02-02 17:38:35 -05:00
Vivek Saini 2316d787fe Updated CI to run rotation test 2022-02-02 17:28:55 -05:00
Vivek Saini 6f00a680bd Updated default config file with TLS rotation config option 2022-02-02 15:49:52 -05:00
Vivek Saini 9a727f663f Added TLS rotation support 2022-02-02 14:20:19 -05:00
christianEQ df51a33413 Merge remote-tracking branch 'opensource/RELEASE_6' into keydbpro
Former-commit-id: 439c655a543f4d3224d90bcdeb21ba43c2ab8ab7
2022-01-14 22:19:42 +00:00
MalavanEQAlpha 4e2e461acc Merge pull request #386 from EQ-Alpha/fix_rdb_hang
add readwrite lock for forking

Former-commit-id: dabb81960f
2022-01-14 13:19:33 -08:00
christianEQ ec255fea11 bump version
Former-commit-id: 35dc4df1df
2022-01-13 00:07:03 +00:00
christianEQ 6122cce93b Merge branch 'unstable' into RELEASE_6
Former-commit-id: e69f1023a9
2022-01-10 23:54:30 +00:00
John Sully 258291efcc Permit connTLSWrite to handle a zero sized write
Former-commit-id: 4be609ff2c80fd6261edc214bb099d6cf6ab1db3
2022-01-06 19:15:31 -05:00
John Sully ce95ae7800 Handle the case where querybuf data is read by the fastsync read handler
Former-commit-id: c4a5b904e941e09132413abc3b4d86c59c342051
2021-12-27 00:15:09 -05:00
John Sully 88cef73484 Fix partial sync failures
Former-commit-id: 7e9f7c0c4f520392a930ab72951e287f52c711ab
2021-12-26 05:16:58 -05:00
John Sully cc70550e67 Fix repl-psync-flash test instability
Former-commit-id: 310b0cf5413dbf3e7aa67e9b9c31869f3e994291
2021-12-23 17:30:14 -05:00
John Sully d652b13a32 Remove double free in keydb-benchmark
Former-commit-id: b4528b797d
2021-12-23 14:20:41 -05:00
John Sully b38157b581 Fix deadlock issue #183 cause by lock inversion
Former-commit-id: e070651039
2021-12-23 13:17:14 -05:00
John Sully ff5e5f89ed Apple build break fix
Former-commit-id: 7a32ec39fd
2021-12-23 13:12:59 -05:00
John Sully 9f09e3aa9c Fix module test break
Former-commit-id: 50dfee2039
2021-12-23 13:12:34 -05:00
John Sully c03a4e5838 Fix module test failures with blocked clients
Former-commit-id: 18ec4b8600ea3462843b58a0f0e917824dfd7ff3
2021-12-23 02:10:20 -05:00
John Sully f8bf0aa035 Fix partial sync corruption with FLASH
Former-commit-id: 532f58c0539b775c040c0dd9a2ad3dc349faf87a
2021-12-23 00:04:28 -05:00
John Sully bef45f06bf Reenable TCP No Delay
Former-commit-id: e11211cdfeca46574a03f6f8210bbe1ab3d70961
2021-12-22 18:42:11 -05:00
John Sully 03603a2ac6 Fix memory leak
Former-commit-id: c5b9adf47e30658359071d458cfb16a094dc8e28
2021-12-22 18:41:50 -05:00
VivekSainiEQ 45e7b87548 Merge remote-tracking branch 'mainpro/PRO_RELEASE_6' into keydbpro
Former-commit-id: 5a32d66ee382b6d227a67073afc81ca058d605ed
2021-12-06 20:43:23 +00:00
John Sully 3b83248db6 Implent the force-backlog-disk-reserve flag
Former-commit-id: d39f7f4407f8935b1540dd302be3e24ac02c5700
2021-12-04 02:07:03 +00:00
Malavan Sotheeswaran d0e9aab2e7 Merge branch 'fix_unlocked_main_db_access_in_async_lookup' into 'keydbpro'
add async to hget and fix bug where a command can hold a key from main db without lock

See merge request external-collab/keydb-pro-6!11

Former-commit-id: 1cf683ef015f7e32fb79fbb5e41a3c3a80a80844
2021-12-02 17:39:27 +00:00
malavan 8e7d88c514 add async to hget and fix bug where a command can hold a key from main db without lock
Former-commit-id: b0b8f426fda7cdabd3898a2d0b38d0fae47d1e69
2021-12-02 17:11:26 +00:00
malavan c61f8822cf fix potential compilation fail on gettid in replication.cpp
Former-commit-id: edb6b240a7785b707652a168d90f46d8744dd4c7
2021-12-01 20:50:18 +00:00
Malavan Sotheeswaran de40662c85 Merge branch 'async_commands' into 'keydbpro'
async commands

See merge request external-collab/keydb-pro-6!10

Former-commit-id: 669987028af582a8561b7959c1b33b84f67c6146
2021-11-30 17:28:17 +00:00
Malavan Sotheeswaran 7b2b5d0470 missing false for return in prefetchKeysAsync
Former-commit-id: 174dc44acdc1a8cb37b86f27ab056e14fc42770c
2021-11-30 12:20:13 -05:00
Malavan Sotheeswaran 6d8fe4ae50 Merge branch 'async_commands' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into async_commands
Former-commit-id: 1afa51c4d21d695c052dbec690bf3880b243dbec
2021-11-30 12:17:46 -05:00
Malavan Sotheeswaran 90fcba1968 Merge branch 'async_commands' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into async_commands
Former-commit-id: 59423294524bb1d093a35084aa0d48989b426961
2021-11-30 11:48:35 -05:00
Malavan Sotheeswaran 54f3436250 Merge branch 'keydbpro' into async_commands
Former-commit-id: 9eaddb8ca1424ff3225dac9c144d23848228c7d2
2021-11-30 11:47:51 -05:00
Malavan Sotheeswaran aaf1a42a7b Merge branch 'fastsync_collab' into 'keydbpro'
Fastsync collab

See merge request external-collab/keydb-pro-6!9

Former-commit-id: 8f410e4b814ea6ac506ab540ee1394834fd1d8a8
2021-11-26 20:53:00 +00:00
christianEQ e5b5099eef don't save master if host is null
Former-commit-id: 8238d8da82c483c093f5248b9dac983bc542e20f
2021-11-26 20:36:46 +00:00
Malavan Sotheeswaran 01d54e5e40 Merge branch 'flash-psync' into 'fastsync_collab'
Flash Partial Sync

See merge request external-collab/keydb-pro-6!6

Former-commit-id: 2ebf2a8abd8df5c4cf3a5d759491962d050e8cc5
2021-11-26 18:59:16 +00:00
christian 09f32f19c7 Merge branch 'fastsync_collab2' into 'fastsync_collab'
fix dataloss on aof load with storage provider

See merge request external-collab/keydb-pro-6!7

Former-commit-id: a3aecc171b45308b68eb922947f8dd31be7e3566
2021-11-26 18:28:08 +00:00
malavan 55cc6f797a client lock for fast sync replbuffer, delay fast sync for next replication cron
Former-commit-id: 9fe7f8328d66f9ec57060934462ad85ef60c36aa
2021-11-26 17:46:41 +00:00
John Sully 8bff491912 Implement the disk backed backlog functionality
Former-commit-id: 759cc01c6ba05f9a865c11580cc4975b5f1bd1d6
2021-11-26 03:05:23 +00:00
malavan bbb565abb0 Merge remote-tracking branch 'origin/fastsync_collab' into fastsync_collab2
Former-commit-id: 176c00615769e1a73eb44f8fe7a6cacfa2ae539d
2021-11-24 22:00:18 +00:00
malavan 2ae7247ae7 remove async write from fast sync repl buffer and fix some bugs
Former-commit-id: 6c45706f75d8322281296d9c73a3fac4f7f383a1
2021-11-24 21:59:01 +00:00
VivekSainiEQ 91c758f153 Initialize snapshots for module thread var
Former-commit-id: c263e0df22bab35d8417eb396d250e00e8853ab3
2021-11-24 01:42:01 +00:00
VivekSainiEQ f2e00755e3 Fix failing cluster test
Former-commit-id: 960503a4710d4379d5ebbb67d7ac82705f312913
2021-11-22 22:21:57 +00:00
benschermel 0d2f8218a7 update conf
Former-commit-id: b5b095c12973cdd3eceea8ad8df3961136464a95
2021-11-19 01:46:05 +00:00
benschermel e8bcf8fbac update deb changelog
Former-commit-id: 5169f974b1
2021-11-17 18:22:36 +00:00
benschermel 3a1efa783a update deb changelog
Former-commit-id: a8b215087e9bccf0d813b4b08974744ba963b31c
2021-11-17 18:20:38 +00:00
malavan ef9c1bd074 fix dataloss on aof load with storage provider
Former-commit-id: 447c8601b5203346fdd4b956ad1ac87c4a6073c8
2021-11-16 02:13:36 +00:00
VivekSainiEQ b0c0cd8f8d Removed trial code entirely
Former-commit-id: 540a60eb12d01c2839228f9fdaa6233aed99dc38
2021-11-15 23:56:30 +00:00
VivekSainiEQ 1ab337d760 bump version
Former-commit-id: 2d25e62ece
2021-11-15 23:45:46 +00:00
VivekSainiEQ 32336ec921 bump version
Former-commit-id: d6038f0e063579987874b88bf8a11b5b16dfb33a
2021-11-15 23:43:56 +00:00
VivekSainiEQ 4a093570d0 Removed KeyDB Enterprise Trial
Former-commit-id: 0899ede8db54db80a2cc101412e5dbcaedb706b1
2021-11-15 20:33:54 +00:00
VivekSainiEQ 147abcb3bc Merge branch 'unstable' into RELEASE_6
Former-commit-id: b0b81c60d9
2021-11-15 18:08:01 +00:00
Vivek Saini 440c637c6c Merge pull request #375 from VivekSainiEQ/time_thread_backport
Backport the time thread code from the enterprise version of KeyDB.

Also fix an issue with clustering where connections are potentially written to after being closed.

Former-commit-id: 4b6bdcbcce
2021-11-15 12:57:15 -05:00
John Sully f9d36fb6bc Prevent GC related crash on force-exit
Former-commit-id: e4d95f83b02786b5a170673709780700def160cb
2021-11-13 19:44:13 +00:00
benschermel ab8b7511cd Merge branch 'systemd_rel' into 'PRO_RELEASE_6'
package updates to release branch

See merge request keydb-dev/KeyDB-Pro!54

Former-commit-id: eef6ec1141aafaa5afe52eb2cf501ca4c1e78b8d
2021-11-13 19:36:18 +00:00
benschermel 2056aeaaf7 package updates to release branch
Former-commit-id: 1f198c7ea5926f6f7be630da1e0aadbc8abd10ca
2021-11-13 19:33:45 +00:00
John Sully 6eae02919a Allow load at boot to be cancelled with a shutdown command
Former-commit-id: 2897a59e59bed14a67d1d0abcec5cb6a71bbb15b
2021-11-13 18:39:03 +00:00
benschermel 2b2cf42e11 Merge pull request #377 from EQ-Alpha/systemd_rel
update release packaging

Former-commit-id: 244af9451c
2021-11-13 13:16:48 -05:00
benschermel 81d9257758 update release packaging
Former-commit-id: 639179471e
2021-11-13 17:50:42 +00:00
VivekSainiEQ 7992428583 Merge remote-tracking branch 'opensource/unstable' into PRO_RELEASE_6
Former-commit-id: 60da86471f68b13e2456e113ecd4aa117d95b134
2021-11-12 21:12:53 +00:00
John Sully fa223f4b5a Allow fast sync even if a background save is in progress
Former-commit-id: b98aadfb6875f366a63a9d27d47fb5ca60abaa03
2021-11-12 00:18:32 +00:00
christianEQ 3819331e2e removed unused vars
Former-commit-id: e2bb6242e8be53cdad6def6acdd7e90e0f7d9852
2021-11-11 13:43:20 +00:00
christianEQ 9c75fc3e8f removed unnecessary code to check for metadata
Former-commit-id: 69ffc89d7c27a4eef04aa5cb59ffd1c2b9b8eb20
2021-11-11 13:43:00 +00:00
christianEQ 0dacd68163 added tests for flash psync
Former-commit-id: 79f7376a4fea2de9bd06c06d96f3f98ee7308874
2021-11-11 13:43:00 +00:00
christianEQ a59b192174 save replid from storage on load
Former-commit-id: 8e5d0cb7035db30f35ead36aab52df07ab3c9bee
2021-11-11 13:43:00 +00:00
christianEQ 7f9ab83d24 retrieve replid from IStorage rather than at load time
Former-commit-id: c25323439ce400ca91b2193aa2f464e7b09978fd
2021-11-11 13:43:00 +00:00
christianEQ ebb0e08d94 save master status to storage when masters change
Former-commit-id: 4989926a0028aed7d7700fd1d1f4ed27c20277cc
2021-11-11 13:42:39 +00:00
christianEQ 5219a90483 save and recognize metadata table identifier
Former-commit-id: f06ef757c24ecc50df0e7abf5201a5499ff28c53
2021-11-11 13:41:48 +00:00
christianEQ 39db170c4e add KEYDB_METADATA_ID to metadata tables when created
Former-commit-id: 7fe8a184db62eab171935c20498bdb4f30ee6b1d
2021-11-11 13:41:00 +00:00
christianEQ aa048e2b2f added createMetadataDb to IStorageFactory + implementations
Former-commit-id: a2acf75484d2af93aad9d03a20bd402893044860
2021-11-11 13:41:00 +00:00
benschermel 87a05a7782 Merge pull request #345 from EQ-Alpha/pkg_update_tools
add keydb-diagnostic-tool to packaging

Former-commit-id: 31c0e38d86
2021-11-10 22:16:09 -05:00
benschermel 8e31c59279 Merge pull request #376 from EQ-Alpha/systemd_build
Systemd build

Former-commit-id: 8f5b94c75f
2021-11-10 22:14:24 -05:00
benschermel 3df64e5a42 fix typo
Former-commit-id: d1fc7b96ed
2021-11-11 02:36:20 +00:00
benschermel 18f082e302 update license
Former-commit-id: b253a7aa8d
2021-11-11 02:19:56 +00:00
benschermel 9f0dfd3df8 Merge branch 'unstable' into systemd_build
Former-commit-id: 1625c74a36
2021-11-11 00:59:33 +00:00
malavan d443babbea ignore rdb specific tests when running in --flash mode
Former-commit-id: b44ba3efb21c390c3d199ea1cdd238a57611fd85
2021-11-10 20:46:09 +00:00
John Sully 0b607ecfc3 Fix multiple test failures
Former-commit-id: ba99418643e7b4a12e79bb08e4a7f152da28b861
2021-11-10 18:47:36 +00:00
John Sully 3ab09b9781 Fix compile error on some machines
Former-commit-id: 5f491a38cb7eae63fd316c465f317005bbced385
2021-11-10 17:39:00 +00:00
John Sully 24fbc46352 Prevent track changes from clearing out the cache and misreporting the key count
Former-commit-id: d7ceb59f11bc714e40f208cb8c774a5b762ad41e
2021-11-10 06:40:43 +00:00
John Sully fcad4dfc6b Fix snapshot count mismatch due to race
Former-commit-id: b4175c9bf82cbec047b94403e2a3700f4544b4f1
2021-11-10 05:29:13 +00:00
Vivek Saini b8136b1580 Security fixes (#373)
Fixing potential buffer overflows when using the bitop shift and cron commands, as well as comparing ACL user passwords in constant time.

Former-commit-id: 3c716ee33d
2021-11-09 19:00:01 -05:00
John Sully b12b48ab27 Initial implementation of snapshot fast replication. There are still a few TODOs in progress
Former-commit-id: 0febdcdab8693af443f350968ed3d8c80106675d
2021-11-09 19:36:07 +00:00
John Sully 553f49507d Smooth out performance fluctuations caused by variance in the rehash calibration
Former-commit-id: 09580dedfef09deace7863bf68ba7e0f9edf3eb3
2021-11-06 15:49:58 +00:00
VivekSainiEQ 83b23eafd0 Backported time thread code from enterprise
Former-commit-id: b03eab2a06
2021-11-05 00:30:34 +00:00
John Sully 693e1f64a9 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into keydbpro_collab
Former-commit-id: eca47e8d19defdc894b9dd09b2500d2e15e5fafa
2021-11-02 19:39:53 +00:00
John Sully 9bd7f63ab1 This change fixes out of file descriptor issues with FLASH.
The change does 3 things:
1. It limits RocksDB to 256 file descriptors instead of unlimited
2. It includes the fd limit in its estimation for total file descriptors needed
3. It raises the system fd limit if possible before we open rocksdb but accounting for the 256 limit we added


Former-commit-id: 1447288209c5e7daf8a1203511fc262500ebe5e1
2021-11-02 19:31:53 +00:00
malavan 322ec31191 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into keydbpro
Former-commit-id: 5b88af1067d344f121b2d65e34fb40e229722575
2021-11-02 19:14:47 +00:00
malavan 755e9788ba don't delete db or snapshots on shutdown, still delete storage provider
Former-commit-id: edb840ce10ea77ce654ba27c9eadbf98bbc13403
2021-11-02 19:01:37 +00:00
VivekSainiEQ 591f0c77c4 Check that cluster connection is valid before setting write handler
Former-commit-id: 6a0a005ff2
2021-11-02 17:43:17 +00:00
John Sully 73215b2eeb Make the replica weighting configurable
Former-commit-id: be6a8a7e68acb5cfbe950f13b903e6f7b98c5a39
2021-10-29 17:59:46 +00:00
malavan c48a942ce4 null check for delete override
Former-commit-id: 51216ee433
2021-10-29 15:59:21 +00:00
Vivek Saini 6b8e55ce06 Merge pull request #372 from VivekSainiEQ/Redis_626_Merge
Redis 6.2.6 merge

Former-commit-id: 5f7ca6a2f6
2021-10-28 17:21:14 -04:00
VivekSainiEQ 349d9d2c05 Cast pointer correctly and fixed MVCC not updating correctly
Former-commit-id: 79bdcf0b3d
2021-10-27 17:08:37 +00:00
John Sully d41aa34ba3 Fix slower performance during replication by better balancing client load on threads servicing a replica
Former-commit-id: 496f91d3f169fcfe6d94c2ea69cee402f8eb60ca
2021-10-22 03:16:33 +00:00
John Sully 2d0f54eb8f Merge branch 'COLLAB_RELEASE_6_4' into keydbpro_collab
Former-commit-id: 3d43e7a022250273ee5cfb5755ed1d6ca42b9889
2021-10-21 23:58:32 +00:00
malavan fbe9ff6680 null check for delete override
Former-commit-id: f5f2f5e200a5ff1b0306998624b758d5a4c10825
2021-10-21 23:56:45 +00:00
malavan b7b14ef19f null check for delete override
Former-commit-id: a48b4cbdf24bfa5a1d13295c0202d1ed09115374
2021-10-21 23:50:50 +00:00
John Sully 3f08905408 Do not dereference a nullptr if there are too many files open
Former-commit-id: 4674eb29a261e8b046953398c94354fc3e550c2a
2021-10-21 23:45:46 +00:00
John Sully 7b3337d244 Ensure async rehash completes before we start a new time. Degrad to sync hash if necessary to ensure this
Former-commit-id: 0f830facc7c6bc6668af9bb2e10b6e13a13227aa
2021-10-21 22:46:17 +00:00
VivekSainiEQ a7e7540284 Resolved merge conflicts in prior commit
Former-commit-id: b88f06b16f
2021-10-21 22:35:15 +00:00
VivekSainiEQ b84ee93b5d Merge tag '6.2.6' into Redis_626_Merge
Former-commit-id: e6d7e01be6
2021-10-21 22:33:55 +00:00
John Sully 43a62493f8 Additional change to ensure FLASH storage goes through the multithread path
Former-commit-id: 422ea0723f0b8718f28ef9c1cc4d5f56d374af46
2021-10-20 03:13:36 +00:00
John Sully d57883bf64 Permit prefetch for FLASH scenarios in single thread mode
Former-commit-id: 6d0b90ed43cc9d1196903ddbc7d50cd40e439e42
2021-10-15 16:22:42 +00:00
noobpwnftw b9d171eb32 Fix incorrect counting of client connections
This affects later distribution of clients among threads if there had been many connection attempts during loading phase.


Former-commit-id: 889bcd1bf1
2021-10-12 21:47:15 -04:00
Alexis 2e9f7b5069 Fix alignment of #ifndef USE_ALIGNED_ACCESS
Former-commit-id: 9637887264
2021-10-12 14:27:53 -04:00
jsully 763b349bd2 Merge branch 'multithread_load' into 'keydbpro'
Multithread load

See merge request external-collab/keydb-pro-6!5

Former-commit-id: 20e712244071028b0f75ccad477308efd139261f
2021-10-08 17:55:55 +00:00
John Sully ac22f3c60f disable key cache during load if necessary
Former-commit-id: 68dcf66909e2138da4902bdec98985f4fcd737cf
2021-10-04 07:35:36 +00:00
John Sully 9d78b8bb08 Handle the case where the key cache exceeds maxmemory
Former-commit-id: 01febf902267fec7fe87e6437b0b81fd08b50963
2021-10-04 07:34:05 +00:00
John Sully 86ec032e2c Don't expand the dictionary if a storage provider is set as we won't use the whole thing
Former-commit-id: 1f07b01144397cec59ec2d94f41c85eceb7248e2
2021-10-04 07:33:38 +00:00
John Sully d29df021b1 Use the concurrentqueue for multithread load instead of mutex and cvs
Former-commit-id: d5a59113dbfedaf7b62a650cff58a2e8ec01826f
2021-10-04 07:33:03 +00:00
John Sully 8a2f2bcb91 Add in the concurrentqueue
Former-commit-id: 319cad462be502b0b7a8c45b634d578b2c1c4e9d
2021-10-02 18:27:21 +00:00
jsully 1f323d743f Merge branch 'improve_overwrite_performance' into 'keydbpro'
Improve overwrite performance

See merge request external-collab/keydb-pro-6!4

Former-commit-id: 7e59e889f28e30fca409dfb951c31f8cb47effbd
2021-09-28 18:13:12 +00:00
John Sully 663f0bca3e Revert "Don't zero out potentially long buffers" - It has no benefit above the noise floor and potentially is the cause of a multithread slowdown
This reverts commit 9a9841afb3ffac4ebece0ec911b35ce1fe1c7e35 [formerly 91e76ab4a00546278100baf6dfe61c13e802b40e].


Former-commit-id: f651cf67d731a10c3a52e30261c8d8b9d291576c
2021-09-28 18:08:15 +00:00
malavan 81be792183 add hmset and hmget to keydb-benchmark
Former-commit-id: e05466c362ba01e61cf007ad8bfc26e1af21ec4f
2021-09-23 20:53:27 +00:00
malavan 33c0ae4084 add async tag to hgwtall hkeys hvals hscan
Former-commit-id: 8534de27603bd4cbd10a087840bcb1a90651afa1
2021-09-23 20:18:38 +00:00
malavan cd4864e69e add async lookup to hmget
Former-commit-id: a967b47b60e3f4efbc945dc44a0903f47e07993f
2021-09-23 19:57:18 +00:00
malavan e3c09a2e79 Merge branch 'async_commands' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into async_commands
Former-commit-id: a19112ec839da4684aeb1a9d1b41906f4c698944
2021-09-23 17:48:33 +00:00
John Sully c1332c89ca Rework the tuning to be better for mixed read/write workloads
Former-commit-id: a4fdd3e3cb41160b20e92e1b1f4f4ebd2ee86a4a
2021-09-23 17:46:56 +00:00
John Sully 48ba79618e Move the snapshot stale threshold to a named constant
Former-commit-id: 46d2aaf17abb0fb021aa6d7b393ffc143493d339
2021-09-23 17:45:49 +00:00
John Sully 0594060e75 prefetch crashes intermittently when a snapshot exists
Former-commit-id: 4a2657023d5d8218c815ce77c2676fd53a634b3f
2021-09-23 17:44:06 +00:00
malavan 1f4c9e6a75 prev_error_count needs to be thread local
Former-commit-id: 4abede1c40db1dfb4235b9aa1e3177678c5304b1
2021-09-23 17:41:28 +00:00
John Sully 938d318596 Async commands incorrectly think they are dirty
Former-commit-id: 4874247931425767156ab3da934c00a4d4832bcf
2021-09-23 05:24:28 +00:00
John Sully 4a0b8534f4 Create snapshots less often, and use them if they exist
Former-commit-id: ba8a00074171d346813247de0b218e08c8f07b92
2021-09-23 00:19:52 +00:00
John Sully c3e01cbf9e Clients should initialize with an mvcc checkpoint
Former-commit-id: 5183cb721774be1b769d130359e4bddb1eb8224b
2021-09-23 00:15:47 +00:00
malavan ef1ca1be9b update expire tests for async commands
Former-commit-id: 088ecd30a7b360e63d701f811f2fc0b9d77f5eb0
2021-09-22 21:49:30 +00:00
malavan b16b003c13 make keyIsExpired check earlier on async read
Former-commit-id: 32dbfbb3a69681553b65afa2d05ea47058833550
2021-09-22 21:16:36 +00:00
malavan dd2d3aca1e remove unneeded mgetCore function
Former-commit-id: 7961d4253b5a356e24d17ab07ac79ba1bf191efd
2021-09-22 21:15:47 +00:00
malavan f9b88a79ce check if key is expired for async lookup
Former-commit-id: d4e3a2688e903fe426e791f8608495fca1c76df6
2021-09-22 19:30:38 +00:00
malavan acfa705d48 Merge branch 'async_commands' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into async_commands
Former-commit-id: 393add1f3d70f7d1e09ecbce60c65508bc06394d
2021-09-22 19:28:37 +00:00
John Sully e155bbc873 We can't evict in an async command
Former-commit-id: 39c2903cbca08c2dbfc3275f83d65e6360c61651
2021-09-22 19:26:30 +00:00
John Sully 978c578433 We returned too early and didn't set the mvcc
Former-commit-id: d8e2ffe538a6b237529c37cb142a7076dd4836f8
2021-09-22 19:25:57 +00:00
John Sully 4cd25093a4 We can't do a command async if there are monitors because we need the lock
Former-commit-id: c5b6ade51251a3f57b69d1f3d9c22b199ec00a69
2021-09-22 19:24:39 +00:00
malavan 14914df0c8 Merge branch 'async_commands' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into async_commands
Former-commit-id: d6cc79a80d0bd22c99e3ea21740c89870cfb235b
2021-09-21 22:00:33 +00:00
John Sully 19175ed885 Make tests deterministic and fix an issue found
Former-commit-id: fd00f39f3ca11053a5c99ab52daa1f9a051b7058
2021-09-21 21:59:19 +00:00
John Sully efbc9b3c7e Improve low load latency
Former-commit-id: f5ac2432cf58c697a6da101d63423679cbd08021
2021-09-21 21:15:21 +00:00
malavan 8a54bf38fc add mget to keydb-benchmark
Former-commit-id: 6bd15f65c46f570f66d58bd759e1c595006d783a
2021-09-21 20:57:08 +00:00
John Sully dcbd4c547f Make async commands runtime configurable
Former-commit-id: 23bafb5f7c3c9805581f4bf09d9d5136898c2883
2021-09-21 20:49:44 +00:00
John Sully cf85a9cd02 Initial implementation of async commands
Former-commit-id: 0d3a4ce7e60c42b2d81962f13100bd1789bf64a8
2021-09-21 20:43:16 +00:00
John Sully 4d605bea02 Unify job types so everything is processed in order
Former-commit-id: 625aa97e4cf16337e8b052b7a27491a0ab09110f
2021-09-17 17:27:19 +00:00
Malavan Sotheeswaran 27bf624bae Merge fix to dict resize during rdb load
Former-commit-id: c398d5f8a027c67acac64bdbfbd01486dde555eb
2021-09-17 16:10:48 +00:00
Maxime de Roucy d7efbd0c4e syslog: enforce syslog identity and facility as soon as possible
Former-commit-id: a9eaf0a130
2021-09-16 17:29:55 -04:00
Maxime de Roucy 3078d08c04 use LL_… log level instead of syslog LOG_… log level
Else there is an out of bound access in syslogLevelMap.

For example if we use `serverLog(LOG_INFO,…`, later in the code
it tries to access `syslogLevelMap[LOG_INFO]`.
LOG_INFO == 6 but syslogLevelMap only have 4 elements.


Former-commit-id: a1680fa612
2021-09-16 17:29:07 -04:00
malavan 765885bd7b if statement was actually correct
Former-commit-id: d44b99afdf1ec92f8a36f0c091c37328008d867b
2021-09-14 17:17:08 +00:00
malavan 34396255a2 the if statement was actually correct
Former-commit-id: 8e4d1ceb859b3440bdec525ff7b8ed4aef86f4b8
2021-09-14 17:15:44 +00:00
malavan 86784fe9ba improve overwrite key performance
Former-commit-id: 56f9d5528385ea78074a308c6d3987b920d6cc35
2021-09-14 17:06:04 +00:00
malavan 3c7c11539c missing brackets in databasesCron rehash check
Former-commit-id: f2f0d5287edda676a514cbc02172bb874569016b
2021-09-14 02:03:18 +00:00
John Sully 8210d67c24 Don't zero out potentially long buffers
Former-commit-id: 91e76ab4a00546278100baf6dfe61c13e802b40e
2021-09-10 00:40:08 +00:00
John Sully f695e2e26c In single thread mode don't batch
Former-commit-id: 7daadae789cdca6f0eb0c3f553737d4f8efc0566
2021-09-10 00:39:47 +00:00
John Sully 9483ff082c Don't zero out potentially long buffers
Former-commit-id: 99eb47e129a3cd555914d4816febb02f0058253a
2021-09-10 00:38:49 +00:00
John Sully 1b02987b0c In single thread mode don't batch
Former-commit-id: b1cb230690a584b8bfe7f433fc0ca0320877ebd3
2021-09-10 00:38:08 +00:00
John Sully 6a3294ab7b Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: 026e939db2897701d936487ca30dd1c30feb299b
2021-09-09 19:35:08 +00:00
malavan a8a550a911 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: f0025394aed6f72a8c678be0da7c42d5e4fad1d9
2021-09-08 21:16:41 +00:00
malavan a15352fc8a add command arg to clientArgs helper
Former-commit-id: b6f388ee3bd269bd8373ea16adb379ec6922ee0a
2021-09-08 21:16:04 +00:00
jsully d1e0684393 Merge branch 'async_mget' into 'keydbpro'
add async mget

See merge request keydb-dev/KeyDB-Pro!38

Former-commit-id: e315b39f4779d530f5ab93e1f15915211e6706e2
2021-09-08 19:08:23 +00:00
benschermel 77ecd63dc2 update deb packaging to build with systemd flag
Former-commit-id: d7bd4f7a1c
2021-09-08 02:28:17 +00:00
John Sully 44d1b90757 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into keydbpro_collab
Former-commit-id: 067acbbfd5eb0c2b4515a5d2cc87970870a88acb
2021-09-03 17:20:54 +00:00
malavan 35e5e85d95 don't use flags that aren't supported by certain versions of OPENSSL
Former-commit-id: ca7342948fb12804905219ae106b4722368e9a2f
2021-09-02 19:06:35 +00:00
malavan 570224a2c4 Remove duplicate code
Former-commit-id: a4c3182afb71a0d7d6d25111c0e0cfe5dcfc6130
2021-09-02 19:06:12 +00:00
malavan 286e9cccdc updates from comments
Former-commit-id: 852885f09e7df1d9570408546baffa8545707335
2021-09-01 21:00:27 +00:00
malavan b300551862 refactor asyncCommand
Former-commit-id: 6af5775e01872f130bc18791fdb4c0b22507b37f
2021-09-01 20:18:41 +00:00
jsully 7d453dd980 Merge branch 'add_storage_provider_data_to_INFO' into 'keydbpro'
add stats for storage provider reads

See merge request keydb-dev/KeyDB-Pro!39

Former-commit-id: 07bb08a8bc89350f4addb9dfd77435217c6b46d5
2021-09-01 19:21:05 +00:00
John Sully 6e7c4cbf17 We need to send keepalives to masters while waiting to prevent disconnects
Former-commit-id: 7cbd6758b1042198c14ca9e8da0f1f7bc05df93d
2021-09-01 04:15:59 +00:00
John Sully f3fb4e3209 Don't be in tracking mode during load as processChangesAsync works outside the normal system
Former-commit-id: 8d31ce6eafea1cea2f9f4ea25e44306efef28fa3
2021-09-01 04:15:28 +00:00
malavan 3bd777bf55 remove unused variable names
Former-commit-id: 18d688c2f04a8ce67409bd4442c7635d426fc0ac
2021-08-31 20:03:55 +00:00
malavan 7ee39396c0 add method to get client args as list
Former-commit-id: 576b8cd2153c48c0ca4dfc9ed7d12f77d6f76f7e
2021-08-30 21:09:22 +00:00
malavan 89e6442c09 add stats for storage provider reads
Former-commit-id: 612393ffba43cda31443605de924dc8dcf77ef52
2021-08-26 19:45:33 +00:00
malavan 0baa543819 add correct thread assert to client::asyncCommand
Former-commit-id: a892fb4d551fb58d619bc80c333a6b3a9ed34215
2021-08-26 14:23:13 +00:00
malavan b92c0e8d5c add correct thread assert to client::asyncCommand
Former-commit-id: 8970f832348a80db6c183d25c4a5342a258a6ba9
2021-08-26 13:58:12 +00:00
malavan 1b074c3983 refactor scan to use client::asyncCommand
Former-commit-id: 4de596631f48626b770d0217c7ff21001ea46bcf
2021-08-26 13:55:32 +00:00
malavan 6175535d54 refactor of asyncCommand to include snapshot creation
Former-commit-id: c0908362162b5f2834b90cd9ce84fd1ee6768834
2021-08-26 13:10:59 +00:00
malavan 7451f1738a change indentation and increase async mget threshold
Former-commit-id: ffaa176d5eafabfae372224c790e99dd9e520fef
2021-08-25 22:15:28 +00:00
malavan dcd3d47f7f refactor async to offload common code to client
Former-commit-id: 9a7547bfaa0ceff76e604262913fb11a64c627d8
2021-08-25 20:06:06 +00:00
malavan cb8f55c057 Merge branch 'keydbpro' into async_mget
Former-commit-id: ae34d0b6324ebd9d2d52342c06b3fd49f110210c
2021-08-25 19:37:33 +00:00
jsully dd9e0ab9c3 Merge branch 'upgrade_rocksdb' into 'keydbpro'
upgrade to latest version of rocksdb

See merge request keydb-dev/KeyDB-Pro!34

Former-commit-id: 74c39b237ee0f9ff98a6cc8e3e4fbf70a3ee00ac
2021-08-25 19:08:19 +00:00
malavan 6494142866 update gitlab ci to work with facebook repo instead of ours
Former-commit-id: 2745277e7591076373e2dfd4eef8c1412cffffbc
2021-08-24 22:07:21 +00:00
malavan 7d693c3665 use latest stable version
Former-commit-id: 792f72cb513fc6db58d824649478ee36d47631eb
2021-08-24 22:00:52 +00:00
malavan aaadb0ce38 Merge branch 'keydbpro' into upgrade_rocksdb
Former-commit-id: 1bf9d7e749e7007f1309f3e57e366122fdbacbac
2021-08-24 21:54:01 +00:00
malavan 6f7283c065 add async mget
Former-commit-id: c7bd2327f8e4330e2bcd857fc87ce7e86e075d20
2021-08-24 21:44:17 +00:00
malavan 9bedb29fb6 add a few more flash tests
Former-commit-id: b19fdc23a9a39ae718580feae5049f6906caec28
2021-08-23 21:30:16 +00:00
benschermel d634b09864 fix service install
Former-commit-id: c43cec74178d8bf35143f3f4148dbe3c37a75f90
2021-08-23 18:41:43 +00:00
malavan a1bbb17a5d newest version of rocksdb
Former-commit-id: e384baa62e50a5caa0cdc779f2b8554ce8d8b375
2021-08-23 17:04:01 +00:00
benschermel 50394ce5f9 fix service install
Former-commit-id: 41bf39f6e92beb8ab55ec0e7652154bc43d48774
2021-08-23 03:39:16 +00:00
benschermel 37cd24866a update pkg conf file
Former-commit-id: f87945cbbd2a475394f584b09b15c2c19db5e9bd
2021-08-22 22:29:42 +00:00
benschermel ebbf84fb15 update pkg conf file
Former-commit-id: 2a2ae61f07ecea8a178f4bc478bb7786d5be27d9
2021-08-22 22:28:18 +00:00
benschermel eb9b09c311 update pkg conf file
Former-commit-id: 0be40b9fd4
2021-08-22 22:21:34 +00:00
benschermel b8bb658e47 update pkg conf file
Former-commit-id: 03a52dade1
2021-08-22 22:18:22 +00:00
Malavan Sotheeswaran 31f9ab610c Merge branch 'keydbpro' into 'PRO_RELEASE_6'
Keydbpro

See merge request keydb-dev/KeyDB-Pro!37

Former-commit-id: e6a130e4a02b3d0cc2fcaeb0ab24e23cb60a7181
2021-08-19 19:11:04 +00:00
malavan ab3eec4d59 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: 4059f9c2396f0fa517ac2946ad5f0e45039c00e6
2021-08-19 18:24:29 +00:00
malavan 0abda4443a switch to new patch of rocksdb that fixes archlinux build
Former-commit-id: e2e5b5320e5c1b89ec2a3f946826097b819f6593
2021-08-19 18:24:01 +00:00
Malavan Sotheeswaran df6aeee332 Merge branch 'patch_rocks_db' into 'keydbpro'
public copy of rocksdb

See merge request keydb-dev/KeyDB-Pro!36

Former-commit-id: 4421396764688f7df2c967974f6a3b5dca28e3f5
2021-08-19 18:08:16 +00:00
Malavan Sotheeswaran 0a37b2b933 Merge branch 'keydbpro' into 'patch_rocks_db'
# Conflicts:
#   .gitmodules

Former-commit-id: aec26e46d3b3617a57edd42d996f7598de5bfe4e
2021-08-19 17:57:52 +00:00
malavan 4d72668045 use --init instead of git submodule init
Former-commit-id: 967866c56c9d4590d72c63169d0e3c32c21b24e0
2021-08-19 17:47:23 +00:00
malavan 9192272cd8 use --init instead of git submodule init
Former-commit-id: e5582ddf313a6bdd2ae0cb68da980954caf83e1b
2021-08-19 17:45:37 +00:00
malavan 76ce7ae47a add branch for git submodule
Former-commit-id: b4471308f1cf99b0a5a4c8c8da8ccf9546123e3f
2021-08-19 17:42:52 +00:00
malavan 1ad621db0f public copy of rocksdb
Former-commit-id: 50bbadcab6d2911fb9cbe15aef03c9762aa91280
2021-08-19 17:22:09 +00:00
Malavan Sotheeswaran dd0de078bc Revert "Merge branch 'patch_rocks_db' into 'keydbpro'"
This reverts merge request !35

Former-commit-id: 8ee1c251de5687fdcf8af740766d2968163bc8e9
2021-08-18 22:47:38 +00:00
Malavan Sotheeswaran d80fc585db Merge branch 'patch_rocks_db' into 'keydbpro'
Patch rocks db, switch to private clone of rocksdb

See merge request keydb-dev/KeyDB-Pro!35

Former-commit-id: 08155fa62332a9e9d3046796cb378e04405c6ca7
2021-08-18 22:07:56 +00:00
malavan 9158411101 use our own clone of rocksdb
Former-commit-id: 1de8a88679faa94d14875655305e6102289556a0
2021-08-18 21:53:55 +00:00
malavan d7bcea1fe2 use our own clone of rocksdb
Former-commit-id: 0aeceb2a8c487eea43d47497647d4e38a3478ca7
2021-08-18 21:46:16 +00:00
MalavanEQAlpha fd5f0b8ebe Merge pull request #313 from MalavanEQAlpha/fixissue295
Resolve Issue #295 by speeding up keyIsExpired and setting timeout on subkey expires.

Former-commit-id: 9e5e6c2f86
2021-08-18 17:34:18 -04:00
malavan 67300040f7 should use LLONG_MAX for INVALID_EXPIRE not LLONG_MIN and add better comments
Former-commit-id: 1ab19b445f
2021-08-18 20:59:01 +00:00
malavan 09d8acd9fb patch rocksdb to fix archlinux build
Former-commit-id: b3c6e4f6353935545dca73cbc103fac9f3da7c42
2021-08-18 20:13:53 +00:00
VivekSainiEQ af217ab261 Include gperftools/tcmalloc.h instead of google/tcmalloc.h
Former-commit-id: ee32ed045c
2021-08-18 15:40:09 -04:00
John Sully ae7a09c508 Solo tests should work with loopn
Former-commit-id: 82ba449dd0
2021-08-18 15:08:10 -04:00
malavan 8673045ac6 upgrade to latest version of rocksdb
Former-commit-id: 9272e412acecc7d032c6299fb815c84c15fb0e2d
2021-08-18 15:18:51 +00:00
benschermel cfc4ff96d3 add keydb-diagnostic-tool to packaging
Former-commit-id: 971725cc8c
2021-08-16 23:21:07 +00:00
malavan 7686b09b39 Remove duplicate code
Former-commit-id: 9b7febb538
2021-08-16 22:55:46 +00:00
malavan fd84a41aba don't use flags that aren't supported by certain versions of OPENSSL
Former-commit-id: fae6bfb80b
2021-08-16 22:55:46 +00:00
malavan ce23ead7a8 Remove duplicate code
Former-commit-id: 046df30861b73f796a7819d8a9ffe6bd68b7e910
2021-08-16 22:53:00 +00:00
malavan e277a2f8f0 don't use flags that aren't supported by certain versions of OPENSSL
Former-commit-id: 1ae9af250513d1430160b37d24ba617551402926
2021-08-16 22:49:55 +00:00
malavan 4d140a4314 Merge remote-tracking branch 'origin/keydbpro' into PRO_RELEASE_6
Former-commit-id: 11214acb5aff8af1e09a64ee2db71357899a9bf7
2021-08-16 22:49:18 +00:00
Malavan Sotheeswaran 76d98f6c6d Merge branch 'pkg_update_tools' into 'keydbpro'
add diagnostic tool to packaging

See merge request keydb-dev/KeyDB-Pro!33

Former-commit-id: f87960ac26a710ed1a014a93e47740db1a81a07f
2021-08-16 22:44:53 +00:00
Malavan Sotheeswaran 3a0aa6be9b Merge branch 'add_asyncFreeDictTable_to_diagnostic_tool' into 'keydbpro'
add asyncFreeDictTable tokeydb-diagnostic-tool.cpp to avoid linker error

See merge request keydb-dev/KeyDB-Pro!32

Former-commit-id: 0a253222359454f233b82c8aaff7c2d9ab57e571
2021-08-16 22:44:43 +00:00
Malavan Sotheeswaran 22cc61345b Merge branch 'pkg_config' into 'keydbpro'
update packaging config files

See merge request keydb-dev/KeyDB-Pro!31

Former-commit-id: d6bce861e5bafa30d1cc31d1856c75f6e492d454
2021-08-16 22:42:29 +00:00
benschermel ad18db98b5 add keydb-diagnostic-tool to packaging
Former-commit-id: 45bb6e801f
2021-08-16 22:10:31 +00:00
benschermel 40af58026a add diagnostic tool to packaging
Former-commit-id: 37c3ca16162bd8a97ef35e2104ff5dc0ed6d7e48
2021-08-16 21:59:59 +00:00
malavan 6f5c6bcaf1 add asyncFreeDictTable tokeydb-diagnostic-tool.cpp to avoid linker error
Former-commit-id: 6b1509932f592ffffb9dd5d06de7f313d44e4394
2021-08-16 21:35:52 +00:00
malavan 315ee2f51b Merge remote-tracking branch 'opensource/RELEASE_6' into PRO_RELEASE_6
Former-commit-id: 4505b3caa94ea0366014fabcbdb36850f7b60be7
2021-08-14 04:04:05 +00:00
MalavanEQAlpha 908a0053d5 Merge pull request #344 from EQ-Alpha/fix_pbuild_ubuntu18.04
don't use flags that aren't supported by certain versions of OPENSSL

Former-commit-id: 1b73bc76c0
2021-08-13 23:59:50 -04:00
malavan 3c157023bc don't use flags that aren't supported by certain versions of OPENSSL
Former-commit-id: 0bfd2ea8a6
2021-08-13 20:02:06 +00:00
malavan 3da2de685c Merge branch 'RELEASE_6' of https://github.com/EQ-Alpha/KeyDB into RELEASE_6
Former-commit-id: 11c6d585ca
2021-08-13 15:46:24 +00:00
malavan 7f8b58e376 Remove duplicate code
Former-commit-id: 2911145df7
2021-08-13 15:46:09 +00:00
christianEQ c89e0f711a install 32bit libraries in github action
Former-commit-id: b08aa26a76
2021-08-13 11:05:12 -04:00
christianEQ ef2c490b52 github runner for 32bit build
Former-commit-id: 8dacbed556
2021-08-13 11:05:12 -04:00
christianEQ 166faa8988 changed keys counter variable to unsigned to fix signedness comparison warning
Former-commit-id: b44df43fcb
2021-08-13 11:05:12 -04:00
christianEQ 9b24998e1b %zu for printing type size_t
Former-commit-id: 84af829053
2021-08-13 11:05:12 -04:00
christianEQ 8d01244594 fixed 32bit compatibility in Makefile
Former-commit-id: f5ee64f9aa
2021-08-13 11:05:12 -04:00
christianEQ cbf83d5eff fixed overly strict assert for 32bit
Former-commit-id: ce4891b33d
2021-08-13 11:05:12 -04:00
benschermel 033fb4a612 update deb master changelog
Former-commit-id: afd8ac5c38
2021-08-13 00:49:41 +00:00
benschermel 5528b75555 update deb changelog
Former-commit-id: d919317ac338a9bfa2e8de7338fcf08a51e31dd1
2021-08-13 00:48:45 +00:00
benschermel 32e6ec97fe bump version
Former-commit-id: 7260ebf5c1
2021-08-13 00:40:46 +00:00
benschermel f082cdb9fe bump version
Former-commit-id: af0769c1a917e9b17dda15b5aca6efdb958bfce4
2021-08-13 00:35:19 +00:00
malavan 5b115b56a1 bump version
Former-commit-id: aae676dc7d
2021-08-11 23:23:39 +00:00
malavan 677cceea57 bump version
Former-commit-id: d923003969be0ecb507bea0acc643ccdf06f8831
2021-08-11 23:22:17 +00:00
malavan 4ed2a52546 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 6b385bc057d8a01ed57a6c0d89eb30e9832fe1ca
2021-08-11 21:20:47 +00:00
malavan 9f1f29543f Merge remote-tracking branch 'opensource/unstable' into keydbpro
Former-commit-id: cf40fa5da29ba9574d20d706d0a41ca7001df95a
2021-08-11 20:41:54 +00:00
malavan 007bd5084b Merge remote-tracking branch 'origin/unstable' into RELEASE_6
Former-commit-id: 16897d36b8
2021-08-11 19:59:28 +00:00
MalavanEQAlpha 89d6d9632f Merge pull request #318 from VivekSainiEQ/redisearch_fixes
Initialized serverTL in more places in module.cpp

Former-commit-id: ffa46b8f0b
2021-08-11 15:47:30 -04:00
Vivek Saini 8b013dc597 Merge pull request #296 from VivekSainiEQ/systemd_fix
Fixed bug where make USE_SYSTEMD=yes would not pass in correct flags

Former-commit-id: bf05c261d2
2021-08-11 15:39:50 -04:00
VivekSainiEQ e0bdb4fca6 Merge remote-tracking branch 'upstream/unstable' into redisearch_fixes
Former-commit-id: 952ae9fbe3
2021-08-11 19:28:04 +00:00
VivekSainiEQ 72e02159f4 Prevent invalid mvcc timestamps from causing critical errors
Former-commit-id: 6f2dbb0011
2021-08-11 15:06:14 -04:00
Paweł Sacawa 39dccbbf21 Add: zsh completions with descriptions
This commit add zsh completions for the keydb `client`. They have contextual host completion and full argument descriptions.
Vendor-distributed completions for zsh should end up in `/usr/share/zsh/vendor-completions`, but unfortunatly I'm not familiar with the packaging method for *.deb archives, so these completions will need to be moved to the appropriate directory.


Former-commit-id: f77980fce8
2021-08-11 15:05:11 -04:00
MalavanEQAlpha 31cb587b27 Merge pull request #340 from EQ-Alpha/update_keydb.conf
update keydb.conf with new configs from redis unstable

Former-commit-id: d90c1e6eae
2021-08-11 15:04:22 -04:00
MalavanEQAlpha 97a47446b8 Merge pull request #341 from EQ-Alpha/pkg_config
update packaging config files

Former-commit-id: d987f463eb
2021-08-11 15:01:37 -04:00
John Sully 14ab4823f0 Merge branch 'keydbpro_collab' into multithread_load
Former-commit-id: f36e9efd8e0079650c78e1e8c19c5fa8553c8251
2021-08-11 02:54:02 +00:00
John Sully 1a66c5fdab Fix crash loading RDB on start with a storage provider set
Former-commit-id: ace6a44399a15ab48a7ef798dc656dbc1207b58d
2021-08-11 02:53:44 +00:00
John Sully c6a0c7b04f Fix crash in load with storage provider set
Former-commit-id: 6990818b7ca647819b50ae04224778e6f8f12a1a
2021-08-11 01:19:39 +00:00
benschermel 5a1a712ec6 add script to compare all active config parameters of any 2 config files
Former-commit-id: 89beaf2460
2021-08-10 20:10:28 -04:00
benschermel cc5528a8e2 update packaging config files
Former-commit-id: 0c5d12b914
2021-08-10 20:08:39 -04:00
benschermel c5f15b645a add script to compare all active config parameters of any 2 config files
Former-commit-id: b873f90dc1f0f9343bc5c8c3c94a544b5f1f7321
2021-08-10 20:06:59 -04:00
benschermel 9876458177 update package config files
Former-commit-id: fd367a91cc0feb22b67f034627d59feb679b81e8
2021-08-10 20:04:30 -04:00
malavan 000e36f605 update keydb.conf with new configs from redis unstable
Former-commit-id: 32ca2e8a73
2021-08-10 21:34:52 +00:00
malavan 02d3141e75 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: a1b8103f429a319e19ca8144f8442905530d7ed8
2021-08-09 22:15:44 +00:00
John Sully c77ce968c5 Merge branch 'keydbpro_collab' into multithread_load
Former-commit-id: 8016c20f1f9a648e658c816e2f6777c5718d5e19
2021-08-09 20:20:34 +00:00
malavan 0b752dd4e0 Merge branch 'unstable' into RELEASE_6
Former-commit-id: 4705235739
2021-08-09 18:17:11 +00:00
Malavan Sotheeswaran 5923d49d8d Merge branch 'add_ci' into 'keydbpro'
Use artifacts to speed up pipeline

See merge request keydb-dev/KeyDB-Pro!30

Former-commit-id: 2b377364d0df4779cf5fef75d30853e1dab73638
2021-08-06 02:20:18 +00:00
Malavan Sotheeswaran 374ec0437b Use artifacts to speed up pipeline
Former-commit-id: 37ad7b3567aaefa7785eb50e1370db4734605e4c
2021-08-06 02:20:18 +00:00
Malavan Sotheeswaran 9541358630 Merge branch 'fix_shrink_on_rdb_load' into 'keydbpro'
add noshrink flag to stop dict from shrinking during mass insertions

See merge request keydb-dev/KeyDB-Pro!28

Former-commit-id: 41241189cb0238b240b2f894f77ae254e49770ac
2021-08-05 20:07:31 +00:00
Malavan Sotheeswaran e2abe4f1a0 add noshrink flag to stop dict from shrinking during mass insertions
Former-commit-id: 5e0c994ec82f4adb437a31f8d89eee7a09145576
2021-08-05 20:07:31 +00:00
Malavan Sotheeswaran 81639cd0a6 Merge branch 'add_ci' into 'keydbpro'
remove duplicate rules and fix duplicating pipelines

See merge request keydb-dev/KeyDB-Pro!29

Former-commit-id: 8e458fb4bed27f653a3630e15aa9c637b2915f62
2021-08-04 15:00:18 +00:00
malavan 2c65ef7a84 disable node redis for now since it does not work with redis 6.23
Former-commit-id: 6bd93684b6078782fc40973b253f1534d79888c1
2021-08-04 01:50:55 +00:00
malavan 2be6b9576e remove duplicate rules and try to fix double pipelines
Former-commit-id: 0f504408042670f3ead2e1522dcbbae7c4c3b62c
2021-08-04 01:44:47 +00:00
Christian Legge 7015a2abd2 Add REPLPING command for use during replication (#329)
* added replping command for initiating replication

* backwards compatibility for replping (retry if not recognized)

* don't allow ping during loading (load balancer fix)

* changed replping warning to notice

Former-commit-id: d7f6bc1614
2021-07-29 15:50:30 -04:00
malavan b32fe9eab5 don't create pipeline on every push
Former-commit-id: fb4bb008856c3e685afb470617a1ab3579ee63a8
2021-07-28 22:52:50 +00:00
Malavan Sotheeswaran ae8d015036 Merge branch 'add_ci' into 'keydbpro'
make make test multithreaded

See merge request keydb-dev/KeyDB-Pro!27

Former-commit-id: 7cb619601d110962ef061b99425ab03d914929c8
2021-07-28 22:23:54 +00:00
MalavanEQAlpha 7e08a9001c Merge pull request #328 from EQ-Alpha/backtrace_for_alpine
Backtrace for alpine using libunwind

Former-commit-id: 83d878f111
2021-07-28 17:17:06 -04:00
malavan 54f40aff81 add some comments
Former-commit-id: 0fc6441c96
2021-07-28 20:32:18 +00:00
John Sully aef0bd877f Fix issue collab #32
Former-commit-id: 0d192cf00ebe9fc0d898404b86e1173476edaefb
2021-07-26 22:30:31 +00:00
John Sully a8685235c3 Initialize el so we can detect if it is null
Former-commit-id: ec0f833ea17c668971893aa8f198d22da2e1d289
2021-07-23 19:31:22 +00:00
John Sully 9e8a28c0ed We cannot create time events on threads that don't have an event loop
Former-commit-id: 3812586a41bb7f974b5d9820c8a68ff34ee8aa9a
2021-07-23 16:02:57 +00:00
John Sully e3df237f39 We cannot create time events on threads that don't have an event loop
Former-commit-id: 4c88a4ee0e86f6e1c9b18733e48ce50751d01e45
2021-07-23 16:02:29 +00:00
malavan 69f3e7c802 remove duplicate function
Former-commit-id: 81cf9979ed
2021-07-21 16:00:24 +00:00
malavan 99a165e0f6 add stacktrace message
Former-commit-id: 5be1620629
2021-07-19 23:17:18 +00:00
John Sully ea19d31df8 Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: e4e5c6696c6d831924f314a198b266b10d831e14
2021-07-19 20:51:27 +00:00
John Sully bacaa204cf Disable async rehash during load as it interferes with eviction
Former-commit-id: 54b4f39e9d634bf53b04cd94433b051b14323bc6
2021-07-19 18:17:54 +00:00
John Sully 345ec75a36 We need to free in order since the first big async free is likely the largest, so don't set the hipri bit
Former-commit-id: 76a9cefa94e0f446e12a690909cbda15d03ca211
2021-07-19 18:01:39 +00:00
malavan 16f361abf6 dd comment and set eip unused
Former-commit-id: 685b87e2ef
2021-07-19 17:32:38 +00:00
malavan 70cb3267de dd comment and set eip unused
Former-commit-id: 72429c2106
2021-07-19 17:31:24 +00:00
malavan 9e411426f2 dd comment and set eip unused
Former-commit-id: 7707fe15a9
2021-07-19 17:29:43 +00:00
malavan abf2114117 add backtrace for alpine using libunwind
Former-commit-id: c583ffff41
2021-07-19 17:20:52 +00:00
malavan fedf45675c Merge branch 'add_ci' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into add_ci
Former-commit-id: 82438d8332e4f23c67df17f888b87aff04a46363
2021-07-19 17:01:17 +00:00
malavan 697f17f91d split up runtests
Former-commit-id: 93e36a064033dc55fe281fe113425b33cf42b2c3
2021-07-19 16:59:03 +00:00
John Sully 88f5bf1d90 We need to periodically flush the GC or we'll end up blocking with a huge backlog at the end of load
Former-commit-id: 29c0bf79ad1a810e808790de2f7db24f3cc603e8
2021-07-19 16:50:48 +00:00
Malavan Sotheeswaran 105fc01d39 Merge branch 'keydbpro' into 'add_ci'
# Conflicts:
#   .gitlab-ci.yml

Former-commit-id: 828924d67d622483fccf570649fc81aa3d78673b
2021-07-19 16:16:36 +00:00
malavan e11d7f25d1 change make test to multithreaded
Former-commit-id: 8f2bae851f2aa7c2600a487733a82850d6552882
2021-07-19 15:52:33 +00:00
John Sully d3793efb33 Info command should show how many keys are cached in RAM vs storage provider
Former-commit-id: 08597bee69bc16ca7c3d5ff31020472774c6eec9
2021-07-19 15:11:33 +00:00
John Sully 614860ce3c StorageCache dtor leaks
Former-commit-id: 0262c4dc76a320141b8a4454df2f6baab4f74ab3
2021-07-19 15:10:48 +00:00
John Sully 4000334b1f Do not resize replica buffer past the max client limit
Former-commit-id: ba116500ca4fd53e4e40f04fc33981e60bb21ab7
2021-07-18 20:48:08 +00:00
John Sully 5f72ce9317 Return the ring buffer to its original size if we temporarily resized it
Former-commit-id: a12ce4a0d105bf7d6ccff95f7dc0044c4676b0a7
2021-07-18 20:45:32 +00:00
John Sully 0b220bddc7 Do not update batch variables when not in a batch
Former-commit-id: ad1e0286cf9b2d9de33c65e8e798a05ead3f7d5a
2021-07-18 20:28:42 +00:00
Christian Legge d05333bf53 Merge pull request #321 from EQ-Alpha/ci-flags-fix
Requested changes from 6.2.2 merge

Former-commit-id: 7c1ab8b8e2
2021-07-15 16:42:02 -04:00
christianEQ 43f31da324 fix warnings for mac build
Former-commit-id: 570fbd0149
2021-07-15 20:14:14 +00:00
Malavan Sotheeswaran 91c4c2b7f7 Merge branch 'add_ci' into 'keydbpro'
test CI do not merge

See merge request keydb-dev/KeyDB-Pro!24

Former-commit-id: 047e32c63a329c9ebc6756db704eda8bbcc1b10a
2021-07-14 23:41:24 +00:00
Malavan Sotheeswaran f518193862 test CI do not merge
Former-commit-id: ccdf18b1bef07ba076e5f86d74fe1e1f6ae50a8c
2021-07-14 23:41:24 +00:00
christianEQ a833c9b2a7 Merge remote-tracking branch 'origin/unstable' into ci-flags-fix
Former-commit-id: da1f09e9b5
2021-07-14 22:56:15 +00:00
malavan f6d8d32539 add endurance test
Former-commit-id: 3ebd20e66fd6cf858f8d7de7de223d18c387a2a9
2021-07-14 22:15:44 +00:00
malavan bfefd8a11b use INVALID_EXPIRE instead of -1
Former-commit-id: 9e45984a97
2021-07-14 22:13:29 +00:00
christianEQ f11601bcfc added REDIS_CFLAGS to makefile for backwards compatibility
Former-commit-id: b2fb4f4b9b
2021-07-14 21:51:44 +00:00
malavan c255a454ec cleanup based on 6.2.2 merge review
Former-commit-id: 51277b17a7
2021-07-14 15:22:27 -04:00
Christian Legge 5019f9c537 Merge pull request #322 from EQ-Alpha/diagnostic-tool
Basic first iteration of Diagnostic Tool

Former-commit-id: 32f5ef864e
2021-07-14 14:19:44 -04:00
malavan 59eec6da85 more specific requirements for jedis and node-redis
Former-commit-id: 4d3f9cb88a8d60ac0350d658f76bae7ad5e17e8f
2021-07-13 20:58:58 +00:00
Christian Legge 25d992777c Merge pull request #327 from EQ-Alpha/issue323_fix
fix for #323: seg fault on expiremember

Former-commit-id: a8f28297ec
2021-07-12 16:54:31 -04:00
christianEQ 229bb85dec tabs -> spaces
Former-commit-id: 0ae13c9731
2021-07-12 18:55:44 +00:00
John Sully d3d7c3a865 Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: 8eec3e948ffd204bb2d6170ad3ca42fa8a2c6d8b
2021-07-09 05:25:04 +00:00
John Sully 2616ed75cc Merge branch 'unstable' into keydbpro
Former-commit-id: 81ded8a35daa5100cac7299a7d0b5f43ee7ac74f
2021-07-09 04:41:47 +00:00
John Sully c0160a4415 Merge tag '6.2.3' into unstable
Former-commit-id: 1895dbb768
2021-07-09 04:40:31 +00:00
malavan fe13e24e99 only use docker
Former-commit-id: c66dbb4afe6b63caa065b7ff8e7b11691099b1ce
2021-07-08 19:11:13 +00:00
christianEQ cf23416296 added eq alpha copyright
Former-commit-id: a6cbbd0f31
2021-07-08 02:58:18 +00:00
christianEQ 145015dc51 fix for #323: seg fault on expiremember
Former-commit-id: f1f52af9cf
2021-07-08 02:50:05 +00:00
christianEQ ea95e6c406 various branding and cleanup fixes
Former-commit-id: e3c619eca4
2021-07-08 02:46:42 +00:00
jsully ed6dda0887 Merge branch 'license_status_fix' into 'keydbpro'
license status OK if not checking license

Closes #14

See merge request keydb-dev/KeyDB-Pro!19

Former-commit-id: f66d0970b1eb9be50210a88bf773769a40513521
2021-07-07 18:07:30 +00:00
malavan 3b54d3ad8e gitlab-ci syntax error
Former-commit-id: 5bab59629c39c8eb22567be36faf092d0b54dbe4
2021-07-07 08:32:09 +00:00
malavan 30f092066d gitlab-ci syntax error
Former-commit-id: 92aaa4fd66225593fa477053f960ee1dbf2f522c
2021-07-07 08:30:41 +00:00
malavan f0d188cb07 gitlab-ci syntax error
Former-commit-id: 2a5b4297425e773cc97376f271acce535ef3a20e
2021-07-07 08:26:39 +00:00
malavan cf1b1b7510 code coverage job
Former-commit-id: 418fd5716dde4b8034259ca31290e5538f0f0aad
2021-07-07 08:25:37 +00:00
malavan 8105dc37eb add redis-rs
Former-commit-id: 13f171eb06b98f25424b1dff8c6572b668dd92ad
2021-07-07 05:28:59 +00:00
malavan d8c0e5ddad tmp dir created by jedis make now
Former-commit-id: 2c362ea5359f0f814da231a5fb9e826d1851bfe3
2021-06-30 17:51:51 +00:00
John Sully 24a24dd082 Merge branch 'repl_backlog_rework' into keydbpro_collab
Former-commit-id: 0983e195757d92d6cbcb63436a1332a6b80e275c
2021-06-30 06:36:45 +00:00
malavan 11e1283526 Merge branch 'keydbpro' into add_ci
Former-commit-id: 3a745920e519177390a36abc207e02f01e35828a
2021-06-25 12:15:52 +00:00
malavan 154baae2ad add tags hopefully no need to kill stunnel
Former-commit-id: 6b49258ba88874075e18e71911f472bc95595c5a
2021-06-25 11:46:28 +00:00
John Sully 6ba0e699d4 Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: ecc69952dfd1f145e1aff12bca56a4b4e102d669
2021-06-25 06:21:58 +00:00
John Sully 0d8da2c350 Avoid taking locks when we don't need to
Former-commit-id: 0d8d3ee9e217cd1f1366a117e6e212f610a028e1
2021-06-25 06:11:14 +00:00
John Sully 165e73353a OPTIMIZATION: Only notify the condition variable when needed
Former-commit-id: 11f07b49c613f54cef682da1e3c8fc54918809b0
2021-06-25 06:11:01 +00:00
John Sully 8db07641ad Reenable LTO
Former-commit-id: e7c1e1c9d8021f48c4081a9dfb84dba9da2521fc
2021-06-25 06:10:13 +00:00
jsully 088e1db814 Merge branch 'repl_backlog_rework' into 'keydbpro'
Replication backlog rework

See merge request keydb-dev/KeyDB-Pro!23

Former-commit-id: 6937d3be40fdc79dddc1852bf7fc8565984da006
2021-06-25 03:10:56 +00:00
vivek 0e953fb916 Primitive implementation of bypassing client buffer, stats are all messed up and print statements everywhere
Former-commit-id: 59b2ae8ff451f8a5ac2f3baf3c7b509f6872895e
2021-06-25 03:10:56 +00:00
John Sully 5949e253ca remove unnecessary newline
Former-commit-id: 532af9cd0286ac6ece6f401c42aea18e36d16f7c
2021-06-25 02:46:32 +00:00
John Sully e6a82692b7 Avoid holding the lockPendingWrite for too long and deadlocking due to lock inversion
Former-commit-id: a4b49fbec60e2333a4407d24383ae204d5d2b413
2021-06-25 02:31:17 +00:00
John Sully 815ebe1e6b Remove fPendingReplicaWrite flag which can instead be calculated on demand
Former-commit-id: ae26afd13f955eb230b5c2cab20ec90db9b714ad
2021-06-25 01:54:38 +00:00
malavan f151ba91b0 don't fail on pkill
Former-commit-id: 7e187095eb82052c2ef0a37094a0cf3c0545c2f0
2021-06-24 22:51:14 +00:00
malavan df8eb2c106 add local tmp dir
Former-commit-id: 7a8f6e7f3c2b4a3e10dabdb2961a39bdd859a2e0
2021-06-24 14:38:52 +00:00
malavan b755231321 reset stunnel for jedis
Former-commit-id: 52d0e91046975791cc91ae230777f80ba2573dc9
2021-06-24 14:04:31 +00:00
malavan 2b3947b15f add jedis-test
Former-commit-id: 964e0313169f3d942d9ea6d7c4af181a20f9c663
2021-06-24 13:34:08 +00:00
christianEQ e5939c5de9 removed unused command line options
Former-commit-id: 57e59d97db
2021-06-22 17:13:35 +00:00
christianEQ 6c5246fb09 changed --ms to --time
Former-commit-id: d7cada0f38
2021-06-21 19:57:14 +00:00
christianEQ 59102658a3 added more verbose options
Former-commit-id: fd2ac1fcfc
2021-06-21 18:40:37 +00:00
christianEQ 2bbb8a54fc -t threads option
Former-commit-id: 0181b0e7a1
2021-06-21 18:36:21 +00:00
malavan 245086f48b redo build instead of upload and download
Former-commit-id: 841cdb2a429576ef2a6fb299aef2156ec56df243
2021-06-19 07:07:28 +00:00
malavan 6e5ffef0ec copy entire directory not just src
Former-commit-id: f75c88039383e1ebb83ea3254c07541b8575e869
2021-06-19 07:01:35 +00:00
malavan 56b1e072f9 try to maintain combined files between jobs
Former-commit-id: acf5161c353ddcbbdfc45b4e85ae978bb442e507
2021-06-19 06:55:41 +00:00
christianEQ 0d9e0a9039 added starting line so diagnostic tool doesnt look frozen at first
Former-commit-id: 2b5e5cfa4c
2021-06-18 20:21:47 +00:00
christianEQ 4028d35560 Merge remote-tracking branch 'origin/unstable' into diagnostic-tool
Former-commit-id: bfb0d02622
2021-06-18 20:19:31 +00:00
christianEQ 248059e50c detect stagnating server load before 100% (diagnostic tool)
Former-commit-id: 534b70643b
2021-06-18 19:01:51 +00:00
malavan 7cd14168bc add -j to make test
Former-commit-id: 7509875974938f1087ace2437ceb95d8baeeeffa
2021-06-18 17:50:35 +00:00
malavan 502197a3f6 use runner login for clone
Former-commit-id: 64cc31184d3a91386b689870de7d96e423fb58af
2021-06-18 17:15:49 +00:00
christianEQ b21b868de2 added config option for time to spin up new client threads (diagnostic tool)
Former-commit-id: 3d0f729572
2021-06-18 16:58:16 +00:00
christianEQ 29e3f7da84 detect full load + server threads (diagnostic tool)
Former-commit-id: fd4ed1e425
2021-06-18 16:49:25 +00:00
malavan b9967bf64d remove artifacts
Former-commit-id: dd62d85dd101b1f9947af0b335874fd28fee21bc
2021-06-18 16:32:15 +00:00
malavan 3e6075bf72 remove allow_failure
Former-commit-id: 55f62ea9f6ea4c6adefc81ad90a8bd1567406b72
2021-06-18 16:19:11 +00:00
malavan 02d5f09206 force test to run even if build hangs
Former-commit-id: e7a68417ae133402e1f53a6dbbdabbbfc2b3edf7
2021-06-18 16:16:19 +00:00
malavan 7685c3e206 syntax error in last commit
Former-commit-id: 4638526c0e68d9b153a5ea11f8ef83b0ad2f42de
2021-06-18 15:34:18 +00:00
malavan 4e6186d2a9 add src/ as an artifact
Former-commit-id: 315bd739a9db97c4e680212dfd31580828c3fcc6
2021-06-18 15:32:58 +00:00
malavan ec1f6d1156 wrong syntax on last commit
Former-commit-id: 587ed953fa8c6a9ed9faf1c406e813ba79e9b7bf
2021-06-18 15:27:30 +00:00
malavan 056e76d3b5 parallel make, order tests
Former-commit-id: d01afd8324e415b92a292c199703999df1f72457
2021-06-18 15:23:42 +00:00
christianEQ 4237c9d5ff detect client cpu usage in diagnostic tool
Former-commit-id: 693450393c
2021-06-17 20:40:10 +00:00
malavan 6d50656fab uninstall before install
Former-commit-id: f30afe82d799ad680343cdcb7b80e8c257026ff7
2021-06-17 20:38:56 +00:00
malavan 26fba09a41 init git submodule
Former-commit-id: e96906d095fed6b37c9ece79526cfd0a88819e4d
2021-06-17 18:52:36 +00:00
christianEQ fd72894fbf accurate cpu usage in diagnostic tool
Former-commit-id: 8ee7584cff
2021-06-17 18:32:11 +00:00
malavan aa763e9bb1 clean before build
Former-commit-id: 49805ee385381486476d2986cca9e9c3d50d68b5
2021-06-17 18:30:11 +00:00
malavan b70ee319b8 add CI for gitlab
Former-commit-id: 37ba6d28030f4cf1866cc9c182833fe247348f38
2021-06-17 08:44:29 +00:00
VivekSainiEQ 29f4c66179 More code cleanup
Former-commit-id: 8e9962b9b7b9093399451bf93d30e5b5d26e3d33
2021-06-16 19:41:55 +00:00
VivekSainiEQ 90a6fef48b Merge remote-tracking branch 'origin/keydbpro' into repl_backlog_rework
Former-commit-id: e9bfcef5429c747fd9f26a829fed2281c5ec2b25
2021-06-16 16:40:06 +00:00
Ubuntu 6a65b8bbaa Optimized use of repl_lowest_off to reduce lock contention
Former-commit-id: 30a957e5399fe94675f0b6d2d34c24112d5a9734
2021-06-15 23:13:49 +00:00
John Sully 420b07960c Prevent test code crash due to no log data
Former-commit-id: 0a56a73bd9
2021-06-14 22:06:36 +00:00
Ubuntu 80dddab0c4 Relaxed locking, should run faster now
Former-commit-id: 5cec4d026dc1766b9ecbade6ec4b9d0e75a94e0f
2021-06-14 19:30:49 +00:00
John Sully dd8e8b098c active defrag tests need to run single threaded because jemalloc has seperate mempools per thread and the numbers won't match otherwise
Former-commit-id: 3a1d3090f2
2021-06-14 16:32:47 +00:00
christianEQ 9dd97c9c0d changed redis_flags names to keydb in makefile
Former-commit-id: 0727393627
2021-06-14 16:09:42 +00:00
John Sully bdc29a935e Fix deadlock in storage cache
Former-commit-id: e74711e8131cd29a1e0294fbb28e1737ee98afce
2021-06-14 06:32:58 +00:00
John Sully df19692fd8 Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: 975655ab7ff357c2d86d2368899325f88efe5310
2021-06-14 04:07:11 +00:00
John Sully 3ca4e0b4f9 Free objects immediately before adding to the GC list, this cuts down on mem consumption
Former-commit-id: 49d718ae9c1c8a850df5ffa2c550df3381ad7174
2021-06-14 04:06:34 +00:00
John Sully 5898a75788 Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: efea1ce6ca09e09cfe83425c385d0ca1c47514ce
2021-06-14 03:51:09 +00:00
John Sully dcffe221ce Remove lock
Former-commit-id: bb8efe2ed942fd67d091b16bb27f67ccefcbbf19
2021-06-14 03:50:47 +00:00
John Sully e70ed32576 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: 51c8b911b1de88065654eec87b88e1f46cf57e2a
2021-06-14 03:35:25 +00:00
John Sully 562c0ae3de memefficiency tests need to run single threaded as jemalloc has seperate pools for threads
Former-commit-id: 02152c7bd8bc0462edd809122873ceb8644dc69a
2021-06-14 03:34:56 +00:00
John Sully c0d1586f9a Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: 0f1b891c15ac27c4ad8a63a798c7dfa9fdcd2e01
2021-06-14 03:14:15 +00:00
jsully 386f6c649f Merge branch 'merge_6.2.2' into 'keydbpro'
Merge 6.2.2

See merge request keydb-dev/KeyDB-Pro!21

Former-commit-id: c1076b2311e8bc1217b7f5030f5f5ebea1e98215
2021-06-14 03:14:03 +00:00
jsully f3708d35b6 Merge branch 'fixintermittentdoublefree' into 'keydbpro'
Fix issue #23 by adding global locks to FreeMemoryLazyFree

Closes #23

See merge request external-collab/keydb-pro-6!2

Former-commit-id: 2c2d09b123da72483d0b85e41a457ccce13e4fc5
2021-06-14 03:01:03 +00:00
christianEQ 2417c7a593 several redis->keydb changes in sentinel.conf
Former-commit-id: d2ef059471
2021-06-11 19:16:33 +00:00
christianEQ 3ea398ad5e renamed redis mentions in runtest files
Former-commit-id: 2e894a512b
2021-06-11 19:11:12 +00:00
christianEQ e0aafaee37 renamed redis mention in readme
Former-commit-id: 34b0209f05
2021-06-11 19:10:35 +00:00
christianEQ d0a3554de7 renamed workspace gitignore
Former-commit-id: 046f575632
2021-06-11 19:10:12 +00:00
christianEQ c23c7f0ca4 renamed redis test files
Former-commit-id: 1c77104b5e
2021-06-11 19:09:40 +00:00
christianEQ 470c6550e4 removed unreliable musl test and left only accurate new one
Former-commit-id: 386be8990a
2021-06-11 18:19:59 +00:00
christianEQ f3c44c96f2 changed redis.pid to keydb.pid where necessary
Former-commit-id: 76d9c7c82a
2021-06-11 18:19:02 +00:00
christianEQ f48be238b1 removed outdated comment in server.cpp
Former-commit-id: 98f08034a1
2021-06-11 18:17:18 +00:00
christianEQ 1c6219643b updated pkg/deb/conf/keydb.conf to use keydb name throughout
Former-commit-id: 308cf77437
2021-06-11 18:15:50 +00:00
christianEQ 87316cb63c removed the question issue template - doesn't seem necessary for us
Former-commit-id: ce64f469f4
2021-06-11 18:08:19 +00:00
christianEQ 8ee834ea24 fixed flag var names in ci
Former-commit-id: e632c3db1b
2021-06-11 17:04:33 +00:00
christianEQ ea12db4433 don't enforce upper limit for requests issued; tool will run indefinitely
Former-commit-id: 239d22ed72
2021-06-11 16:28:29 +00:00
VivekSainiEQ 15f6acae11 Merged in 6.2.2
Former-commit-id: 3fb9bb5b4fdfb8e09430c7bef6bf9421065adf0f
2021-06-10 20:11:14 +00:00
malavan 5998dc233a add global locks to FreeMemoryLazyFree
Former-commit-id: d850ce20219a3e29a6a816ebfa0d714963d6a88b
2021-06-09 21:49:15 +00:00
VivekSainiEQ 9db8556e91 Cleaned up code a bit, need to rewrite some comments to reflect new behaviour
Former-commit-id: 850ec766cd71614ce9e61c12414545cd212d3878
2021-06-08 23:10:53 +00:00
VivekSainiEQ da0b7a3900 Seems to pass multithreaded test cases, thank the lord
Former-commit-id: 6cbf70cfff5735f3d4ef2e980945b4b1a1f85971
2021-06-04 20:09:47 +00:00
VivekSainiEQ 667d2763c0 Removed unused variables
Former-commit-id: 48663bc480f7279a94c68aeebdd9721ca64f7038
2021-06-03 21:47:33 +00:00
VivekSainiEQ 2e9c7aed03 Single threaded tests work now
Former-commit-id: 0e760d7c71231c7f52102909a31fc8db1b3e2860
2021-06-03 20:44:32 +00:00
John Sully 0f41d34ba2 Fix collab issue #26
Former-commit-id: 2392879772a77fc30c856488b9911d194ced827b
2021-06-03 04:43:38 +00:00
VivekSainiEQ 2a6848a65a Sync works single threaded properly, passes all but one testcase (which hangs)
Former-commit-id: 9a6ca3a5d906b9d87fe70652d218decbb2775ac1
2021-06-02 23:41:36 +00:00
christianEQ 982067b16a fixed code style for ifdef
Former-commit-id: 93c41fa31c91098af98d2bc0362eb29685cd6678
2021-06-02 15:02:27 +00:00
John Sully eef508736d Merge branch 'keydbpro_collab' into multithread_load
Former-commit-id: b580a5561220bc6dc7bc073135f3045ba0cdda51
2021-06-02 04:24:49 +00:00
John Sully eb7c74cf13 Merge branch 'merge_6.2.2' into keydbpro_collab
Former-commit-id: 00f3646df54d25443d8d42c92de60fdeef4fbbe8
2021-06-02 02:12:16 +00:00
John Sully d93360b96b Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: 6eb1417295ecc6ce23677e9a8e1c756579177629
2021-06-02 02:11:29 +00:00
John Sully 368441127f Fix merge issue with wrong return type
Former-commit-id: 1640a2fefb8f09c7b6b335838f14a7fd3a51ae88
2021-06-02 02:10:00 +00:00
John Sully 18a2b27ef9 Merge branch 'unstable' into keydbpro
Former-commit-id: 657789db5c3bd0fbbfc15be150d6eb525554251c
2021-06-02 02:08:18 +00:00
John Sully 833faf96c5 Merge branch 'merge_6.2.2' into keydbpro_collab
Former-commit-id: 54fe037e4e215b1e5bdb42b567c6df04a69ba150
2021-06-02 02:05:44 +00:00
jsully 3859bea711 Merge branch 'fixleakindictdelete' into 'keydbpro'
fix leak caused by dict entry not being added to GCList

See merge request keydb-dev/KeyDB-Pro!20

Former-commit-id: 92c8c6d854c3029269f695d0f9e4afe80c1e48f6
2021-06-02 00:01:52 +00:00
jsully e5197d6801 Merge branch 'jesse/update-readme-build-instructions' into 'PRO_RELEASE_6'
Add additional libraries that need to be installed for building pro

See merge request keydb-dev/KeyDB-Pro!16

Former-commit-id: b18a4f718f40059c30dba6f8ceb2c7612dbcf392
2021-06-02 00:01:33 +00:00
jsully 838150179c Merge branch 'monkey_blocking' into 'keydbpro'
Monkey Improvements

See merge request keydb-dev/KeyDB-Pro!13

Former-commit-id: 130434f01b4bd27c14502b005b5dc71daa6b9cae
2021-06-02 00:01:19 +00:00
John Sully af81622bfc We need to refactor to gurantee the key is visible when loading subexpires. Keys may be temporarily invisible while waiting to be added to the storage
Former-commit-id: 222eecb95925f7c60e28a5717d73163ad64b522b
2021-06-01 23:59:22 +00:00
John Sully f09af75a20 Merge branch 'keydbpro_collab' into multithread_load
Former-commit-id: ffd1225c007e3d1eaecb6b71e215d1e08364aa51
2021-06-01 22:31:52 +00:00
John Sully ef41f96633 Fix lock mismatch
Former-commit-id: 98eb0e778bc3a5ff7da917d39997b2fdb4adbca6
2021-06-01 22:15:35 +00:00
christianEQ 0c41217fba working diag tool prototype
Former-commit-id: fefbe96816
2021-06-01 20:54:48 +00:00
John Sully d0e69e4c47 Reduce lock contention when loading to a storage provider
Former-commit-id: 58bc777f2215918043325753b6e2bf89dc3108f7
2021-06-01 20:01:41 +00:00
John Sully 3675a59496 Merge branch 'keydbpro_collab' into multithread_load
Former-commit-id: 31ddf772cd89344017042a18547ae83a60ce02b9
2021-06-01 19:18:19 +00:00
John Sully b85cbbceee Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: 0f2132505470ca63375f53b54cb6751b604d92f9
2021-06-01 19:17:54 +00:00
John Sully 6e51487f09 Implement bulkInsert for rocksdb
Former-commit-id: e9abae77d6ae18e21d7dac0cbdd563f572ac3d03
2021-06-01 19:17:40 +00:00
John Sully ceb98b062c Initial bulkInsert implementation
Former-commit-id: 2a721d4dff3c9f78ec4ba1c7b490ea1f5d216a89
2021-06-01 19:15:01 +00:00
John Sully 992d515b05 Merge remote-tracking branch 'collab/keydbpro' into multithread_load
Former-commit-id: a09454b3a4b295b2d04bdb7d742db7f9a3e17be7
2021-05-31 01:16:01 +00:00
John Sully 537450bc5d Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: 40187ebd4cc479fa86a3ee5cca9bedef7d488ee7
2021-05-31 01:15:30 +00:00
John Sully 4c88843720 Eliminate unnecessary global locks
Former-commit-id: 8f924ed0979f3cf7cd290395d1b1eec358979325
2021-05-31 01:14:28 +00:00
John Sully 5d525a8830 Fix deadlock in async work queue
Former-commit-id: 3265f2908e8d3aa567b3b9e6b141a7881c795053
2021-05-31 01:14:11 +00:00
John Sully 0bb036aebb Don't pass on flags indicating membership in a list
Former-commit-id: b1f662d639
2021-05-30 05:11:18 +00:00
John Sully 702bfaee9b Merge branch 'unstable' into keydbpro
Former-commit-id: 4fd95b064648ee3d02097a1c2dabf306978b44f9
2021-05-30 04:28:09 +00:00
John Sully 6331caca6a Fix a leak in the benchmark
Former-commit-id: aa5b27b040
2021-05-30 02:55:39 +00:00
John Sully e5691036d9 Fix merge issue with module test script
Former-commit-id: 10d254ec1b
2021-05-30 02:45:06 +00:00
John Sully 42f5d1a175 Ensure our connections are touched only on the right thread
Former-commit-id: e8a44821d0
2021-05-30 02:08:30 +00:00
John Sully 1a734223ca Handle race where a different thread cancels the replication but we haven't closed the connection
Former-commit-id: 92e48f0717
2021-05-30 02:08:02 +00:00
John Sully f1ba462df6 Delete pipe on the right thread so event handlers are cleaned up
Former-commit-id: 9742c44db5
2021-05-30 02:07:31 +00:00
John Sully f82860104e Don't leave dangling client pointers in the process list
Former-commit-id: 5d16f51950
2021-05-30 02:06:47 +00:00
John Sully 06560f9f85 Don't leak AE control pipes to fork children
Former-commit-id: 1ed2e8b5bc
2021-05-30 02:06:20 +00:00
John Sully 4142b86ff8 Fix branding
Former-commit-id: b20803b766
2021-05-29 07:08:01 +00:00
John Sully 71adde26d1 Fix cluster test failures
Former-commit-id: 8cf1daf823
2021-05-29 07:07:54 +00:00
John Sully 989799df85 Merge branch 'unstable' into keydbpro
Former-commit-id: 14c24ce161ddcbddb701a20062659261397cb0e4
2021-05-29 06:49:05 +00:00
John Sully 1b29ba5873 Mac build break fixes
Former-commit-id: 083b54472c
2021-05-28 22:40:03 -04:00
John Sully ef5bf1fdd7 Prevent partial sync in test that requires only full syncs
Former-commit-id: 1b9fea0669
2021-05-29 02:22:20 +00:00
John Sully 4e70e85ab8 Fix failover command test failures
Former-commit-id: d3c37c7159
2021-05-29 01:19:12 +00:00
John Sully f6067d1664 Remove dup'd code from merge
Former-commit-id: 807f020184
2021-05-29 01:08:52 +00:00
John Sully bf77b1a03a ProcessingEventsWhileBlocked is relevant only to the current thread
Former-commit-id: b400be68b7
2021-05-29 01:08:43 +00:00
John Sully 1d0378e0dc Make processClients reentrant
Former-commit-id: e39bdb58ec
2021-05-29 01:08:14 +00:00
John Sully 589e95e0c8 Don't have dangling expires
Former-commit-id: 83c8977033
2021-05-29 01:07:46 +00:00
John Sully cec7f98f34 Use correct make flags
Former-commit-id: 682990eeb3
2021-05-29 01:07:35 +00:00
John Sully 007f276a43 Repair async rehash code removed by merge
Former-commit-id: 14a3ab8133c474bf8f1ad636c8699d5d59c5394e
2021-05-29 00:24:46 +00:00
John Sully f4151f0d6b Merge branch 'unstable' into keydbpro
Former-commit-id: 205d8f18d2bb8df5253bab40578b006b7aa73fd5
2021-05-28 23:32:46 +00:00
VivekSainiEQ bf120245fa Added more synchronization and fixed some data races
Former-commit-id: 183e015dac6f85df1c94d0761e89bc23d9f53319
2021-05-27 18:57:23 +00:00
VivekSainiEQ 6080ee8f2f Added transmitted RDB lock
Former-commit-id: 4b32167afc85742d85ff9b47b2c2e0b6b02e140a
2021-05-26 20:10:33 +00:00
John Sully d414b5ee60 Ensure multi-thread handling of cached master is equivalent to single thread case
Former-commit-id: 7ee766aee1
2021-05-26 17:29:47 +00:00
John Sully c091050d4a Avoid differences between single thread and multi-thread
Former-commit-id: 848c5ad784
2021-05-26 17:29:01 +00:00
malavan 5043fb4091 fix leak caused by dict entry not being added to GCList
Former-commit-id: d8c1b3b6ec64f63fdff04d53102e4563c2c6764a
2021-05-26 17:01:51 +00:00
John Sully b94b46a5ee Eliminate test issue while clients wait for async free
Former-commit-id: a41fb1b036
2021-05-26 01:18:47 +00:00
John Sully 02211afea8 Fix failure sending deferred aggregate lengths to clients on other threads (merge bug)
Former-commit-id: 915117ae7b
2021-05-25 20:51:18 +00:00
John Sully f6de98779f Remove duplicate code
Former-commit-id: de5fa78762
2021-05-25 20:50:40 +00:00
John Sully 84b8e80841 Fix TLS test failure due to tls-port not marked as runtime configurable
Former-commit-id: b0c8efd840
2021-05-25 20:50:23 +00:00
John Sully 9939c0ac5c Fix crash in TLS due to merge
Former-commit-id: 1dcd5edbf9
2021-05-25 18:52:27 +00:00
John Sully 2fa0085988 Build break fix: Remove dependency on future C++ feature
Former-commit-id: 87d7fc8e5d
2021-05-25 18:52:08 +00:00
John Sully f5dc441dff More OS X build breaks
Former-commit-id: 100a747eab
2021-05-25 18:35:45 +00:00
John Sully 9992f14de8 OS X build break fix
Former-commit-id: 105fd03ef8
2021-05-25 18:32:31 +00:00
John Sully f1c3a9ffc8 Fix uninitialized variable
Former-commit-id: 9395a9c1d9
2021-05-25 18:30:07 +00:00
John Sully e8b330f4ff Fix duplicate checks (resolve PR comments)
Former-commit-id: 02f7efd9d4
2021-05-25 16:57:49 +00:00
John Sully 87f706f8e7 Fix TLS Build Errors
Former-commit-id: aea86c5977
2021-05-25 16:55:59 +00:00
VivekSainiEQ 4933615dc1 Initialized serverTL in more places in module.cpp
Former-commit-id: 8d81592bec
2021-05-25 16:55:47 +00:00
VivekSainiEQ 4fd76c4791 Fixed single threaded for real this time, need to add synchronization for multi threaded
Former-commit-id: 4d858dac1a503f4d518477212ba585069af22574
2021-05-21 17:05:55 +00:00
John Sully ea6a0f214b Merge tag '6.2.2' into unstable
Former-commit-id: 93ebb31b17
2021-05-21 05:54:39 +00:00
christianEQ a9552f9635 license status OK if not checking license
Former-commit-id: 6bfdc9d41dc638989d50f005af8d66e4ed47ce77
2021-05-20 19:09:02 +00:00
John Sully f49d8f9adb Merge tag '6.2.1' into unstable
Former-commit-id: bfed57e3e0
2021-05-19 02:59:48 +00:00
Malavan 04fcf3e9b5 Fix issue with INVALID_EXPIRE overlapping with mask
Former-commit-id: a6bbbeffcf
2021-05-17 21:38:42 +00:00
Malavan 7859cbdf59 Merge remote-tracking branch 'upstream/unstable' into fixissue295
Former-commit-id: 9110747194
2021-05-17 21:35:43 +00:00
Malavan 26d1c80398 merge when and whenFull
Former-commit-id: 693b209cb4
2021-05-15 05:48:23 +00:00
Malavan bafd03f53c Speedup keyIsExpired by removing subkey search
Former-commit-id: a01564158e
2021-05-07 09:40:23 +00:00
John Sully 42f98c27e3 Fix test hang
Former-commit-id: 23647390e6
2021-05-07 00:28:10 +00:00
VivekSainiEQ 501a065759 Changed branding in various locations
Former-commit-id: 96bca72bb4
2021-05-06 20:13:45 -04:00
John Sully 442aa5bbd9 Pause execution during rdbLoadProgressCallback as its too risky to let it run
Former-commit-id: e70c01cb3e756d1e02ed190b76c73b7b7010c0d3
2021-05-06 00:42:49 +00:00
John Sully 40fdb3ce05 Add endurance testing to better detect threading bugs
Former-commit-id: 945e428aa110968479fdcdfc2d5c5308a99eadc3
2021-05-06 00:09:07 +00:00
VivekSainiEQ 7ff2fb716a Fixed data race? Seems to be passing multithreaded test cases now
Former-commit-id: cb13edd1200c1230fa7e313d69c69e06129951d3
2021-05-05 22:26:36 +00:00
VivekSainiEQ f6a714db26 Updated overhead calculation to only use repl_backlog_size
Former-commit-id: 6f93c7eb44d84bb143b4ad4fff3c6a5436ebaaf7
2021-05-05 17:04:08 +00:00
VivekSainiEQ eb35d7e9ec Updated maxmemory tests to account for overhead in new replication backlog behaviour
Former-commit-id: 4cd197959693dfe4d1497c3f703cf6aaa27d34ad
2021-05-05 16:37:02 +00:00
Malavan 9a2d6cbad2 add lookup limit to active subkey expire
Former-commit-id: 5d6da23108
2021-05-04 22:28:03 +00:00
Malavan 6312005640 add lookup limit to active subkey expire
Former-commit-id: b44f504ced
2021-05-04 21:34:25 +00:00
John Sully 8e85eaf53e Merge branch 'keydbpro' into keydbpro_collab
Former-commit-id: 446daf8f4c33005096372ad9e29ae9b3d465c64e
2021-05-03 22:58:56 +00:00
jsully de6e9845d2 Merge branch 'cluster_bugfix' into 'keydbpro'
Set repl_down_since in freeClientAsync

See merge request keydb-dev/KeyDB-Pro!12

Former-commit-id: bd7591fe50b1e5565da2fa521438b88058d4da07
2021-05-03 21:41:05 +00:00
christian 3d424defd5 Set repl_down_since in freeClientAsync
Former-commit-id: fb4bd2984651837fadd1dbbbb56327e8452b4a2a
2021-05-03 21:41:04 +00:00
John Sully 0c5585e5de Ensure multithread load works with FLASH storage
Former-commit-id: 24e2991c7aa2cef90a89b1640f7095235c5d34ed
2021-05-03 20:18:45 +00:00
VivekSainiEQ 33a7b52899 Forgot to add server.h in last commit
Former-commit-id: 34fa6119c9a3f1533cc3e6e5d118dc6424a70891
2021-05-03 16:49:09 +00:00
John Sully c58739bbcb Respect replica output buffer limits when adding large commands to the ring buffer
Former-commit-id: 37ec01cfd8a8da1e895c7cdc358d382d35ad59dd
2021-05-03 16:33:16 +00:00
VivekSainiEQ f6305ed15b Now tracks memory and resizes 'accurately', need to fix cluster
Former-commit-id: 5f0e01cc199427ab6dfd7f8f28321f6a1f34fd1c
2021-05-03 16:29:11 +00:00
John Sully eaaff16cca Don't sync too often it hurts perf
Former-commit-id: a20e89a457a0a682483c22f0f1cdb5c93c574d28
2021-05-03 04:15:46 +00:00
John Sully 5583fbb838 Fix remaining test failures
Former-commit-id: 37e607f9b13b6601ff52e74e613fb369cab22b56
2021-05-03 02:37:02 +00:00
John Sully 4677c62428 Fix issue where async load thread misses work
Former-commit-id: a24a7b093295c5f5d69feee9fbc37c64cfa8aa03
2021-04-30 18:48:23 +00:00
John Sully 7352e4a45f Fix majority of test issues with multithread load
Former-commit-id: 4db88176e33e3615ffb90852b49e76b12d5b4622
2021-04-30 18:45:37 +00:00
John Sully 556f394ed9 Initial implementation of multithread load
Former-commit-id: 87b0657c3acd7a3c89964afe1702851b44467c9a
2021-04-30 17:32:54 +00:00
VivekSainiEQ 7ef58a333f Performance optimizations
Former-commit-id: 7fd83d467784d293f7da78b74f9b9763ce387238
2021-04-29 18:51:30 +00:00
VivekSainiEQ d8367a92b2 Updated resize logic
Former-commit-id: e6d892ef21b7fc6f51433f32b01198038e555419
2021-04-29 17:01:06 +00:00
benschermel f8ddcf1e8e update README with community slack info
Former-commit-id: 6163e7b13a
2021-04-29 03:11:54 +00:00
christianEQ 861e54942f fixed diagnostic tool to use correct obj files
Former-commit-id: 66547bd28a
2021-04-28 16:02:44 +00:00
christianEQ d1330899a8 updated makefile vars to keydb names
Former-commit-id: e6ab823473
2021-04-27 21:14:05 +00:00
christianEQ 0bf752a543 added keydb-diagnostic-tool binary (copy of benchmark)
Former-commit-id: a2c0bce4cc
2021-04-27 20:56:37 +00:00
VivekSainiEQ 05fe41b33a Primitive implementation of bypassing client buffer, stats are all messed up and print statements everywhere
Former-commit-id: 8ae310fb0f7b53add826f76891da333b63860001
2021-04-26 22:13:32 +00:00
John Sully 95ae92a691 Optimize freeMemory by lazy freeing objects
Former-commit-id: cca31ed5ee2f42975f0051cfabf1e88720b3d678
2021-04-21 01:20:13 +00:00
John Sully 3966f84862 Better RocksDB perf tuning
Former-commit-id: cbe1e0a7c1b5dc49c1adff07b7c32042e673acf4
2021-04-21 01:19:44 +00:00
John Sully 6e546b3c44 Fix issue where we reply a dangling pointer
Former-commit-id: fd11e490c39fe876d979eace5eaec56c645cdfcf
2021-04-21 01:19:29 +00:00
John Sully 9c1cf39b70 _dictExpandIfNeeded is called too late to be useful
Former-commit-id: 7f75ca5d3a9ed47465bceb22f5f74fd6f0760008
2021-04-21 01:18:38 +00:00
John Sully 7f68765981 Allow prefetch even with a single thread
Former-commit-id: 2e68821b330a6bae8a352e37c3da643d504b2ce3
2021-04-12 04:44:52 +00:00
John Sully 92028ddb5c Avoid posting unnecessary async tasks
Former-commit-id: 1661d2a05943f96992be195f5dc32dd9a67c0e68
2021-04-12 03:44:29 +00:00
John Sully 2eb3710039 Fix issue where GC is not free'd until a BGSAVE
Former-commit-id: 38523e6b508cf5f4b40c178dfe98554abea8f6bd
2021-04-12 03:44:15 +00:00
John Sully 2c8540c4fd Make prefetch more aggressive
Former-commit-id: 25a5cfefcf7fa3451e92500f5d310290c4b6bbde
2021-04-12 03:42:05 +00:00
John Sully 5793bb0c34 Don't prefetch when lock contention is low, it increases latency
Former-commit-id: 0d21614e0e5aba28acd364231823d51a3073081f
2021-04-12 03:41:53 +00:00
John Sully 3ed9963363 Reduce P99 latency with async rehash
Former-commit-id: 7ea4c26fd82c0cdfa377183083f38a43336e480b
2021-04-12 03:39:13 +00:00
John Sully aa64a260fc Make prefetch configurable
Former-commit-id: 3b660347d70cc25d57119080bd43fb4671e36488
2021-04-12 03:38:57 +00:00
John Sully da545be5b5 Make prefetch more aggressive
Former-commit-id: 9cb0be197fb96d7fb3cb697c19b5be313b01337a
2021-04-12 03:24:05 +00:00
John Sully 5ccaa9265c Don't prefetch when lock contention is low, it increases latency
Former-commit-id: 9b2629f6a20368cec8e55f0d006f3a67c8b770b7
2021-04-12 03:23:49 +00:00
John Sully 2d2ae90f30 Reduce P99 latency with async rehash
Former-commit-id: 6c045837c7cf92dc92be35465229b482e09e46d2
2021-04-12 03:22:22 +00:00
John Sully c92b90eb91 DO not set the timethread as high priority, it can starve the server threads
Former-commit-id: faeac65371af9d6b6effe0886bcbdefaec24ad6d
2021-04-09 01:06:24 +00:00
John Sully e1adedb1fa DO not set the timethread as high priority, it can starve the server threads
Former-commit-id: 5355207a0ad3f1a191fa06450490c792caa76e87
2021-04-09 01:05:55 +00:00
John Sully 69f7a194bc Make prefetch configurable
Former-commit-id: 16996c048042bd3799c8051645bbe7c54137d54c
2021-04-08 19:52:38 +00:00
John Sully 571718f774 Avoid posting unnecessary async tasks
Former-commit-id: 08f63fdfd6c78388bba093ec2edda7d77fc9173e
2021-04-07 17:41:20 +00:00
John Sully 635ddad7fc Fix issue where GC is not free'd until a BGSAVE
Former-commit-id: e19350005b571591876e49219bfca75e905604a5
2021-04-07 17:30:59 +00:00
John Sully 55a118ecd0 Reduce connection latency for cluster clients
Former-commit-id: f1acee99bdaee4faf9e18cdf4734d51a73e78a41
2021-04-07 15:49:58 +00:00
John Sully eb818d4c00 Fix build break from merge conflicts
Former-commit-id: 5052388bd43b0e42430fd741fb2b403544684246
2021-04-07 15:25:22 +00:00
John Sully ca13d87204 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/external-collab/keydb-pro-6 into keydbpro_collab
Former-commit-id: e077756b140855cb5a7e60567abf845dbfbc162d
2021-04-07 15:14:59 +00:00
jsully c168c8fbbf Merge branch 'flash_read_perf' into 'keydbpro'
Flash read perf

See merge request external-collab/keydb-pro-6!1

Former-commit-id: f6d7277f307b78f079dd99bf532cd26a7b62018d
2021-04-07 06:12:55 +00:00
Cloud User 6601905d8c Make high pri time thread configurable
Former-commit-id: 7e94207765d2166f46792aea0919786f3f30d7b3
2021-04-06 22:39:20 +00:00
christianEQ ec11cc177e check for musl in logging.tcl as backtrace() is not available with it
Former-commit-id: 2c8239f9cb
2021-04-05 11:09:49 -04:00
John Sully 6b2567298d Don't ensure if we don't have to
Former-commit-id: b7b678a3ada531890e67313c867b7b49b01fe41e
2021-04-01 18:17:05 +00:00
jsully 7b61c83b3e Merge branch 'keydbpro' into 'flash_read_perf'
# Conflicts:
#   src/db.cpp
#   src/networking.cpp

Former-commit-id: e16c846b2b9e70f20981172287b19e585f81d73d
2021-04-01 17:25:31 +00:00
John Sully e5d5b41be1 Fix issue #300
Former-commit-id: 22d0bca3a51bef7d42264b518b1c470df51fdc5e
2021-03-30 23:45:07 +00:00
John Sully 40fdf5670c Fix issue #300
Former-commit-id: bee7f398c9c3b4c01b687d26194913bf215dca36
2021-03-30 23:44:34 +00:00
John Sully 577ba39c70 Fix issue #300
Former-commit-id: e9551c9e8d
2021-03-30 23:30:41 +00:00
John Sully ad8a706d4a Fix issue #300
Former-commit-id: bf5b2d78d9
2021-03-30 23:30:17 +00:00
John Sully 0b6a66ca55 Fix crash in RDB save
Former-commit-id: b032809b3e978fe571b791179d32ecdc9c067045
2021-03-30 20:49:33 +00:00
John Sully e943b60a39 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: c4eefb1345209790e31b41401d1870473a401676
2021-03-30 20:44:36 +00:00
John Sully 123d7ad148 Fix crash in RDB save
Former-commit-id: ef1e122fcb039d25f60752ca27c9feb5e8cfbb31
2021-03-30 20:44:22 +00:00
jsully 842c8dd3c9 Merge branch 'jesse/update-readme-build-instructions-default-branch' into 'keydbpro'
Add additional libraries that need to be installed for building pro

See merge request keydb-dev/KeyDB-Pro!17

Former-commit-id: d42c70048d4e4b7dd0ecc802742ff45f7c959b1c
2021-03-30 20:20:45 +00:00
Jesse 749fd784f5 Add additional libraries that need to be installed for building pro
Former-commit-id: 303a0646b5510e310dfd03c7288d747f76ce3d62
2021-03-30 13:14:03 -07:00
Jesse 13cb94c169 Add additional libraries that need to be installed for building pro
Former-commit-id: 506d4229c46598330ed39d837196d790bf4867cb
2021-03-30 13:12:23 -07:00
Hanif Ariffin 4b204b6776 Fix typo in error string
Former-commit-id: 0ac80086bc
2021-03-30 13:52:47 -04:00
VivekSainiEQ 239bb9cf65 Added logic back to only acquire/release GIL if modules are enabled, without causing deadlocks
Former-commit-id: 9ab36ddc36
2021-03-30 13:46:03 -04:00
VivekSainiEQ 662d5faa8b now acquire and release GIL every time you go to/wake from sleep
Former-commit-id: a6bc34c09b
2021-03-30 13:46:03 -04:00
VivekSainiEQ cb43eda420 Created and initialized seperate thread variables for modules
Former-commit-id: 3bb6b16c4a
2021-03-30 13:46:03 -04:00
VivekSainiEQ 3f9f4f6bff Readded getkeys to module build
Former-commit-id: 1cde2442aa
2021-03-30 13:46:03 -04:00
John Sully c0d7601aa4 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 2910cee32b
2021-03-29 00:49:34 +00:00
John Sully 3027a4cbb4 Enable LTO
Former-commit-id: a6edb104b7142b8e76048e0534e342048ade08d6
2021-03-29 00:47:50 +00:00
John Sully e15f035bfb Prevent unnecessary copies in replication scenarios
Former-commit-id: b152a9bd88c081ce98eebe9a7af49649e60e5523
2021-03-28 22:43:15 +00:00
John Sully 999dba6619 Make some asserts debug only for perf
Former-commit-id: dc66209f2cf8eadb794dad302bd1ea92890e75b0
2021-03-28 21:08:48 +00:00
John Sully 22b1ac1e8d Excessive rehashing adds latency
Former-commit-id: ee5a4528d61420a18f89a07f4ac63e2181a19738
2021-03-28 20:22:01 +00:00
John Sully 33197a128d Fix thread safety issues with the cache prefetch logic
Former-commit-id: 4892122fc02109d98684a350bd732a0b08a8c7b4
2021-03-28 20:21:44 +00:00
John Sully afeb4db219 Prefetch keys even in pure RAM scenarios
Former-commit-id: d7219de186d60a5a437c1828ac97117eaad34819
2021-03-28 20:21:31 +00:00
John Sully 39f4615893 Eliminate unnecessary lookup in ensure when there is no snapshot
Former-commit-id: 1f363ed7c13c186f0c120ab4f3e321144667f50f
2021-03-28 20:19:15 +00:00
John Sully aa8800abaf Enable LTO
Former-commit-id: 3ec75184bae92c0e7af579eda8cbe6cfa2375327
2021-03-28 20:13:54 +00:00
John Sully 8377da61ed Enable LTO
Former-commit-id: 7241bfc25525e8b27193fb0d4f9eae2e5e98e8d6
2021-03-28 18:27:14 +00:00
John Sully 6cf736535d Make some asserts debug only for perf
Former-commit-id: c22740df4f7c1468fbe19fd97dfaec20e011b6f1
2021-03-28 18:27:00 +00:00
John Sully b8c03fd014 Excessive rehashing adds latency
Former-commit-id: 9db2277b0fea032abcde089f617fe7e4f5ce12e3
2021-03-28 17:59:02 +00:00
John Sully 74d73b4ca3 Fix thread safety issues with the cache prefetch logic
Former-commit-id: a80a128bb64b81115c095d6dd91896ff73048b3d
2021-03-28 17:58:43 +00:00
benschermel 8130a7fa59 bump version
Former-commit-id: f660cd9357
2021-03-27 18:30:52 +00:00
benschermel 2f80810544 bump version
Former-commit-id: 33b75e0a2cf8712c976e7af74e2a615bb991c356
2021-03-27 18:26:11 +00:00
John Sully 0d69b7684e Prefetch keys even in pure RAM scenarios
Former-commit-id: 54c0f11db0b35f34c9dfc3c8b4b76b7b7921bacd
2021-03-26 23:48:24 +00:00
John Sully a66295ed98 Eliminate unnecessary lookup in ensure when there is no snapshot
Former-commit-id: 04540531b95ebadf6d60c90c6681c11060eaf907
2021-03-26 23:44:42 +00:00
benschermel 9a8d93708a bump version
Former-commit-id: 4272a7de24
2021-03-26 22:57:19 +00:00
benschermel 2abff4220c update rpm script for centos8
Former-commit-id: f52815d309
2021-03-26 22:55:12 +00:00
John Sully 83e8e613a2 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 7e0bcf58224921abf2046dc1f58606ed18ebb379
2021-03-26 02:54:50 +00:00
John Sully 352bde8d89 Fix issue where timethread wakes too slowly
Former-commit-id: 60f875f5eb7cb541e537f0f440ce8d5aeac57862
2021-03-26 02:54:33 +00:00
John Sully d9848fc0dd Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: c180de1c6d3ef25877ec3b4c50698624dfd3320d
2021-03-26 02:36:27 +00:00
jsully ace6ad4752 Merge branch 'timethread_idle' into 'keydbpro'
Sleep the time thread when server sleeps

See merge request keydb-dev/KeyDB-Pro!15

Former-commit-id: 0864c46e38f85f03ea69a18162e3797370c17c91
2021-03-26 02:36:01 +00:00
John Sully 8ec77ffbf2 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 20d2c4fd62bb1867b8970b2bb282bd2ed64bcf6e
2021-03-26 01:50:51 +00:00
John Sully 111bdabbae Fix bug where we skip valid dict elements in dictGetRandomKey
Former-commit-id: c25a9a3b84c967428b3598c99a65b14ed2417571
2021-03-26 01:18:39 +00:00
John Sully dbe8a10fbf Prevent unnecessary copies in replication scenarios
Former-commit-id: 84c671cdafae7e84beef722fcc8a90b92918c89d
2021-03-25 23:14:48 +00:00
christianEQ 13697db121 moved time thread code to end of beforeSleep
Former-commit-id: ac1022c772c7357571829f24c87aa3dc2deade72
2021-03-24 21:16:21 +00:00
christianEQ fa44f2650e serverAsserts on sleeping_threads, remove bare locks
Former-commit-id: 8c64ca2333d8eb2ee92d835907474ec63e127b62
2021-03-24 20:44:40 +00:00
christianEQ 6d1be2a3f5 counter for time thread sleeping threads
Former-commit-id: 6270939d6a2d7820fecac9c5aedf0ff985531f6b
2021-03-24 20:33:26 +00:00
John Sully 131a8c9e35 Fix bug where we skip valid dict elements in dictGetRandomKey
Former-commit-id: 626b56b00824573660af0c47b210fd1e8d2cfeb2
2021-03-24 20:26:33 +00:00
christianEQ 22cffc5d54 removed extraneous wakeTimeThread cal
Former-commit-id: cfb5c5d7dc1e09c51ca416a2dbb19eab4bbaa77a
2021-03-24 20:24:07 +00:00
John Sully 54fb01e24a Don't run code in evict unless we really have to
Former-commit-id: b665b1c2b2df96883a6e2237f7bf3f9b1bec2a89
2021-03-24 20:13:42 +00:00
John Sully fa244c930e Bump RocksDB version for better perf
Former-commit-id: ab4ae61b9c54b3c28dc5fd775d0df3d377c4846a
2021-03-24 20:12:43 +00:00
John Sully 18da2dd091 Fix bug where we skip valid dict elements in dictGetRandomKey
Former-commit-id: 291a3610a679cb1d17caadf6ab067cad41885935
2021-03-24 19:58:51 +00:00
christianEQ 28895d72fe added condition variable to time thread; wake on afterSleep, sleep on beforeSleep
Former-commit-id: ff2f2a3aceff2ba4a74951197348d67fc39568b2
2021-03-24 19:27:39 +00:00
John Sully 0ce53d6ce1 Disable assert
Former-commit-id: b5d5eeee7cb1900eba192704e5d68c90b9f2b9f2
2021-03-23 23:50:48 +00:00
benschermel 6b18ab6ab4 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 99021efc9d4b59a93328e6f85db8b29010b3b0b1
2021-03-23 21:29:16 +00:00
christian d841598ea0 Merge branch 'rebrand' into 'keydbpro'
Rebrand

See merge request keydb-dev/KeyDB-Pro!14

Former-commit-id: 6840087819f26804302635dd0a75de523e133f8c
2021-03-23 20:01:05 +00:00
benschermel efa9d4ef98 addressing comments from merge review
Former-commit-id: 955aa69ca16ca7230d5099ad16f6f825402b5dd5
2021-03-23 18:41:59 +00:00
John Sully c6fc1bcfe3 Perform GET command inline
Former-commit-id: 5623936d99e334ab103f3dc1541b145c125d0ee8
2021-03-23 03:44:20 +00:00
benschermel 5c145039d4 update enterprise wording for keydb.config lk
Former-commit-id: feb2d31e6544763c94f4abaea69bc98bd1cb8b17
2021-03-21 05:19:28 +00:00
VivekSainiEQ 50884c6a20 Updated jemalloc to version 5.2.1
Former-commit-id: 7fefc7b245
2021-03-19 20:10:27 +00:00
VivekSainiEQ f4dbaab531 Removed hasModuleGIL boolean and added fix from PR #292
Former-commit-id: 68d213f4c9
2021-03-19 20:10:24 +00:00
VivekSainiEQ 932fd2e79a added lock releasing w/ hasModuleGIL, changed module serverTL, and moved module_blocking_pipe to global scope to fix issue #276
Former-commit-id: 7d9a2ce827
2021-03-19 20:08:28 +00:00
benschermel 2fd3097269 update rpm script for centos8
Former-commit-id: c6ef287452
2021-03-18 19:31:54 +00:00
benschermel 2cddb1f6e9 bump version
Former-commit-id: d5b042f010395628734848fc0b7db370fa9106c4
2021-03-18 02:11:19 +00:00
benschermel 20de526037 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: c03c45a1a1bf3c92a75804e123e34ea394adad07
2021-03-18 02:01:15 +00:00
benschermel 2e5ecd9003 minor fixes
Former-commit-id: ad7a27d41fb9e8e47966bbee72b28a4be66bbd8f
2021-03-18 01:16:57 +00:00
christianEQ 0436e62b7a fix old reference to c variable (monkey)
Former-commit-id: 0b9b6413c70d4ba71bbabcd0b22fb004d804958f
2021-03-17 20:22:01 +00:00
christianEQ 4944836478 removed unused stuff from monkey
Former-commit-id: be55daa6f7bcbf137b37269d1ee7a5fcacc14ff0
2021-03-17 20:17:52 +00:00
christianEQ 34d019f483 fixed runtime arg for monkey
Former-commit-id: b3e6e1f13b3d24c92d9f7e8441831232f47ff053
2021-03-17 19:50:28 +00:00
christianEQ ca97f6e454 working blpop test in monkey
Former-commit-id: 21af13c2a38741ad9e036fad42b23ea2454ac33c
2021-03-17 16:10:06 +00:00
christianEQ a2d8079d49 track each command separately in monkey
Former-commit-id: e3accdaad985fd9f93490a5cc6704d9ecb909604
2021-03-17 16:03:51 +00:00
benschermel 2c6d5c991f fix rpm script for centos8
Former-commit-id: 6790d9b793b1995b2faae7dbfb5d09dce90a878c
2021-03-17 05:11:01 +00:00
benschermel d1bfe49bc2 update all packaging to support enterprise dist
Former-commit-id: 1fd4f27cd271090fc66dba3b09a3800bf1c33b0e
2021-03-17 02:30:34 +00:00
christianEQ 6119273c5e unblocking test to monkey, works with 1 client
Former-commit-id: 9fbe8cf6a8aeb141d4a502532a456e4256f4daf8
2021-03-17 01:40:38 +00:00
christianEQ a93234accc parameterized monkey options
Former-commit-id: eda1055689587c25dca3e889dd3a74d3f9c9378f
2021-03-16 23:19:29 +00:00
John Sully 44603c8227 Make async rehash behave with snapshots (thread safety issues)
Former-commit-id: 372adf39a80252b8035e3c948fcaf7d5ef6f928f
2021-03-16 02:38:41 +00:00
John Sully 61d548079c Remove snapshot consolidation because its not properly thread safe
Former-commit-id: dcb86d2b92e3ecdb9f914b6f5de9e184cdd23036
2021-03-16 02:37:49 +00:00
John Sully 15e1ee620f Fix TSAN errors in tests
Former-commit-id: 30207d2ab34f175b94f430f97581191343d23f1e
2021-03-16 02:29:24 +00:00
benschermel e40fe53395 re-label keydb-pro-server to keydb-server
Former-commit-id: eb6f61ad372f0f4e573b9b731eac6c7f2ada0d9f
2021-03-16 01:57:26 +00:00
John Sully dc658ba47b Support deletes in the monkey
Former-commit-id: 84101aaa1bd0c89fbaffc11a264788cd75458c48
2021-03-15 19:41:38 +00:00
John Sully ada1f2a527 Add the monkey script to enhance testing
Former-commit-id: 57ce7b9e9976ca6827415d756ea3cabef1a0d615
2021-03-15 15:32:43 +00:00
John Sully 319b4039af We can't swap databases if there are async rehashes
Former-commit-id: 4b8967f94667309c5585032db7403bf4c8885145
2021-03-15 05:46:52 +00:00
John Sully d7f3f2b4e5 Enable more asserts to better validate snapshots
Former-commit-id: 01113e2eec3a0dbe0d07f98289a0050df7713047
2021-03-14 23:40:41 +00:00
John Sully 7197ba2fe5 Fix incorrect memory order on refcounted strings
Former-commit-id: fcf3368b1d56ad7a11e510e5a66e415a46277e8b
2021-03-14 19:42:56 +00:00
John Sully 5bd11ae0eb Avoid queuing null pointers to be freed
Former-commit-id: f50541d437cd1d98139c29407bb3fb4d6ce17fca
2021-03-14 03:22:10 +00:00
John Sully 767efb2519 Ensure the hash is passed through when moving tombstones
Former-commit-id: 91c8d2d38a33175c64c987b75e94c4b8782a3cdc
2021-03-14 03:21:09 +00:00
John Sully bb96b066e2 Reduce log spam
Former-commit-id: a5ba7bdde5435ad5b7cf066e0b45f6df1f784808
2021-03-14 03:19:41 +00:00
John Sully 650fa335eb Remove rarely used bug-prone code paths from tricky snapshot code
Former-commit-id: dff84228afb97962d77caefe948154090dd5ce23
2021-03-14 03:19:04 +00:00
John Sully 6bf6956c30 Add checked build support to makefile
Former-commit-id: 7e27c371679d780137a5d39b03b9472651ddf686
2021-03-14 03:18:24 +00:00
John Sully d2c9ce84df bump version
Former-commit-id: c802ea93a167ff6c59e585d4ab72c9f7b6b03a1c
2021-03-10 04:03:56 +00:00
John Sully ff3c13a938 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 066f984e5223f58b239d99c115901ea9845da513
2021-03-10 04:03:13 +00:00
John Sully bf81e55547 If we're clearing the command queue we need to reset the parse length
Former-commit-id: 19068f990a77fb428a50a8f751ed6f8cf59a8a74
2021-03-10 02:53:52 +00:00
John Sully 7636676988 When we add a delay to rdb save for test purposes we still need to check for aborts
Former-commit-id: b057b4d05aae6c08b855bfc9ae48d41ad0e881f8
2021-03-10 02:53:15 +00:00
John Sully a2c2337cd9 Fix failed merge due to overwriting the hashidx and pretending no rehash is in progress
Former-commit-id: 0524b822a05b732e0f3e510dcaeb3304069d3595
2021-03-10 02:52:22 +00:00
John Sully 50060b4a13 Fix crash saving an RDB
Former-commit-id: 51c35f03a84f7ada0f150a1c3992df574ab89b95
2021-03-05 00:54:11 +00:00
VivekSainiEQ 883fba7f04 Updated module tests to default to multithreaded and added tests for RM_CreateTimer while loading .rdb
Former-commit-id: e6091a2b7e
2021-03-04 23:33:01 +00:00
John Sully 902264efb7 Load perf fixes with a storage provider set
Former-commit-id: 861b19de00c75c9167cc25031292284ad1c21893
2021-03-04 07:41:06 +00:00
John Sully 50ce24a10c Fix compile warnings
Former-commit-id: c314cab888e9c8b3e825b2dfe0c0392ee998bdc4
2021-03-03 22:12:51 +00:00
jsully ba5b7a6da1 Merge branch 'time_thread_priority' into 'keydbpro'
time thread priority + nanosleep

See merge request keydb-dev/KeyDB-Pro!11

Former-commit-id: 423b76a2bbbd568f525f6469ce829ab053972536
2021-03-03 18:55:07 +00:00
John Sully 08b9f21d71 Data loss issue due to async rehash interfering with snapshots
Former-commit-id: 5245ca9a67c74b34139cafc9754543d1b8bed90a
2021-03-03 07:06:19 +00:00
John Sully ea6ba8370d In low load async rehash may not complete in time, do it in the cron
Former-commit-id: 0a27d30753d887b6251e645abe26118068c55587
2021-03-03 07:05:51 +00:00
John Sully 4066ce8f3a Don't let dictionaries shrink too rapidly. It can cause massive perf issues while in the shrink rehash
Former-commit-id: a7ad346e4f03c85d22a29c8268d35471e86283aa
2021-03-03 07:05:12 +00:00
John Sully 76698beeaf Drastically improve perf when loading an RDB with a storage provider
Former-commit-id: 0133b42d54676e8fac2c5cb006cc87988dced268
2021-03-02 04:16:20 +00:00
John Sully 6065f276c4 Key prefetch error handling instead of crashign
Former-commit-id: b322a14efb1b897134b229c1726b45264b57783f
2021-03-02 01:38:12 +00:00
VivekSainiEQ d855afdcac Fixed bug where make USE_SYSTEMD=yes would not pass in correct flags, issue #226
Former-commit-id: 69dc0a06bf
2021-03-01 21:31:33 +00:00
John Sully eabfae81b3 Bump version
Former-commit-id: 31392562b27a6fc1576476626a27a3defe13795f
2021-02-28 21:02:25 +00:00
John Sully 0cba72ba14 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 7609673e282b46a760a3d0e0b42d685af9b4d056
2021-02-28 20:46:08 +00:00
christianEQ 175b266c34 time thread priority + nanosleep
Former-commit-id: c84f296edabc001a1836ab8437f746dcff811148
2021-02-26 20:17:34 +00:00
John Sully 877ad1e4b2 Don't complain about unclean shutdowns with an empty database
Former-commit-id: 99f5c02e87062552eaa2f26e960eb7c9dd977c84
2021-02-26 06:06:58 +00:00
John Sully bbb310f419 Eliminate needless lock
Former-commit-id: 60f972d463f202edb33ff9a25bc2bd3e2558105c
2021-02-26 05:40:56 +00:00
John Sully 6ee9d69763 Eliminate the need for an mfence by tricking the CPU into ordering the futex read
Former-commit-id: 340e6f5bc94cd1c3b0c6fb6da833e8504acaf23a
2021-02-26 01:28:05 +00:00
John Sully 4f632962c1 eliminate syscall in call()
Former-commit-id: 3ee111a2e50bc29818ba85ae4fb786171d695c37
2021-02-26 01:03:10 +00:00
jsully 1459d88a6d Merge branch 'timethread' into 'keydbpro'
Offload updating cached time to dedicated thread

See merge request keydb-dev/KeyDB-Pro!10

Former-commit-id: 31786a995d0220ec0cb4502917a8cc0f192da4cb
2021-02-26 00:50:22 +00:00
christian 53b7b83af6 Offload updating cached time to dedicated thread
Former-commit-id: 9bfc8a43952481b5b54a7b051d44b8bece4a18dd
2021-02-26 00:50:22 +00:00
John Sully ca13fda90f Fix issue where finding random keys is slow due to not shrinking the hash table.
Former-commit-id: fd05010cdcf9d6a6187ca2e18bc55adbaa680a02
2021-02-22 09:14:24 +00:00
John Sully 87fc018415 Implement maxstorage config
Former-commit-id: 79e07859dfec14edf2a39646013e1a82db033d4f
2021-02-19 05:17:41 +00:00
John Sully 3ac42ec80c Disable async rehash with single threads, it causes slowdowns as the rehash never completes
Former-commit-id: 5d08dbdf76c0fd1e0cfcf86b97ef3e656f0e4f5d
2021-02-16 21:07:43 +00:00
John Sully c43bb8e8b5 Fix deadlock in storage prefetch
Former-commit-id: 9e6162de08248f7726b97b73aee2f23808ff4e7b
2021-02-12 19:38:57 +00:00
John Sully ef471e6e53 Enable prefetch with storage providers
Former-commit-id: 21f9c52c446ad1b460a340c3d873839b2355728f
2021-02-11 00:50:21 +00:00
John Sully fdfbd8cc91 Fix polarity issue in async rehash
Former-commit-id: dfea168499
2021-02-09 05:10:22 +00:00
John Sully e5e1350219 Fix polarity issue in async rehash
Former-commit-id: 9eefba49d4fcde7f12929929d7aeb36f5186a63d
2021-02-09 02:41:44 +00:00
John Sully 3de15c16ac Fix deadlock with disconnecting client and storage provider
Former-commit-id: 0831745323e425f463322e8c0dc27fc25854868e
2021-02-08 19:02:01 +00:00
John Sully 078abba316 Merge branch 'unstable' into keydbpro
Former-commit-id: e2140793f2bf565972ada799af73bf4457e2718d
2021-02-08 18:17:09 +00:00
John Sully 4efab08466 Fix bug in fastlock stack metadata
Former-commit-id: 241d1bd7e1
2021-02-07 19:11:05 -05:00
John Sully 662fc28fdc Disable multithreaded rehash when active defrag is enabled. The two are not compatible
Former-commit-id: 56addcd172
2021-02-07 19:11:05 -05:00
John Sully 1b3dc3d422 The server should recalibrate periodically. Also reduce log noise
Former-commit-id: 8d8e1810d4
2021-02-07 19:11:05 -05:00
John Sully 27552cb307 Ensure the C lock implementation behaves the same as the ASM
Former-commit-id: b5ddc11c46
2021-02-07 19:11:05 -05:00
John Sully ba006abe02 Ensure rehash completes even when we're in a long running task
Former-commit-id: f107746e90
2021-02-07 19:11:05 -05:00
John Sully 495dff1e8c Implement rehash during spinlock
Former-commit-id: f68a26381a
2021-02-07 19:11:05 -05:00
John Sully 071ecb801a Allow multiple threads to rehash simultaneously
Former-commit-id: 5a2cc90786
2021-02-07 19:11:05 -05:00
John Sully 6379ae6c7f Fix races in free
Former-commit-id: 3881d5c1f2
2021-02-07 19:11:05 -05:00
John Sully 1c0b603def Initial implementation
Former-commit-id: 958f2c00c8
2021-02-07 19:11:05 -05:00
John Sully 5c884b6fd8 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 4a269c3382083f6ad7f697ef07eebc552e0de9d8
2021-02-08 00:02:54 +00:00
John Sully f4c7da7284 Merge branch 'unstable' into RELEASE_6
Former-commit-id: 0b7b5332f2
2021-02-07 23:55:58 +00:00
John Sully aa47e643b0 Fix memory leak in mvccRestore
Former-commit-id: 165333b0fc
2021-02-07 23:38:49 +00:00
John Sully e2f634aef5 Fix cluster test failure
Former-commit-id: 230fde39882766426d892fd30d0c8349f5cca912
2021-02-07 23:38:25 +00:00
John Sully 6a7b193fc1 Fix memory leak in mvccRestore
Former-commit-id: 92da1cbd0a08b66264f170a9b57ef7270f270157
2021-02-07 23:38:09 +00:00
John Sully 52c1d17127 Update test to handle forkless bgsave
Former-commit-id: fc8c6de8252e6b802688413050f1a823093d0a1d
2021-02-07 21:41:19 +00:00
John Sully b20ab1fd21 Merge branch 'keydbpro' of https://gitlab.eqalpha.com/keydb-dev/KeyDB-Pro into keydbpro
Former-commit-id: 8bad923169b2a73f249fd8b3153236d6a74100c9
2021-02-07 20:53:07 +00:00
jsully 1c0c0ebd3f Merge branch 'opensourcemerge_2021-02-01' into 'keydbpro'
Merge from open source Feb 5 2021

See merge request keydb-dev/KeyDB-Pro!9

Former-commit-id: 1a2e2b99cc0123b1b03b78b5f28107df395decdb
2021-02-07 20:49:08 +00:00
christianEQ fc83515309 fixed up backup stuff
Former-commit-id: 8a23162c24dc13a4268928c5defd85b0b5249d39
2021-02-04 22:36:32 +00:00
christianEQ ed2a86c98f removed bgsave test, not applicable to keydb pro
Former-commit-id: d017c160662702ebcdbf063df239b907c2a193c5
2021-02-03 19:13:53 +00:00
christianEQ c69b2845fd Merge remote-tracking branch 'opensource/unstable' into keydbpro
Former-commit-id: 5bad058733de2c217340bb9ee48f02b07d754808
2021-02-03 18:10:27 +00:00
John Sully 651abfdca0 Module test reliability
Former-commit-id: cc827e157a
2021-02-01 22:21:49 +00:00
John Sully cb5119b756 Simplify the handling of CreateTimer
Former-commit-id: 7b4e25008a
2021-02-01 15:51:22 -05:00
VivekSainiEQ b0f94bd4b5 Modified RM_CreateTimer to prevent more that one function being posted at a time
Former-commit-id: f66e5a9c3d
2021-02-01 15:51:22 -05:00
VivekSainiEQ cf122aa54d Changed RM_CreateTimer to only call aePostFunction is existing aePostFunction isn't in flight
Former-commit-id: 9954f5b4a4
2021-02-01 15:51:22 -05:00
VivekSainiEQ 84dc6401c7 Now post entire timer installation process as one function to make atomic with respect to global locks
Former-commit-id: 53936661c8
2021-02-01 15:51:22 -05:00
VivekSainiEQ 49132539dd Updated header file to remove fSynchronous flag
Former-commit-id: e2552ff8a9
2021-02-01 15:51:22 -05:00
VivekSainiEQ 662037e3a3 Removed more uses of fSynchronous and the use of condition variable and mutex on the control struct.
Former-commit-id: 6ab08cc3e1
2021-02-01 15:51:22 -05:00
VivekSainiEQ 2addbe7e4a Added fix for scenario where module thread waiting for s_mutexModule in acquireGIL can deadlock with module thread waiting for s_mutex in releaseGIL
Former-commit-id: 3205373bb3
2021-02-01 15:51:22 -05:00
VivekSainiEQ dd0b8af2c5 removed synchronous calls to aePostFunction and changed scope of g_fModuleThread in order to prevent module related deadlocks, issue #214
Former-commit-id: 3b8d1f7076
2021-02-01 15:51:22 -05:00
John Sully 3c663b69b8 Bump version
Former-commit-id: d30fcfbe8a
2021-01-31 21:24:49 +00:00
John Sully 9c59979955 Merge branch 'unstable' into RELEASE_6
Former-commit-id: 32b11ab809
2021-01-31 21:24:07 +00:00
John Sully 84576e9b39 ARM build fix
Former-commit-id: 5832c25ad1
2021-01-31 21:22:23 +00:00
John Sully 68ed1292ee Fix test failure caused by allowing pings during load
Former-commit-id: 569a3d9ff8
2021-01-31 07:15:55 +00:00
John Sully 10a745df65 Reduce intermittent failures by giving tests more time
Former-commit-id: 69bc7108bd
2021-01-31 06:33:13 +00:00
christianEQ a0ae32a9f0 added exception to allow pings during loading
Former-commit-id: 8a557e9d71
2021-01-31 00:12:49 -05:00
christianEQ 19dc63bd3a added severity levels for afterErrorReply
Former-commit-id: fe0f071993
2021-01-31 00:12:49 -05:00
John Sully d4408580b5 Improve multithreaded test reliability
Former-commit-id: effa53339c
2021-01-31 04:33:27 +00:00
John Sully 7766b37062 Fix test failure due to bad merge
Former-commit-id: f6fb0e4620
2021-01-31 03:40:57 +00:00
John Sully 516eee7a1a Fix CI failure due to missing package
Former-commit-id: cf46a014c1
2021-01-31 02:36:30 +00:00
John Sully 543d92d0ff Fix crash on shutdown command
Former-commit-id: d72b5fa16d
2021-01-31 02:30:28 +00:00
christianEQ 7d3b48fc33 Merge pull request #284 from christianEQ/redismerge_2021-01-20
Merge Redis 6.0.10 into KeyDB

Former-commit-id: 0151507cef
2021-01-29 10:59:36 -05:00
christianEQ 5a6f7c395f killMainThread -> killServerThreads
Former-commit-id: 0fea781f8f
2021-01-28 23:57:19 +00:00
christianEQ 3d2a59d7ae compare_exchange in connSocketRead, explicitly enforce memory order (even if redundant)
Former-commit-id: 3c4cadc020
2021-01-28 23:17:48 +00:00
christianEQ 9d62e397bd fixed replicaof no one config, added test case
Former-commit-id: e2615ccf88
2021-01-28 19:49:22 +00:00
christianEQ 304a037cb3 updated version num to 255.255.255
Former-commit-id: 595deb0e13
2021-01-28 16:54:22 +00:00
christianEQ 3949e90920 Merge remote-tracking branch 'john/unstable' into redismerge_2021-01-20
Former-commit-id: 5372d1aab2
2021-01-27 22:25:14 +00:00
christianEQ 70960ffe12 arm locker before checking zmalloc_used_memory
Former-commit-id: 52eca14ca6
2021-01-27 22:24:06 +00:00
Daniel Dai 6ffb95a313 Fix Swapdb crash
Former-commit-id: 1155f5ac63
2021-01-27 15:24:10 -05:00
christianEQ 5668a5d02d fixed uninitialized variables in ACLSetUserCommandBit
Former-commit-id: 7319953ae3
2021-01-26 23:29:15 +00:00
christianEQ b840a1a3eb fixed strncpy off-by-one errors
Former-commit-id: b8e106a72e
2021-01-26 23:27:28 +00:00
christianEQ 59ffc79765 removed unimplemented killIOThreads function declaration
Former-commit-id: f30f8eba2f
2021-01-26 22:27:22 +00:00
christianEQ 8d7142488b fixed server.cpp mentions
Former-commit-id: 7ed2296fc5
2021-01-26 22:22:19 +00:00
christianEQ 0312d89c7a added note about io-threads to keydb.conf
Former-commit-id: 0691a46669
2021-01-26 22:10:53 +00:00
christianEQ 237f3e8524 fixed race condition in connSocketWrite
Former-commit-id: d7f01c1f7d
2021-01-26 22:08:07 +00:00
christianEQ 1907c4f6f8 Removed Redis-specific things from conf file
Former-commit-id: 4d71929c60
2021-01-26 21:50:45 +00:00
christianEQ c068f2cd3d Merge tag 'tags/6.0.10' into redismerge_2021-01-20
Former-commit-id: dadce055f8
2021-01-26 21:43:09 +00:00
christianEQ ab80e23152 changed loading process config types to be consistent across environments
Former-commit-id: d2867580ab
2021-01-14 21:12:36 -05:00
christianEQ 464a08226d renamed loaded key counter to be more clear
Former-commit-id: 8dc238efae
2021-01-14 13:06:57 -05:00
christianEQ 81f4f73c30 removed 'comment arguments' from config options (doesn't ignore inline comments)
Former-commit-id: 7cd4b5e11c
2021-01-14 13:06:57 -05:00
christianEQ 047e1174d9 fixed signedness warning
Former-commit-id: 00043f9509
2021-01-14 13:06:57 -05:00
christianEQ 9262739be2 added section to keydb.conf for new options, tweaked default
Former-commit-id: 9b81f3f263
2021-01-14 13:06:57 -05:00
christianEQ 327c44f8eb ping replicas during key load
Former-commit-id: 2747d1a1a9
2021-01-14 13:06:57 -05:00
christianEQ 28a0cdc572 added config option for loading callback interval keys
Former-commit-id: 9f7ed0b232
2021-01-14 13:06:57 -05:00
christianEQ fc3388acfe configurized loading_process_events_interval_bytes
Former-commit-id: c176ea7366
2021-01-14 13:06:57 -05:00
Oran Agra 93fbd5d13e Redis 6.0.10 2021-01-12 16:25:37 +02:00
Oran Agra 463b97dacb Improve stability of new CSC eviction test (#8160)
b640e2944 added a test that now fails with valgrind
it fails for two resons:
1) the test samples the used memory and then limits the maxmemory to
   that value, but it turns out this is not atomic and on slow machines
   the background cron process that clean out old query buffers reduces
   the memory so that the setting doesn't cause eviction.
2) the dbsize was tested late, after reading some invalidation messages
   by that time more and more keys got evicted, partially draining the
   db. this is not the focus of this fix (still a known limitation)

(cherry picked from commit 080ad5b0f2)
2021-01-12 16:25:37 +02:00
Oran Agra 61640e5ba0 fix race in cluster transactions test (#8312)
we didn't wait for the commands executed on the master to reach the replica.

(cherry picked from commit 7d23490bd7)
2021-01-12 16:25:37 +02:00
Oran Agra 2be8879c06 Fix cluster diskless load swapdb test (#8308)
The test was trying to wait for the replica to start loading the rdb
from the master before it kills the master, but it was actually waiting
for ROLE to be in "sync" mode, which corresponds to REPL_STATE_TRANSFER
that starts before the actual loading starts.
now instead it waits for the loading flag to be set.

Besides, the test was dependent on the previous configuration of the
servers, relying on the fact the replica is configured to persist
(either RDB of AOF), now it is set explicitly.

(cherry picked from commit 37cf8d8f7f)
2021-01-12 16:25:37 +02:00
Bob Li 5041095cad Fix overflow of rdbWriteRaw return value (#8306)
Saving string of more than 2GB to the RDB file, can result in corrupt RDB, or failure in rdbSave.
S

(cherry picked from commit 3fb4197a74)
2021-01-12 16:25:37 +02:00
guybe7 2d537b376c Modules: Fix an integer sign bug in moduleTimerHandler (#8131)
bug was introduced in 9cbdc8dcdb

(cherry picked from commit de339c2963)
2021-01-12 16:25:37 +02:00
Egor Seredin 85bcc60165 Allow '\0' inside of result of sdscatvprintf, and efficiency improvements (#6260)
This will allow to use: RedisModule_CreateStringPrintf(ctx, "%s %c %s", "string1", 0, "string2");

On large string, the previous code would incrementally retry to double the output buffer.
now it uses the the return value of snprintf and grows to the right size in one step.

and also avoids an excessive strlen in sdscat at the end.

(cherry picked from commit 1ad4e18394)
2021-01-12 16:25:37 +02:00
guybe7 c01b72f30d Modules: Improve timer accuracy (#7987)
The bug occurs when 'callback' re-registers itself to a point
in the future and the execution time in non-negligible:
'now' refers to time BEFORE callback was executed and is used
to calculate 'next_period'.
We must get the actual current time when calculating 'next_period'

(cherry picked from commit 9cbdc8dcdb)
2021-01-12 16:25:37 +02:00
Meir Shpilraien (Spielrein) 58c00320e3 Moved RMAPI_FUNC_SUPPORTED location such that it will be visible to modules (#8037)
The RMAPI_FUNC_SUPPORTED was defined in the wrong place on redismodule.h
and was not visible to modules.

(cherry picked from commit 560d2dc008)
2021-01-12 16:25:37 +02:00
David CARLIER 010223a7f4 raspberry build fix. (#8095)
__ILP32__ is 32 bits ABI and does not imply x86, this patch resolves this. 

(cherry picked from commit 6e44f74dbc)
2021-01-12 16:25:37 +02:00
Yossi Gottlieb 1167967014 Fix crash log output on ARM. (#8020)
(cherry picked from commit 43c07a877c)
2021-01-12 16:25:37 +02:00
Oran Agra df32c5a812 Fix cluster access to unaligned memory (SIGBUS on old ARM) (#7958)
Turns out this was broken since version 4.0 when we added sds size
classes.
The cluster code uses sds for the receive buffer, and then casts it to a
struct and accesses a 64 bit variable.
This commit replaces the use of sds with a simple reallocated buffer.

(cherry picked from commit b71d06c269)
2021-01-12 16:25:37 +02:00
Oran Agra 39ac9ba73f prevent client tracking from causing feedback loop in performEvictions (#8100)
When client tracking is enabled signalModifiedKey can increase memory usage,
this can cause the loop in performEvictions to keep running since it was measuring
the memory usage impact of signalModifiedKey.

The section that measures the memory impact of the eviction should be just on dbDelete,
excluding keyspace notification, client tracking, and propagation to AOF and replicas.

This resolves part of the problem described in #8069
p.s. fix took 1 minute, test took about 3 hours to write.

(cherry picked from commit b640e2944e)
2021-01-12 16:25:37 +02:00
Madelyn Olson b3f7166eb5 White space tweaks and skip categories already applied
(cherry picked from commit b9b8ef1130)
2021-01-12 16:25:37 +02:00
Madelyn Olson a3806ed216 Further improved ACL algorithm for picking categories
(cherry picked from commit 2eae7756fd)
2021-01-12 16:25:37 +02:00
Yang Bodong 356e8f1afb Swapdb should make transaction fail if there is any client watching keys (#8239)
This PR not only fixes the problem that swapdb does not make the
transaction fail, but also optimizes the FLUSHALL and FLUSHDB command to
set the CLIENT_DIRTY_CAS flag to avoid unnecessary traversal of clients.

FLUSHDB was changed to first iterate on all watched keys, and then on the
clients watching each key.
Instead of iterating though all clients, and for each iterate on watched keys.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit f571f8467c)
2021-01-12 16:25:37 +02:00
Itamar Haber eeede65172 Adds 'use-memory' to GEORADIUS[BYMEMBER] (#8107)
Partial resolution for #6860, item 7

(cherry picked from commit 872a6c09e1)
2021-01-12 16:25:37 +02:00
Oran Agra 426a976a29 fix valgrind warning created by recent pidfile fix (#8235)
This isn't a leak, just an warning due to unreachable
allocation on the fork child.
Problem created by 4192faa

(cherry picked from commit 997c2dc7ec)
2021-01-12 16:25:37 +02:00
Meir Shpilraien (Spielrein) b0a00784da Fix issue where fork process deletes the parent pidfile (#8231)
Turns out that when the fork child crashes, the crash log was deleting
the pidfile from the disk (although the parent is still running.

Now we set the pidfile of the fork process to NULL so the fork process
will never deletes it.

(cherry picked from commit 4192faa982)
2021-01-12 16:25:37 +02:00
Wen Hui 2355a7056f Sentinel: add missing calls for sentinelflushconfig when config master at runtime (#8229)
(cherry picked from commit 84a2084d07)
2021-01-12 16:25:37 +02:00
Wen Hui a93d343902 fix memory leak in processInlineBuffer error handling code (#8295)
This code path is normally executed only when v6.0 and above replicates from v2.4

(cherry picked from commit 138ecf1de7)
2021-01-12 16:25:37 +02:00
huangzhw 277f92284c sdscatfmt call sdsMakeRoomFor, asked for more space than intended (#8286)
instead of asking for the extra new space it wanted, it asked to grow the
string by the size it already has too.
i.e. a string of 1000 bytes, needing to grow by 10 bytes, would have been
asking for an **additional** 1010 bytes.

(cherry picked from commit f2bde2268a)
2021-01-12 16:25:37 +02:00
huangzhw 02fe0138fe sort Command lookupKeyRead and lookupKeyWrite are used on the opposite (#8283)
This is a recent problem, introduced by 9b2a426 (redis 6.0)

The implications are:
The sole difference between LookupKeyRead and LookupKeyWrite is for command
executed on a replica, which are not received from its master client. (for the master,
and for the master client on the replica, these two functions behave the same)!

Since SORT is a write command, this bug only implicates a writable-replica.
And these are its implications:

- SORT STORE will behave as it did before the above mentioned commit (like before
  redis 6.0). on a writable-replica an already logically expired the key would have
  appeared missing. (store dest key would be deleted, instead of being populated
  with the data from the already logically expired key)
- SORT (the non store variant, which in theory could have been executed on
  read-only-replica if it weren't for the write flag), will (in redis 6.0) have a new bug
  and return the data from the already logically expired key instead of empty response.

(cherry picked from commit 6230ba0811)
2021-01-12 16:25:37 +02:00
Oran Agra 1ba383e8e7 Fix rdb checksum / crc64 on bigendian (#8270)
Turns out the RDB checksum in Redis 6.0 on bigendian is broken.
It always returned 0, so the RDB files are generated as if checksum is
disabled, and will be loaded ok on littleendian, and on bigendian.
But it'll not be able to load RDB files generated on littleendian or older versions.

Similarly DUMP and RESTORE will work on the same version (0==0),
but will be unable to exchange dump payloads with littleendian or old versions.

(cherry picked from commit a67621f495)
2021-01-12 16:25:37 +02:00
Oran Agra ab26f24b18 fix crash in redis-cli after making cluster backup (#8267)
getRDB is "designed" to work in two modes: one for redis-cli --rdb and
one for redis-cli --cluster backup.
in the later case it uses the hiredis connection from the cluster nodes
and it used to free it without nullifying the context, so a later
attempt to free the context would crash.

I suppose the reason it seems to want to free the hiredis context ASAP
is that it wants to disconnect the replica link, so that replication
buffers will not be accumulated.

(cherry picked from commit 93b8b13930)
2021-01-12 16:25:37 +02:00
Oran Agra 5576959fdc Fix wrong order of key/value in Lua map response (#8266)
When a Lua script returns a map to redis (a feature which was added in
redis 6 together with RESP3), it would have returned the value first and
the key second.

If the client was using RESP2, it was getting them out of order, and if
the client was in RESP3, it was getting a map of value => key.
This was happening regardless of the Lua script using redis.setresp(3)
or not.

This also affects a case where the script was returning a map which it got
from from redis by doing something like: redis.setresp(3); return redis.call()

This fix is a breaking change for redis 6.0 users who happened to rely
on the wrong order (either ones that used redis.setresp(3), or ones that
returned a map explicitly).

This commit also includes other two changes in the tests:
1. The test suite now handles RESP3 maps as dicts rather than nested
   lists
2. Remove some redundant (duplicate) tests from tracking.tcl

(cherry picked from commit bcde1d978d)
2021-01-12 16:25:37 +02:00
Oran Agra 03e4829239 Crash log would crash half way on commands with no arguments (#8260)
The crash log attempts to print the current client info, and when it
does that it attempts to check if the first argument happens to be a key
but it did so for commands with no arguments too, which caused the crash
log to crash half way and not reach its end.

(cherry picked from commit 318d581922)
2021-01-12 16:25:37 +02:00
Yossi Gottlieb 14305a876b Fix crashes with io-threads-do-reads enabled. (#8230)
Normally IO threads should simply read data from the socket into the
buffer and attempt to parse it.

If a protocol error is detected, a reply is generated which may result
with installing a write handler which is not thread safe. This fix
delays that until the client is processed back in the main thread.

Fixes #8220

(cherry picked from commit 53f926dd90)
2021-01-12 16:25:37 +02:00
George Prekas fecbb48519 Add check for the MADV_FREE/fork arm64 Linux kernel bug (#8224)
Older arm64 Linux kernels have a bug that could lead to data corruption during
background save under the following scenario:

1) jemalloc uses MADV_FREE on a page,
2) jemalloc reuses and writes the page,
3) Redis forks the background save process, and
4) Linux performs page reclamation.

Under these conditions, Linux will reclaim the page wrongfully and the
background save process will read zeros when it tries to read the page.

The bug has been fixed in Linux with commit:
ff1712f953e27f0b0718762ec17d0adb15c9fd0b ("arm64: pgtable: Ensure dirty bit is
preserved across pte_wrprotect()")

This Commit adds an ignore-warnings config, when not found, redis will
print a warning and exit on startup (default behavior).

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 75bbf56d37)

in 6.0 this warning is ignored by default in order to avoid adding
regression, specifically for deployments that don't need persistence or
replication
2021-01-12 16:25:37 +02:00
Qu Chen 01db11ce8d Not over-allocate client query buffer when reading large objects. (#5954)
In response to large client query buffer optimization introduced in 1898e6c. The calculation of the amount of
remaining bytes we need to write to the query buffer was calculated wrong, as a result we are unnecessarily
growing the client query buffer by sdslen(c->querybuf) always. This fix corrects that behavior.

Please note the previous behavior prior to the before-mentioned change was correctly calculating the remaining
additional bytes, and this change makes that calculate to be consistent.

Useful context, the argument of size `ll` starts at qb_pos (which is now the beginning of the sds), but much of it
may have already been read from the socket, so we only need to grow the sds for the remainder of it.

(cherry picked from commit b8c98337cd)
2021-01-12 16:25:37 +02:00
Oran Agra fb0783c710 Handle output buffer limits for Module blocked clients (#8141)
Module blocked clients cache the response in a temporary client,
the reply list in this client would be affected by the recent fix
in #7202, but when the reply is later copied into the real client,
it would have bypassed all the checks for output buffer limit, which
would have resulted in both: responding with a partial response to
the client, and also not disconnecting it at all.

(cherry picked from commit 11e0c4739b)
2021-01-12 16:25:37 +02:00
Yossi Gottlieb 0b5312a4a6 Fix setproctitle related crashes. (#8150)
Makes spt_init more careful with assumptions about what memory regions
may be overwritten. It will now only consider a contiguous block of argv
and envp elements and mind any gaps.

(cherry picked from commit 9f272197ea)
2021-01-12 16:25:37 +02:00
Yossi Gottlieb e2f6b95926 Fix use-after-free issue in spt_copyenv. (#8088)
Seems to have gone unnoticed for a long time, because at least with
glibc it will only be triggered if setenv() was called before spt_init,
which Redis doesn't.

Fixes #8064.

(cherry picked from commit 87f59674b4)
2021-01-12 16:25:37 +02:00
Wang Yuan f5d6057cbb Backup keys to slots map and restore when fail to sync if diskless-load type is swapdb in cluster mode (#8108)
When replica diskless-load type is swapdb in cluster mode, we didn't backup
keys to slots map, so we will lose keys to slots map if fail to sync.
Now we backup keys to slots map at first, and restore it properly when fail.

This commit includes a refactory/cleanup of the backups mechanism (moving it to db.c and re-structuring it a bit).

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 10712afaf3)
2021-01-12 16:25:37 +02:00
Wang Yuan ce6eee028d Reset average ttl when empty databases (#8106)
On FLUSHDB or full sync, reset old average TTL stat.
This Stat is incrementally collected by the master over time when it searches for expired keys. 

(cherry picked from commit b6916ca91c)
2021-01-12 16:25:37 +02:00
Oran Agra 626b8b2a13 Fix bug with module GIL being released prematurely (#8061)
This is hopefully usually harmles.
The server.ready_keys will usually be empty so the code after releasing
the GIL will soon be done.
The only case where it'll actually process things is when a module
releases a client (or module) blocked on a key, by triggering this NOT
from within a command (e.g. a timer event).

This bug was introduced in redis 6.0.9, see #7903

(cherry picked from commit f5604de4c8)
2021-01-12 16:25:37 +02:00
Oran Agra 878d8476e5 Fix oom-score-adj-values range, abs options, and bug when used in config file (#8046)
Fix: When oom-score-adj-values is provided in the config file after
oom-score-adj yes, it'll take an immediate action, before
readOOMScoreAdj was acquired, resulting in an error (out of range score
due to uninitialized value. delay the reaction the real call is made by
main().

Since the values are clamped to -1000..1000, and they're
applied as an offset from the value at startup (which may be -1000), we
need to allow the offsets to reach to +2000 so that a value of +1000 is
achievable in case the value at startup was -1000.

Adding an option for absolute values rather than relative ones.

(cherry picked from commit f08fd95c66)
2021-01-12 16:25:37 +02:00
guybe7 02236725af EXISTS should not alter LRU, OBJECT should not reveal expired keys on replica (#8016)
The bug was introduced by #5021 which only attempted avoid EXIST on an
already expired key from returning 1 on a replica.

Before that commit, dbExists was used instead of
lookupKeyRead (which had an undesired effect to "touch" the LRU/LFU)

Other than that, this commit fixes OBJECT to also come empty handed on
expired keys in replica.

And DEBUG DIGEST-VALUE to behave like DEBUG OBJECT (get the data from
the key regardless of it's expired state)

(cherry picked from commit 168dcb549c)
2021-01-12 16:25:37 +02:00
Wang Yuan bde35e3aaa Disable rehash when redis has child process (#8007)
In redisFork(), we don't set child pid, so updateDictResizePolicy()
doesn't take effect, that isn't friendly for copy-on-write.

The bug was introduced this in redis 6.0: e70fbad

(cherry picked from commit 16e3af9d23)
2021-01-12 16:25:37 +02:00
John Sully e9274a0a93 Fix intermittent module test failure, resizing the repl backlog is not good enough to clear the backlog
Former-commit-id: d50e4bb819
2021-01-12 00:29:07 +00:00
benschermel dd58268712 update perf chart, build info, job post link
Former-commit-id: 4485ca74f6
2021-01-11 11:40:00 -05:00
benschermel ca7ca0ee3a created ascii logo image
Former-commit-id: 7f72b214e5
2021-01-11 11:40:00 -05:00
John Sully 64d24938b3 Merge branch 'repl_perf' into unstable
Former-commit-id: bc8cc1adb3
2020-12-24 02:22:57 +00:00
John Sully 7d3d900cc5 Don't write in the lock
Former-commit-id: 93b7364aaecbe578be4b75c18c840c4b396c7d4e
2020-12-17 06:52:59 +00:00
John Sully b6479099d3 Merge branch 'unstable' into keydbpro
Former-commit-id: 53a062a6b796ccbd43560fed1b05367ba759da96
2020-12-11 18:39:30 +00:00
John Sully 248b6a52e3 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: d03c2de901
2020-12-11 03:59:50 +00:00
John Sully fb3c28ee49 don't try and free a client that can't be freed
Former-commit-id: 7d3c5f1e64
2020-12-11 03:59:39 +00:00
John Sully 5fbe23164d Prevent use after free
Former-commit-id: 81573de393
2020-12-11 03:59:26 +00:00
John Sully 34c014fb41 Merge branch 'unstable' into keydbpro
Former-commit-id: e59c3945d3ed0b05a3e42713b091b1b5c96a9db2
2020-12-11 00:49:54 +00:00
John Sully aab452cf61 Remove AE_ASSERT and use the proper assert infra
Former-commit-id: a80dd5d001
2020-12-11 00:24:27 +00:00
John Sully 3e8ac111b5 Prevent test crash due to unimplemented save for nested hash
Former-commit-id: 7e0077f293
2020-12-11 00:23:44 +00:00
John Sully 68665aeeb3 Fix crash freeing nested hash with list
Former-commit-id: 1eb035e6ad
2020-12-11 00:23:14 +00:00
John Sully 856dd45bf6 Fix test timeouts
Former-commit-id: 6f3feee67678b594fbe9fd592f9f823a7a07b770
2020-12-10 20:09:19 +00:00
John Sully 6b6ae228e1 Merge branch 'repl_perf' into keydbpro
Former-commit-id: c4431a6be7a1ddc05abdd4510630fac2a2a6664e
2020-12-10 18:45:52 +00:00
John Sully 5c832c5ad0 Merge branch 'unstable' into keydbpro
Former-commit-id: b7a1e16c0f04e8aeb3764e3681fa14fc0f97f6a3
2020-12-10 02:37:28 +00:00
Kajaruban Surendran ed3835ce5e Addressing PR comments
Former-commit-id: bdd14ac517
2020-12-04 14:54:06 -05:00
Kajaruban Surendran b09730b4e2 Addressing PR comments
Former-commit-id: 63e5d00bdf
2020-12-04 14:54:06 -05:00
Kajaruban Surendran 877f94734c Handling of aeResizeSetSize's return code for current thread
Former-commit-id: c25fb3d74f
2020-12-04 14:54:06 -05:00
Kajaruban Surendran d25fc8a950 check the aeResizeSetSize return code
Former-commit-id: 572d41325b
2020-12-04 14:54:06 -05:00
Kajaruban Surendran e62592666c Adding thread index to the error message
Former-commit-id: e02120cdf7
2020-12-04 14:54:06 -05:00
Kajaruban Surendran e53d00c320 Call aePostFunction to change the setsize of each threads by that thread
Former-commit-id: 7b1221a74d
2020-12-04 14:54:06 -05:00
Kajaruban Surendran 04ad6b5078 Calling initServerThread function cserver.cthreads(server-threads) times than MAX_EVENT_LOOPS(constant)
Former-commit-id: d6b4f994ad
2020-12-04 14:52:28 -05:00
christianEQ e6b4537a5d Issue: #204 Allocate 8 MB to thread stack
Former-commit-id: 66a41dafc4
2020-12-01 14:50:03 -05:00
John Sully abd543c8e9 Issue: #260 Don't use C++ static_assert in C files
Former-commit-id: f19b9c155e
2020-11-30 23:01:20 +00:00
John Sully c470266991 code coverage reports should test multithreaded
Former-commit-id: 5d016fdb6b
2020-11-30 22:59:00 +00:00
VivekSainiEQ 6da123ce77 Added module data type load/save tests
Former-commit-id: cae9924fd9
2020-11-30 17:47:04 -05:00
VivekSainiEQ 363cb7ec5b Removed use of module datatypes, now should work if tests/modules is not built
Former-commit-id: 089f28e8ba
2020-11-30 17:47:04 -05:00
VivekSainiEQ 6e00ea188b Added tests for saving various data types to disk and loading them back, and for loading data types from redis to maintain compatibility
Former-commit-id: dcb44d3a09
2020-11-30 17:47:04 -05:00
VivekSainiEQ 14bfa4618a Added remainder of runtest scripts to make lcov command. Code coverage goes from 57.9% to 72.1%
Former-commit-id: f99cba0b92
2020-11-30 17:47:04 -05:00
VivekSainiEQ fd3f2c7da4 Added KeyDB.info to .gitignore file
Former-commit-id: e10dc0dace
2020-11-30 17:47:04 -05:00
Kajaruban Surendran 188e7a5693 Configurable option for MOTD
Former-commit-id: 49a89d636b
2020-11-30 10:42:48 -05:00
VivekSainiEQ 9748c7af67 Added references to KeyDB.info instead of redis.info
Former-commit-id: b94f91b9b2
2020-11-25 18:49:20 -05:00
VivekSainiEQ 16c7fe3490 Properly escaped $ in lcov command
Former-commit-id: 06a17c8511
2020-11-25 18:49:20 -05:00
VivekSainiEQ e6a8c99eef Updated 'make lcov' command to exclude external dependancies and generate final code coverage percentage
Former-commit-id: eebd70aaa6
2020-11-25 18:49:20 -05:00
VivekSainiEQ 67fcffe545 Added test for issue #257
Former-commit-id: 779c775df9
2020-11-25 17:21:37 -05:00
VivekSainiEQ c7fd0951c5 Made NULL pointer check explicit, issue #257
Former-commit-id: 1d4d2925c2
2020-11-25 17:21:37 -05:00
VivekSainiEQ b9089ab13c Added NULL check to function objFromAllocPtr, now NULL input will map to NULL output even if active replica is enabled
Former-commit-id: b67db7c2d5
2020-11-25 17:21:37 -05:00
John Sully a2439842f6 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 18953b2998
2020-11-23 02:01:54 +00:00
John Sully 50c2a8524c Fix issue where active replication doesn't replicate RDB data
Former-commit-id: 527b7eb074
2020-11-23 02:01:40 +00:00
Kajaruban Surendran 1b77279021 fix for the server crash when the maxclients increased via config set
Former-commit-id: 34a97c447f
2020-11-20 15:20:46 -05:00
John Sully 3366f914d4 Blocking clients should not crash if an active replica loads a remote RDB with a key in the blocklist
Former-commit-id: 1c525e20b1
2020-11-19 23:28:01 +00:00
John Sully 5d68c2ca8f Merge branch 'RELEASE_6' into keydbpro
Former-commit-id: 2ee33cb050b26cbe34f0b390b8807cdc1b908ded
2020-11-19 20:38:47 +00:00
John Sully 3e828a5988 Ensure multithreaded tests pass
Former-commit-id: 0bcce50285
2020-11-13 21:08:10 +00:00
John Sully 973b769b21 Improve replication performance in multithreaded scenarios
Former-commit-id: 96e0b2a2b1
2020-11-13 21:08:10 +00:00
John Sully 104164aa14 Add ability to compile KeyDB without MOTD and curl
Former-commit-id: f3794d2c42
2020-11-13 20:51:30 +00:00
John Sully 2fdac516a6 Add missing file
Former-commit-id: 97fd736923
2020-11-11 03:29:38 +00:00
John Sully 4f7ac9c11f Second implementation of nested hashes
Former-commit-id: ba950a3d1f
2020-11-06 19:24:48 +00:00
John Sully f6f5fc3ccf Additional test reliability fixes
Former-commit-id: dad5a902d3
2020-10-27 07:25:43 +00:00
Oran Agra 984d33e8b6 Redis 6.0.9. 2020-10-27 09:12:01 +02:00
Yossi Gottlieb 77b0060fbe Fix wrong zmalloc_size() assumption. (#7963)
When using a system with no malloc_usable_size(), zmalloc_size() assumed
that the heap allocator always returns blocks that are long-padded.

This may not always be the case, and will result with zmalloc_size()
returning a size that is bigger than allocated. At least in one case
this leads to out of bound write, process crash and a potential security
vulnerability.

Effectively this does not affect the vast majority of users, who use
jemalloc or glibc.

This problem along with a (different) fix was reported by Drew DeVault.

(cherry picked from commit 05a086617d)
2020-10-27 09:12:01 +02:00
Oran Agra bfe67bd205 Attempt to fix sporadic test failures due to wait_for_log_messages (#7955)
The tests sometimes fail to find a log message.
Recently i added a print that shows the log files that are searched
and it shows that the message was in deed there.
The only reason i can't think of for this seach to fail, is we we
happened to read an incomplete line, which didn't match our pattern and
then on the next iteration we would continue reading from the line after
it.

The fix is to always re-evaluation the previous line.

(cherry picked from commit 35eb8ec6f3)
2020-10-27 09:12:01 +02:00
David CARLIER 8f7b0343ab cpu affinity: DragonFlyBSD support (#7956)
(cherry picked from commit c1ff07dfbb)
2020-10-27 09:12:01 +02:00
Zach Fewtrell 67b92eaffe fix invalid 'failover' identifier in cluster slave selection test (#7942)
(cherry picked from commit 0a0ec83e48)
2020-10-27 09:12:01 +02:00
WuYunlong 39272f6836 Update rdb_last_bgsave_time_sec in INFO on diskless replication (#7917)
`info Persistence` will include correct (updated) rdb_last_bgsave_time_sec
For diskless bgsave (sockets) too (like a few other persistence info fields).

Refactor code to reduce duplicate code.

(cherry picked from commit 51f36283df)
2020-10-27 09:12:01 +02:00
Wen Hui 6b4aba30a9 do not add save parameter during config rewrite in sentinel mode (#7945)
Previous code would have added default redis save parameters
to the config file on rewrite, which would have been silently ignored
when the config file is loaded.

The new code avoids adding this, and also actively removes these lines
If added by a previous config rewrite. 

(cherry picked from commit f61435fe8b)
2020-10-27 09:12:01 +02:00
Qu Chen 872744d196 WATCH no longer ignores keys which have expired for MULTI/EXEC. (#7920)
This wrong behavior was backed by a test, and also documentation, and dates back to 2010.
But it makes no sense to anyone involved so it was decided to change that.

Note that 3b031b1 (invalidate watch on expire on access) was released in 6.0 RC2
and 62a3ec8 released in in 6.0.0 GA (invalidate watch when key is evicted).
both of which do similar changes.

(cherry picked from commit 44bcbed2ee)
2020-10-27 09:12:01 +02:00
Oran Agra 7aec82cdb9 improve verbose logging on failed test. print log file lines (#7938)
(cherry picked from commit 33c59266cc)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb deaa71637a Add a --no-latency tests flag. (#7939)
Useful for running tests on systems which may be way slower than usual.

(cherry picked from commit be43c030df)
2020-10-27 09:12:01 +02:00
filipe oliveira 0a4aaa631f Fixed bug concerning redis-benchmark non clustered benchmark forcing always the same hash tag {tag} (#7931)
Adding the ":{tag}" only if --cluster is used, so that when used against
a proxy it generates traffic to all shards.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 128bc0f495)
2020-10-27 09:12:01 +02:00
Oran Agra edf8894162 fix 32bit build warnings (#7926)
(cherry picked from commit cc231e4882)
2020-10-27 09:12:01 +02:00
Wen Hui 4807eeef21 fix double fclose in aofrewrite (#7919)
minor fix for a bug which happen on error handling code
and doesn't look like it could have caused any real harm
(fd number wouldn't have been reused yet)

(cherry picked from commit ee8cb472a7)
2020-10-27 09:12:01 +02:00
Oran Agra c55bc96dc6 INFO report peak memory before eviction (#7894)
In some cases one command added a very big bulk of memory, and this
would be "resolved" by the eviction before the next command.

Seeing an unexplained mass eviction we would wish to
know the highest momentary usage too.

Tracking it in call() and beforeSleep() adds some hooks in AOF and RDB
loading.

The fix in clientsCronTrackExpansiveClients is related to #7874

(cherry picked from commit 0de424cab9)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb c9dcf82020 Fix tests failure on busybox systems. (#7916)
(cherry picked from commit 6a035f5edf)
2020-10-27 09:12:01 +02:00
Oran Agra 1ee7b3973b Allow requirepass config to clear the password (#7899)
This is a compatibility issue with redis 5.0 that was introduced by ACL.
Before this commit, setting requirepass to an empty string will result
in a server that needs an empty AUTH, unlike redis 5.0 which would
accept connections without an AUTH.

(cherry picked from commit c7fe6387d9)
2020-10-27 09:12:01 +02:00
Wang Yuan 86c8cf42a0 Remove temporary aof and rdb files in a background thread (#7905)
If we fail or stop to rewrite aof, we need to remove temporary aof.
We also remove temporary rdb when replicas abort to receive rdb.
But currently we delete them in main thread, to avoid blocking,
we should use bg_unlink to remove them in a background thread.

Btw, we have already used this way to removed child process temporary rdb.

(cherry picked from commit 5bb220660e)
2020-10-27 09:12:01 +02:00
guybe7 371555135f Minor improvements to module blocked on keys (#7903)
- Clarify some documentation comments
- Make sure blocked-on-keys client privdata is accessible
  from withing the timeout callback
- Handle blocked clients in beforeSleep - In case a key
  becomes "ready" outside of processCommand

See #7879 #7880

(cherry picked from commit c816eec893)
2020-10-27 09:12:01 +02:00
Andreas Lind 2a9f491e0d Support redis-cli -u rediss://... (#7900)
(cherry picked from commit efa784d5f2)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb c6c0155725 Modules: fix RM_GetCommandKeys API. (#7901)
This cleans up and simplifies the API by passing the command name as the
first argument. Previously the command name was specified explicitly,
but was still included in the argv.

(cherry picked from commit a94ddb27fe)
2020-10-27 09:12:01 +02:00
Meir Shpilraien (Spielrein) dbf3902481 Add Module API for version and compatibility checks (#7865)
* Introduce a new API's: RM_GetContextFlagsAll, and
RM_GetKeyspaceNotificationFlagsAll that will return the
full flags mask of each feature. The module writer can
check base on this value if the Flags he needs are
supported or not.

* For each flag, introduce a new value on redismodule.h,
this value represents the LAST value and should be there
as a reminder to update it when a new value is added,
also it will be used in the code to calculate the full
flags mask (assuming flags are incrementally increasing).
In addition, stated that the module writer should not use
the LAST flag directly and he should use the GetFlagAll API's.

* Introduce a new API: RM_IsSubEventSupported, that returns for a given
event and subevent, whether or not the subevent supported.

* Introduce a new macro RMAPI_FUNC_SUPPORTED(func) that returns whether
or not a function API is supported by comparing it to NULL.

* Introduce a new API: int RM_GetServerVersion();, that will return the
current Redis version in the format 0x00MMmmpp; e.g. 0x00060008;

* Changed unstable version from 999.999.999 to 255.255.255

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
(cherry picked from commit e9c837ad31)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 02edabc9aa Module API: Add RM_GetClientCertificate(). (#7866)
This API function makes it possible to retrieve the X.509 certificate
used by clients to authenticate TLS connections.

(cherry picked from commit 929f1e2ec7)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 298808cf32 Modules: Add RM_GetDetachedThreadSafeContext(). (#7886)
The main motivation here is to provide a way for modules to create a
single, global context that can be used for logging.

Currently, it is possible to obtain a thread-safe context that is not
attached to any blocked client by using `RM_GetThreadSafeContext`.
However, the attached context is not linked to the module identity so
log messages produced are not tagged with the module name.

Ideally we'd fix this in `RM_GetThreadSafeContext` itself but as it
doesn't accept the current context as an argument there's no way to do
that in a backwards compatible manner.

(cherry picked from commit e270302cdf)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 4af8059e61 Modules: add RM_GetCommandKeys().
This is essentially the same as calling COMMAND GETKEYS but provides a
more efficient interface that can be used in every context (i.e. not a
Redis command).

(cherry picked from commit 9e58b52a19)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb ad1ed7dcd0 Introduce getKeysResult for getKeysFromCommand.
Avoid using a static buffer for short key index responses, and make it
caller's responsibility to stack-allocate a result type. Responses that
don't fit are still allocated on the heap.

(cherry picked from commit bf5beab64a)
2020-10-27 09:12:01 +02:00
Madelyn Olson ec9b1cca59 Fixed excessive categories being displayed from acls (#7889)
(cherry picked from commit abe416c5f2)
2020-10-27 09:12:01 +02:00
Oran Agra 9cf7292ef7 Add some additional signal info to the crash log (#7891)
- si_code can be very useful info some day.
- a clear indication that redis was killed by an external user

(cherry picked from commit 38c7c62d22)
2020-10-27 09:12:01 +02:00
Oran Agra 6e03b388ce Allow blocked XREAD on a cluster replica (#7881)
I suppose that it was overlooked, since till recently none of the blocked commands were readonly.

other changes:
- add test for the above.
- add better support for additional (and deferring) clients for
  cluster tests
- improve a test which left the client in MULTI state.

(cherry picked from commit ba61700db2)
2020-10-27 09:12:01 +02:00
Oran Agra a5302a8c21 memory reporting of clients argv (#7874)
track and report memory used by clients argv.
this is very usaful in case clients started sending a command and didn't
complete it. in which case the first args of the command are already
trimmed from the query buffer.

in an effort to avoid cache misses and overheads while keeping track of
these, i avoid calling sdsZmallocSize and instead use the sdslen /
bulk-len which can at least give some insight into the problem.

This memory is now added to the total clients memory usage, as well as
the client list.

(cherry picked from commit 7481e513f0)
2020-10-27 09:12:01 +02:00
DvirDukhan 7a8a268ac4 redis-cli add control on raw format line delimiter (#7841)
Adding -D option for redis-cli to control newline between command
responses in raw mode.

Also removing cleanup code before calling exit, just in order
to avoid adding more adding more cleanup code (redis doesn't
bother to release allocations before exit anyway)

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit f0f8e9c824)
2020-10-27 09:12:01 +02:00
Oran Agra 0d7a1d1d37 Include internal sds fragmentation in MEMORY reporting (#7864)
The MEMORY command is used for debugging memory usage, so it should include internal
fragmentation, same as used_memory

(cherry picked from commit 86483e7952)
2020-10-27 09:12:01 +02:00
Oran Agra 51dd4677c9 Fix crash in script timeout during AOF loading (#7870)
(cherry picked from commit 8cff3e0352)
2020-10-27 09:12:01 +02:00
Rafi Einstein 57027f0c55 Makefile: enable program suffixes via PROG_SUFFIX (#7868)
(cherry picked from commit 2636b760fb)
2020-10-27 09:12:01 +02:00
nitaicaro e7bae88392 Fixed Tracking test “The other connection is able to get invalidations” (#7871)
PROBLEM:

[$rd1 read] reads invalidation messages one by one, so it's never going to see the second invalidation message produced after INCR b, whether or not it exists. Adding another read will block incase no invalidation message is produced.

FIX:

We switch the order of "INCR a" and "INCR b" - now "INCR b" comes first. We still only read the first invalidation message produces. If an invalidation message is wrongly produces for b - then it will be produced before that of a, since "INCR b" comes before "INCR a".

Co-authored-by: Nitai Caro <caronita@amazon.com>
(cherry picked from commit 94e9b0124e)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 38853fd487 Modules: expose real client on conn events.
When REDISMODULE_EVENT_CLIENT_CHANGE events are delivered, modules may
want to mutate the client state (e.g. perform authentication).

This change links the module context with the real client rather than a
fake client for these events.

(cherry picked from commit 4aca4e5f39)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 0816b8fadd Module API: Fail ineffective auth calls.
The client pointed to by the module context may in some cases be a fake
client. RM_Authenticate*() calls in this case would be ineffective but
appear to succeed, and this change fails them to make it easier to catch
such cases.

(cherry picked from commit 82866776d0)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 51a6e1e61a TLS: Do not require CA config if not used. (#7862)
The tls-ca-cert or tls-ca-cert-dir configuration parameters are only
used when Redis needs to authenticate peer certificates, in one of these
scenarios:

1. Incoming clients or replicas, with `tls-auth-clients` enabled.
2. A replica authenticating the master's peer certificate.
3. Cluster nodes authenticating other nodes when establishing the bus
   protocol connection.

(cherry picked from commit 3bd9d0cc85)
2020-10-27 09:12:01 +02:00
Oran Agra c7cae0df77 warning: comparison between signed and unsigned integer in 32bit build (#7838)
(cherry picked from commit c11bda25fd)
2020-10-27 09:12:01 +02:00
David CARLIER 4da8211063 Add support for Haiku OS (#7435)
(cherry picked from commit d535a5061c)
2020-10-27 09:12:01 +02:00
Gavrie Philipson c6d6646567 Fix typo in module API docs (#7861)
(cherry picked from commit ce5efb444b)
2020-10-27 09:12:01 +02:00
David CARLIER 58a7774ca4 getting rss size implementation for netbsd (#7293)
(cherry picked from commit 520c3b26c3)
2020-10-27 09:12:01 +02:00
Oran Agra 0fc601b3dd Fix new obuf-limits tests to work with TLS (#7848)
Also stabilize new shutdown tests on slow machines (valgrind)

(cherry picked from commit d89ae2d7ab)
2020-10-27 09:12:01 +02:00
caozb 5ed795f025 ignore slaveof no one in redis.conf (#7842)
when slaveof config is "no one", reset any pre-existing config and resume.

also solve a memory leak if slaveof appears twice.
and fail loading if port number is out of range or not an integer.

Co-authored-by: caozhengbin <caozb@yidingyun.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 01694608cb)
2020-10-27 09:12:01 +02:00
Wang Yuan a6f8745127 Don't support Gopher if enable io threads to read queries (#7851)
There's currently an issue with IO threads and gopher (issuing lookupKey from within the thread).
simply fix is to just not support it for now.

(cherry picked from commit 9bdef76f8e)
2020-10-27 09:12:01 +02:00
Wang Yuan 9042852ea1 Set 'loading' and 'shutdown_asap' to volatile sig_atomic_t type (#7845)
We may access and modify these two variables in signal handler function,
to guarantee them async-signal-safe, so we should set them to volatile
sig_atomic_t type.

It doesn't look like this could have caused any real issue, and it seems that
signals are handled in main thread on most platforms. But we want to follow C
and POSIX standard in signal handler function.

(cherry picked from commit 917043fa43)
2020-10-27 09:12:01 +02:00
Uri Shachar 10be3d96d8 Fix config rewrite file handling to make it really atomic (#7824)
Make sure we handle short writes correctly, sync to disk after writing  and use
rename to make sure the replacement is actually atomic.
In any case of failure old configuration will remain in place.

Also, add some additional logging to make it easier to diagnose rewrite problems.

(cherry picked from commit 8dbe91f031)
2020-10-27 09:12:01 +02:00
WuYunlong 39e1f2e2bd Add fsync to readSyncBulkPayload(). (#7839)
We should sync temp DB file before renaming as rdb_fsync_range does not use
flag `SYNC_FILE_RANGE_WAIT_AFTER`.

Refer to `Linux Programmer's Manual`:
SYNC_FILE_RANGE_WAIT_AFTER
    Wait upon write-out of all pages in the range after performing any write.

(cherry picked from commit d119448881)
2020-10-27 09:12:01 +02:00
Wen Hui ac867bfb6a rdb.c: handle fclose error case differently to avoid double fclose (#7307)
When fclose would fail, the previous implementation would have attempted to do fclose again
this can in theory lead to segfault.

other changes:
check for non-zero return value as failure rather than a specific error code.
this doesn't fix a real bug, just a minor cleanup.

(cherry picked from commit c67656fa35)
2020-10-27 09:12:01 +02:00
Wang Yuan 1c4a99c9ec Don't write replies if close the client ASAP (#7202)
Before this commit, we would have continued to add replies to the reply buffer even if client
output buffer limit is reached, so the used memory would keep increasing over the configured limit.
What's more, we shouldn’t write any reply to the client if it is set 'CLIENT_CLOSE_ASAP' flag
because that doesn't conform to its definition and we will close all clients flagged with
'CLIENT_CLOSE_ASAP' in ‘beforeSleep’.

Because of code execution order, before this, we may firstly write to part of the replies to
the socket before disconnecting it, but in fact, we may can’t send the full replies to clients
since OS socket buffer is limited. But this unexpected behavior makes some commands work well,
for instance ACL DELUSER, if the client deletes the current user, we need to send reply to client
and close the connection, but before, we close the client firstly and write the reply to reply
buffer. secondly, we shouldn't do this despite the fact it works well in most cases.

We add a flag 'CLIENT_CLOSE_AFTER_COMMAND' to mark clients, this flag means we will close the
client after executing commands and send all entire replies, so that we can write replies to
reply buffer during executing commands, send replies to clients, and close them later.

We also fix some implicit problems. If client output buffer limit is enforced in 'multi/exec',
all commands will be executed completely in redis and clients will not read any reply instead of
partial replies. Even more, if the client executes 'ACL deluser' the using user in 'multi/exec',
it will not read the replies after 'ACL deluser' just like before executing 'client kill' itself
in 'multi/exec'.

We added some tests for output buffer limit breach during multi-exec and using a pipeline of
many small commands rather than one with big response.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 3085577c09)
2020-10-27 09:12:01 +02:00
Guy Korland 66a13267c7 Fix RedisModule_HashGet examples (#6697)
(cherry picked from commit 04945e0e6d)
2020-10-27 09:12:01 +02:00
Oran Agra 7ab8961c6d fix recently broken TLS build error, and add coverage for CI (#7833)
(cherry picked from commit 270fcb80bf)
2020-10-27 09:12:01 +02:00
David CARLIER 06c8f03ba1 Further NetBSD update and build fixes. (#7831)
mainly backtrace and register dump support.

(cherry picked from commit 6bc28d99a3)
2020-10-27 09:12:01 +02:00
WuYunlong d3fc736123 Fix redundancy use of semicolon in do-while macros in ziplist.c. (#7832)
this is very dangerous bug, but it looks like it didn't cause any harm.

(cherry picked from commit 00668f782f)
2020-10-27 09:12:01 +02:00
yixiang f478a1b6fb Fix connGetSocketError usage (#7811)
(cherry picked from commit 4e70e49d2b)
2020-10-27 09:12:01 +02:00
Oran Agra 90e8da536e RM_GetContextFlags - document missing flags (#7821)
(cherry picked from commit 78c80b3f8c)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb 24f258e39c Fix occasional hangs on replication reconnection. (#7830)
This happens only on diskless replicas when attempting to reconnect after 
failing to load an RDB file. It is more likely to occur with larger datasets.

After reconnection is initiated, replicationEmptyDbCallback() may get called 
and try to write to an unconnected socket. This triggered another issue where
the connection is put into an error state and the connect handler never gets
called. The problem is a regression introduced by commit cad93ed.

(cherry picked from commit ecd86283ec)
2020-10-27 09:12:01 +02:00
Ariel Shtul 29f6e9fe95 Fix redis-check-rdb support for modules aux data (#7826)
redis-check-rdb was unable to parse rdb files containing module aux data.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit b914d4fc48)
2020-10-27 09:12:01 +02:00
Wen Hui 8f4ad687af refactor rewriteStreamObject code for adding missing streamIteratorStop call (#7829)
This commit adds streamIteratorStop call in rewriteStreamObject function in some of the return statement. Although currently this will not cause memory leak since stream id is only 16 bytes long.


(cherry picked from commit 7934f163b4)
2020-10-27 09:12:01 +02:00
WuYunlong 5021ed7c45 Make IO threads killable so that they can be canceled at any time.
This commit can be cherry picked to 6.0 only if we also cherry pick e9b6077.

(cherry picked from commit 6c6ab16e5a)
2020-10-27 09:12:01 +02:00
WuYunlong 4a3330c941 Make main thread killable so that it can be canceled at any time.
Refine comment of makeThreadKillable().

This commit can be backported to 5.0, only if we also backport cf8a6e3.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit d229162730)
2020-10-27 09:12:01 +02:00
Oran Agra f216bf312a RM_GetContextFlags provides indication that we're in a fork child (#7783)
(cherry picked from commit 0b476b591d)
2020-10-27 09:12:01 +02:00
Wen Hui d3f36e93a9 Add Swapdb Module Event (#7804)
(cherry picked from commit 0db3223bc6)
2020-10-27 09:12:01 +02:00
Daniel Dai 064992af62 fix make warnings in debug.c MacOS (#7805)
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 6d46a8e216)
2020-10-27 09:12:01 +02:00
David CARLIER 57e1dbff57 debug.c: NetBSD build warning fix. (#7810)
The symbol base address is a const on this system.

(cherry picked from commit c9edb47792)
2020-10-27 09:12:01 +02:00
Wang Yuan 048816bf27 Remove tmp rdb file in background thread (#7762)
We're already using bg_unlink in several places to delete the rdb file in the background,
and avoid paying the cost of the deletion from our main thread.
This commit uses bg_unlink to remove the temporary rdb file in the background too.

However, in case we delete that rdb file just before exiting, we don't actually wait for the
background thread or the main thread to delete it, and just let the OS clean up after us.
i.e. we open the file, unlink it and exit with the fd still open.

Furthermore, rdbRemoveTempFile can be called from a thread and was using snprintf which is
not async-signal-safe, we now use ll2string instead.

(cherry picked from commit 6638f61295)
2020-10-27 09:12:01 +02:00
Oran Agra 1cbdafc980 Add printf attribute and fix warnings and a minor bug (#7803)
The fix in error handling of rdbGenericLoadStringObject is an actual bugfix

(cherry picked from commit 622b57e9ee)
2020-10-27 09:12:01 +02:00
WuYunlong 201b993840 bio: doFastMemoryTest should try to kill io threads as well.
(cherry picked from commit e9b6077ac7)
2020-10-27 09:12:01 +02:00
WuYunlong 4aef590a63 bio: fix doFastMemoryTest.
If one thread got SIGSEGV, function sigsegvHandler() would be triggered,
it would call bioKillThreads(). But call pthread_cancel() to cancel itself
would make it block. Also note that if SIGSEGV is caught by bio thread, it
should kill the main thread in order to give a positive report.

(cherry picked from commit cf8a6e3c7a)
2020-10-27 09:12:01 +02:00
Wen Hui 385e3596b5 correct OBJECT ENCODING response for stream type (#7797)
This commit makes stream object returning "stream" as encoding type in OBJECT ENCODING subcommand and DEBUG OBJECT command.

Till now, it would return "unknown"

(cherry picked from commit 2a8803f534)
2020-10-27 09:12:01 +02:00
WuYunlong 7e8f233e8b Clarify help text of tcl scripts. (#7798)
Before this commit, following command did not show --tls option:
./runtest-cluster --help
./runtest-sentinel --help

(cherry picked from commit e4a1280a0e)
2020-10-27 09:12:01 +02:00
Mykhailo Pylyp b4299b0629 Recalculate hardcoded variables from $::instances_count in sentinel tests (#7561)
Co-authored-by: MemuraiUser <githubuser@janeasystems.com>
(cherry picked from commit c0a41896da)
2020-10-27 09:12:01 +02:00
Oran Agra 5097434dee Fix failing valgrind installation in github actions (#7792)
These tests started failing every day on http 404 (not being able to
install valgrind)

(cherry picked from commit 9428c1a591)
2020-10-27 09:12:01 +02:00
Oran Agra c769bc81b6 fix broken PEXPIREAT test (#7791)
This test was nearly always failing on MacOS github actions.
This is because of bugs in the test that caused it to nearly always run
all 3 attempts and just look at the last one as the pass/fail creteria.

i.e. the test was nearly always running all 3 attempts and still sometimes
succeed. this is because the break condition was different than the test
completion condition.

The reason the test succeeded is because the break condition tested the
results of all 3 tests (PSETEX/PEXPIRE/PEXPIREAT), but the success check
at the end was only testing the result of PSETEX.

The reason the PEXPIREAT test nearly always failed is because it was
getting the current time wrong: getting the current second and loosing
the sub-section time, so the only chance for it to succeed is if it run
right when a certain second started.

Because i now get the time from redis, adding another round trip, i
added another 100ms to the PEXPIRE test to make it less fragile, and
also added many more attempts.

Adding many more attempts before failure to account for slow platforms,
github actions and valgrind

(cherry picked from commit 1fd56bb75a)
2020-10-27 09:12:01 +02:00
Wang Yuan 410c101439 Remove dead global variable 'lru_clock' (#7782)
(cherry picked from commit 95595d0636)
2020-10-27 09:12:01 +02:00
Oran Agra f264678ccf Squash merging 125 typo/grammar/comment/doc PRs (#7773)
List of squashed commits or PRs
===============================

commit 66801ea
Author: hwware <wen.hui.ware@gmail.com>
Date:   Mon Jan 13 00:54:31 2020 -0500

    typo fix in acl.c

commit 46f55db
Author: Itamar Haber <itamar@redislabs.com>
Date:   Sun Sep 6 18:24:11 2020 +0300

    Updates a couple of comments

    Specifically:

    * RM_AutoMemory completed instead of pointing to docs
    * Updated link to custom type doc

commit 61a2aa0
Author: xindoo <xindoo@qq.com>
Date:   Tue Sep 1 19:24:59 2020 +0800

    Correct errors in code comments

commit a5871d1
Author: yz1509 <pro-756@qq.com>
Date:   Tue Sep 1 18:36:06 2020 +0800

    fix typos in module.c

commit 41eede7
Author: bookug <bookug@qq.com>
Date:   Sat Aug 15 01:11:33 2020 +0800

    docs: fix typos in comments

commit c303c84
Author: lazy-snail <ws.niu@outlook.com>
Date:   Fri Aug 7 11:15:44 2020 +0800

    fix spelling in redis.conf

commit 1eb76bf
Author: zhujian <zhujianxyz@gmail.com>
Date:   Thu Aug 6 15:22:10 2020 +0800

    add a missing 'n' in comment

commit 1530ec2
Author: Daniel Dai <764122422@qq.com>
Date:   Mon Jul 27 00:46:35 2020 -0400

    fix spelling in tracking.c

commit e517b31
Author: Hunter-Chen <huntcool001@gmail.com>
Date:   Fri Jul 17 22:33:32 2020 +0800

    Update redis.conf

    Co-authored-by: Itamar Haber <itamar@redislabs.com>

commit c300eff
Author: Hunter-Chen <huntcool001@gmail.com>
Date:   Fri Jul 17 22:33:23 2020 +0800

    Update redis.conf

    Co-authored-by: Itamar Haber <itamar@redislabs.com>

commit 4c058a8
Author: 陈浩鹏 <chenhaopeng@heytea.com>
Date:   Thu Jun 25 19:00:56 2020 +0800

    Grammar fix and clarification

commit 5fcaa81
Author: bodong.ybd <bodong.ybd@alibaba-inc.com>
Date:   Fri Jun 19 10:09:00 2020 +0800

    Fix typos

commit 4caca9a
Author: Pruthvi P <pruthvi@ixigo.com>
Date:   Fri May 22 00:33:22 2020 +0530

    Fix typo eviciton => eviction

commit b2a25f6
Author: Brad Dunbar <dunbarb2@gmail.com>
Date:   Sun May 17 12:39:59 2020 -0400

    Fix a typo.

commit 12842ae
Author: hwware <wen.hui.ware@gmail.com>
Date:   Sun May 3 17:16:59 2020 -0400

    fix spelling in redis conf

commit ddba07c
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date:   Sat May 2 23:25:34 2020 +0100

    Correct a "conflicts" spelling error.

commit 8fc7bf2
Author: Nao YONASHIRO <yonashiro@r.recruit.co.jp>
Date:   Thu Apr 30 10:25:27 2020 +0900

    docs: fix EXPIRE_FAST_CYCLE_DURATION to ACTIVE_EXPIRE_CYCLE_FAST_DURATION

commit 9b2b67a
Author: Brad Dunbar <dunbarb2@gmail.com>
Date:   Fri Apr 24 11:46:22 2020 -0400

    Fix a typo.

commit 0746f10
Author: devilinrust <63737265+devilinrust@users.noreply.github.com>
Date:   Thu Apr 16 00:17:53 2020 +0200

    Fix typos in server.c

commit 92b588d
Author: benjessop12 <56115861+benjessop12@users.noreply.github.com>
Date:   Mon Apr 13 13:43:55 2020 +0100

    Fix spelling mistake in lazyfree.c

commit 1da37aa
Merge: 2d4ba28 c90b2a4
Author: hwware <wen.hui.ware@gmail.com>
Date:   Thu Mar 5 22:41:31 2020 -0500

    Merge remote-tracking branch 'upstream/unstable' into expiretypofix

commit 2d4ba28
Author: hwware <wen.hui.ware@gmail.com>
Date:   Mon Mar 2 00:09:40 2020 -0500

    fix typo in expire.c

commit 1a746f7
Author: SennoYuki <minakami1yuki@gmail.com>
Date:   Thu Feb 27 16:54:32 2020 +0800

    fix typo

commit 8599b1a
Author: dongheejeong <donghee950403@gmail.com>
Date:   Sun Feb 16 20:31:43 2020 +0000

    Fix typo in server.c

commit f38d4e8
Author: hwware <wen.hui.ware@gmail.com>
Date:   Sun Feb 2 22:58:38 2020 -0500

    fix typo in evict.c

commit fe143fc
Author: Leo Murillo <leonardo.murillo@gmail.com>
Date:   Sun Feb 2 01:57:22 2020 -0600

    Fix a few typos in redis.conf

commit 1ab4d21
Author: viraja1 <anchan.viraj@gmail.com>
Date:   Fri Dec 27 17:15:58 2019 +0530

    Fix typo in Latency API docstring

commit ca1f70e
Author: gosth <danxuedexing@qq.com>
Date:   Wed Dec 18 15:18:02 2019 +0800

    fix typo in sort.c

commit a57c06b
Author: ZYunH <zyunhjob@163.com>
Date:   Mon Dec 16 22:28:46 2019 +0800

    fix-zset-typo

commit b8c92b5
Author: git-hulk <hulk.website@gmail.com>
Date:   Mon Dec 16 15:51:42 2019 +0800

    FIX: typo in cluster.c, onformation->information

commit 9dd981c
Author: wujm2007 <jim.wujm@gmail.com>
Date:   Mon Dec 16 09:37:52 2019 +0800

    Fix typo

commit e132d7a
Author: Sebastien Williams-Wynn <s.williamswynn.mail@gmail.com>
Date:   Fri Nov 15 00:14:07 2019 +0000

    Minor typo change

commit 47f44d5
Author: happynote3966 <01ssrmikururudevice01@gmail.com>
Date:   Mon Nov 11 22:08:48 2019 +0900

    fix comment typo in redis-cli.c

commit b8bdb0d
Author: fulei <fulei@kuaishou.com>
Date:   Wed Oct 16 18:00:17 2019 +0800

    Fix a spelling mistake of comments  in defragDictBucketCallback

commit 0def46a
Author: fulei <fulei@kuaishou.com>
Date:   Wed Oct 16 13:09:27 2019 +0800

    fix some spelling mistakes of comments in defrag.c

commit f3596fd
Author: Phil Rajchgot <tophil@outlook.com>
Date:   Sun Oct 13 02:02:32 2019 -0400

    Typo and grammar fixes

    Redis and its documentation are great -- just wanted to submit a few corrections in the spirit of Hacktoberfest. Thanks for all your work on this project. I use it all the time and it works beautifully.

commit 2b928cd
Author: KangZhiDong <worldkzd@gmail.com>
Date:   Sun Sep 1 07:03:11 2019 +0800

    fix typos

commit 33aea14
Author: Axlgrep <axlgrep@gmail.com>
Date:   Tue Aug 27 11:02:18 2019 +0800

    Fixed eviction spelling issues

commit e282a80
Author: Simen Flatby <simen@oms.no>
Date:   Tue Aug 20 15:25:51 2019 +0200

    Update comments to reflect prop name

    In the comments the prop is referenced as replica-validity-factor,
    but it is really named cluster-replica-validity-factor.

commit 74d1f9a
Author: Jim Green <jimgreen2013@qq.com>
Date:   Tue Aug 20 20:00:31 2019 +0800

    fix comment error, the code is ok

commit eea1407
Author: Liao Tonglang <liaotonglang@gmail.com>
Date:   Fri May 31 10:16:18 2019 +0800

    typo fix

    fix cna't to can't

commit 0da553c
Author: KAWACHI Takashi <tkawachi@gmail.com>
Date:   Wed Jul 17 00:38:16 2019 +0900

    Fix typo

commit 7fc8fb6
Author: Michael Prokop <mika@grml.org>
Date:   Tue May 28 17:58:42 2019 +0200

    Typo fixes

    s/familar/familiar/
    s/compatiblity/compatibility/
    s/ ot / to /
    s/itsef/itself/

commit 5f46c9d
Author: zhumoing <34539422+zhumoing@users.noreply.github.com>
Date:   Tue May 21 21:16:50 2019 +0800

    typo-fixes

    typo-fixes

commit 321dfe1
Author: wxisme <850885154@qq.com>
Date:   Sat Mar 16 15:10:55 2019 +0800

    typo fix

commit b4fb131
Merge: 267e0e6 4842305
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date:   Fri Feb 8 22:55:45 2019 +0200

    Merge branch 'unstable' of antirez/redis into unstable

commit 267e0e6
Author: Nikitas Bastas <nikitasbst@gmail.com>
Date:   Wed Jan 30 21:26:04 2019 +0200

    Minor typo fix

commit 30544e7
Author: inshal96 <39904558+inshal96@users.noreply.github.com>
Date:   Fri Jan 4 16:54:50 2019 +0500

    remove an extra 'a' in the comments

commit 337969d
Author: BrotherGao <yangdongheng11@gmail.com>
Date:   Sat Dec 29 12:37:29 2018 +0800

    fix typo in redis.conf

commit 9f4b121
Merge: 423a030 19d0ece
Author: BrotherGao <yangdongheng@xiaomi.com>
Date:   Sat Dec 29 11:41:12 2018 +0800

    Merge branch 'unstable' of antirez/redis into unstable

commit 423a030
Merge: 42b02b7 0423081
Author: 杨东衡 <yangdongheng@xiaomi.com>
Date:   Tue Dec 4 23:56:11 2018 +0800

    Merge branch 'unstable' of antirez/redis into unstable

commit 42b02b7
Merge: 8c7dcff efa96f0
Author: Dongheng Yang <yangdongheng11@gmail.com>
Date:   Sun Oct 28 15:54:23 2018 +0800

    Merge pull request #1 from antirez/unstable

    update local data

commit 714b589
Author: Christian <crifei93@gmail.com>
Date:   Fri Dec 28 01:17:26 2018 +0100

    fix typo "resulution"

commit e23259d
Author: garenchan <1412950785@qq.com>
Date:   Wed Dec 26 09:58:35 2018 +0800

    fix typo: segfauls -> segfault

commit a9359f8
Author: xjp <jianping_xie@aliyun.com>
Date:   Tue Dec 18 17:31:44 2018 +0800

    Fixed REDISMODULE_H spell bug

commit a12c3e4
Author: jdiaz <jrd.palacios@gmail.com>
Date:   Sat Dec 15 23:39:52 2018 -0600

    Fixes hyperloglog hash function comment block description

commit 770eb11
Author: 林上耀 <1210tom@163.com>
Date:   Sun Nov 25 17:16:10 2018 +0800

    fix typo

commit fd97fbb
Author: Chris Lamb <chris@chris-lamb.co.uk>
Date:   Fri Nov 23 17:14:01 2018 +0100

    Correct "unsupported" typo.

commit a85522d
Author: Jungnam Lee <jungnam.lee@oracle.com>
Date:   Thu Nov 8 23:01:29 2018 +0900

    fix typo in test comments

commit ade8007
Author: Arun Kumar <palerdot@users.noreply.github.com>
Date:   Tue Oct 23 16:56:35 2018 +0530

    Fixed grammatical typo

    Fixed typo for word 'dictionary'

commit 869ee39
Author: Hamid Alaei <hamid.a85@gmail.com>
Date:   Sun Aug 12 16:40:02 2018 +0430

    fix documentations: (ThreadSafeContextStart/Stop -> ThreadSafeContextLock/Unlock), minor typo

commit f89d158
Author: Mayank Jain <mayankjain255@gmail.com>
Date:   Tue Jul 31 23:01:21 2018 +0530

    Updated README.md with some spelling corrections.

    Made correction in spelling of some misspelled words.

commit 892198e
Author: dsomeshwar <someshwar.dhayalan@gmail.com>
Date:   Sat Jul 21 23:23:04 2018 +0530

    typo fix

commit 8a4d780
Author: Itamar Haber <itamar@redislabs.com>
Date:   Mon Apr 30 02:06:52 2018 +0300

    Fixes some typos

commit e3acef6
Author: Noah Rosamilia <ivoahivoah@gmail.com>
Date:   Sat Mar 3 23:41:21 2018 -0500

    Fix typo in /deps/README.md

commit 04442fb
Author: WuYunlong <xzsyeb@126.com>
Date:   Sat Mar 3 10:32:42 2018 +0800

    Fix typo in readSyncBulkPayload() comment.

commit 9f36880
Author: WuYunlong <xzsyeb@126.com>
Date:   Sat Mar 3 10:20:37 2018 +0800

    replication.c comment: run_id -> replid.

commit f866b4a
Author: Francesco 'makevoid' Canessa <makevoid@gmail.com>
Date:   Thu Feb 22 22:01:56 2018 +0000

    fix comment typo in server.c

commit 0ebc69b
Author: 줍 <jubee0124@gmail.com>
Date:   Mon Feb 12 16:38:48 2018 +0900

    Fix typo in redis.conf

    Fix `five behaviors` to `eight behaviors` in [this sentence ](antirez/redis@unstable/redis.conf#L564)

commit b50a620
Author: martinbroadhurst <martinbroadhurst@users.noreply.github.com>
Date:   Thu Dec 28 12:07:30 2017 +0000

    Fix typo in valgrind.sup

commit 7d8f349
Author: Peter Boughton <peter@sorcerersisle.com>
Date:   Mon Nov 27 19:52:19 2017 +0000

    Update CONTRIBUTING; refer doc updates to redis-doc repo.

commit 02dec7e
Author: Klauswk <klauswk1@hotmail.com>
Date:   Tue Oct 24 16:18:38 2017 -0200

    Fix typo in comment

commit e1efbc8
Author: chenshi <baiwfg2@gmail.com>
Date:   Tue Oct 3 18:26:30 2017 +0800

    Correct two spelling errors of comments

commit 93327d8
Author: spacewander <spacewanderlzx@gmail.com>
Date:   Wed Sep 13 16:47:24 2017 +0800

    Update the comment for OBJ_ENCODING_EMBSTR_SIZE_LIMIT's value

    The value of OBJ_ENCODING_EMBSTR_SIZE_LIMIT is 44 now instead of 39.

commit 63d361f
Author: spacewander <spacewanderlzx@gmail.com>
Date:   Tue Sep 12 15:06:42 2017 +0800

    Fix <prevlen> related doc in ziplist.c

    According to the definition of ZIP_BIG_PREVLEN and other related code,
    the guard of single byte <prevlen> should be 254 instead of 255.

commit ebe228d
Author: hanael80 <hanael80@gmail.com>
Date:   Tue Aug 15 09:09:40 2017 +0900

    Fix typo

commit 6b696e6
Author: Matt Robenolt <matt@ydekproductions.com>
Date:   Mon Aug 14 14:50:47 2017 -0700

    Fix typo in LATENCY DOCTOR output

commit a2ec6ae
Author: caosiyang <caosiyang@qiyi.com>
Date:   Tue Aug 15 14:15:16 2017 +0800

    Fix a typo: form => from

commit 3ab7699
Author: caosiyang <caosiyang@qiyi.com>
Date:   Thu Aug 10 18:40:33 2017 +0800

    Fix a typo: replicationFeedSlavesFromMaster() => replicationFeedSlavesFromMasterStream()

commit 72d43ef
Author: caosiyang <caosiyang@qiyi.com>
Date:   Tue Aug 8 15:57:25 2017 +0800

    fix a typo: servewr => server

commit 707c958
Author: Bo Cai <charpty@gmail.com>
Date:   Wed Jul 26 21:49:42 2017 +0800

    redis-cli.c typo: conut -> count.

    Signed-off-by: Bo Cai <charpty@gmail.com>

commit b9385b2
Author: JackDrogon <jack.xsuperman@gmail.com>
Date:   Fri Jun 30 14:22:31 2017 +0800

    Fix some spell problems

commit 20d9230
Author: akosel <aaronjkosel@gmail.com>
Date:   Sun Jun 4 19:35:13 2017 -0500

    Fix typo

commit b167bfc
Author: Krzysiek Witkowicz <krzysiekwitkowicz@gmail.com>
Date:   Mon May 22 21:32:27 2017 +0100

    Fix #4008 small typo in comment

commit 2b78ac8
Author: Jake Clarkson <jacobwclarkson@gmail.com>
Date:   Wed Apr 26 15:49:50 2017 +0100

    Correct typo in tests/unit/hyperloglog.tcl

commit b0f1cdb
Author: Qi Luo <qiluo-msft@users.noreply.github.com>
Date:   Wed Apr 19 14:25:18 2017 -0700

    Fix typo

commit a90b0f9
Author: charsyam <charsyam@naver.com>
Date:   Thu Mar 16 18:19:53 2017 +0900

    fix typos

    fix typos

    fix typos

commit 8430a79
Author: Richard Hart <richardhart92@gmail.com>
Date:   Mon Mar 13 22:17:41 2017 -0400

    Fixed log message typo in listenToPort.

commit 481a1c2
Author: Vinod Kumar <kumar003vinod@gmail.com>
Date:   Sun Jan 15 23:04:51 2017 +0530

    src/db.c: Correct "save" -> "safe" typo

commit 586b4d3
Author: wangshaonan <wshn13@gmail.com>
Date:   Wed Dec 21 20:28:27 2016 +0800

    Fix typo they->the in helloworld.c

commit c1c4b5e
Author: Jenner <hypxm@qq.com>
Date:   Mon Dec 19 16:39:46 2016 +0800

    typo error

commit 1ee1a3f
Author: tielei <43289893@qq.com>
Date:   Mon Jul 18 13:52:25 2016 +0800

    fix some comments

commit 11a41fb
Author: Otto Kekäläinen <otto@seravo.fi>
Date:   Sun Jul 3 10:23:55 2016 +0100

    Fix spelling in documentation and comments

commit 5fb5d82
Author: francischan <f1ancis621@gmail.com>
Date:   Tue Jun 28 00:19:33 2016 +0800

    Fix outdated comments about redis.c file.
    It should now refer to server.c file.

commit 6b254bc
Author: lmatt-bit <lmatt123n@gmail.com>
Date:   Thu Apr 21 21:45:58 2016 +0800

    Refine the comment of dictRehashMilliseconds func

SLAVECONF->REPLCONF in comment - by andyli029

commit ee9869f
Author: clark.kang <charsyam@naver.com>
Date:   Tue Mar 22 11:09:51 2016 +0900

    fix typos

commit f7b3b11
Author: Harisankar H <harisankarh@gmail.com>
Date:   Wed Mar 9 11:49:42 2016 +0530

    Typo correction: "faield" --> "failed"

    Typo correction: "faield" --> "failed"

commit 3fd40fc
Author: Itamar Haber <itamar@redislabs.com>
Date:   Thu Feb 25 10:31:51 2016 +0200

    Fixes a typo in comments

commit 621c160
Author: Prayag Verma <prayag.verma@gmail.com>
Date:   Mon Feb 1 12:36:20 2016 +0530

    Fix typo in Readme.md

    Spelling mistakes -
    `eviciton` > `eviction`
    `familar` > `familiar`

commit d7d07d6
Author: WonCheol Lee <toctoc21c@gmail.com>
Date:   Wed Dec 30 15:11:34 2015 +0900

    Typo fixed

commit a4dade7
Author: Felix Bünemann <buenemann@louis.info>
Date:   Mon Dec 28 11:02:55 2015 +0100

    [ci skip] Improve supervised upstart config docs

    This mentions that "expect stop" is required for supervised upstart
    to work correctly. See http://upstart.ubuntu.com/cookbook/#expect-stop
    for an explanation.

commit d9caba9
Author: daurnimator <quae@daurnimator.com>
Date:   Mon Dec 21 18:30:03 2015 +1100

    README: Remove trailing whitespace

commit 72d42e5
Author: daurnimator <quae@daurnimator.com>
Date:   Mon Dec 21 18:29:32 2015 +1100

    README: Fix typo. th => the

commit dd6e957
Author: daurnimator <quae@daurnimator.com>
Date:   Mon Dec 21 18:29:20 2015 +1100

    README: Fix typo. familar => familiar

commit 3a12b23
Author: daurnimator <quae@daurnimator.com>
Date:   Mon Dec 21 18:28:54 2015 +1100

    README: Fix typo. eviciton => eviction

commit 2d1d03b
Author: daurnimator <quae@daurnimator.com>
Date:   Mon Dec 21 18:21:45 2015 +1100

    README: Fix typo. sever => server

commit 3973b06
Author: Itamar Haber <itamar@garantiadata.com>
Date:   Sat Dec 19 17:01:20 2015 +0200

    Typo fix

commit 4f2e460
Author: Steve Gao <fu@2token.com>
Date:   Fri Dec 4 10:22:05 2015 +0800

    Update README - fix typos

commit b21667c
Author: binyan <binbin.yan@nokia.com>
Date:   Wed Dec 2 22:48:37 2015 +0800

    delete redundancy color judge in sdscatcolor

commit 88894c7
Author: binyan <binbin.yan@nokia.com>
Date:   Wed Dec 2 22:14:42 2015 +0800

    the example output shoule be HelloWorld

commit 2763470
Author: binyan <binbin.yan@nokia.com>
Date:   Wed Dec 2 17:41:39 2015 +0800

    modify error word keyevente

    Signed-off-by: binyan <binbin.yan@nokia.com>

commit 0847b3d
Author: Bruno Martins <bscmartins@gmail.com>
Date:   Wed Nov 4 11:37:01 2015 +0000

    typo

commit bbb9e9e
Author: dawedawe <dawedawe@gmx.de>
Date:   Fri Mar 27 00:46:41 2015 +0100

    typo: zimap -> zipmap

commit 5ed297e
Author: Axel Advento <badwolf.bloodseeker.rev@gmail.com>
Date:   Tue Mar 3 15:58:29 2015 +0800

    Fix 'salve' typos to 'slave'

commit edec9d6
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date:   Wed Jun 12 14:12:47 2019 +0200

    Update README.md

    Co-Authored-By: Qix <Qix-@users.noreply.github.com>

commit 692a7af
Author: LudwikJaniuk <ludvig.janiuk@gmail.com>
Date:   Tue May 28 14:32:04 2019 +0200

    grammar

commit d962b0a
Author: Nick Frost <nickfrostatx@gmail.com>
Date:   Wed Jul 20 15:17:12 2016 -0700

    Minor grammar fix

commit 24fff01aaccaf5956973ada8c50ceb1462e211c6 (typos)
Author: Chad Miller <chadm@squareup.com>
Date:   Tue Sep 8 13:46:11 2020 -0400

    Fix faulty comment about operation of unlink()

commit 3cd5c1f3326c52aa552ada7ec797c6bb16452355
Author: Kevin <kevin.xgr@gmail.com>
Date:   Wed Nov 20 00:13:50 2019 +0800

    Fix typo in server.c.

From a83af59 Mon Sep 17 00:00:00 2001
From: wuwo <wuwo@wacai.com>
Date: Fri, 17 Mar 2017 20:37:45 +0800
Subject: [PATCH] falure to failure

From c961896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B7=A6=E6=87=B6?= <veficos@gmail.com>
Date: Sat, 27 May 2017 15:33:04 +0800
Subject: [PATCH] fix typo

From e600ef2 Mon Sep 17 00:00:00 2001
From: "rui.zou" <rui.zou@yunify.com>
Date: Sat, 30 Sep 2017 12:38:15 +0800
Subject: [PATCH] fix a typo

From c7d07fa Mon Sep 17 00:00:00 2001
From: Alexandre Perrin <alex@kaworu.ch>
Date: Thu, 16 Aug 2018 10:35:31 +0200
Subject: [PATCH] deps README.md typo

From b25cb67 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 10:55:37 +0300
Subject: [PATCH 1/2] fix typos in header

From ad28ca6 Mon Sep 17 00:00:00 2001
From: Guy Korland <gkorland@gmail.com>
Date: Wed, 26 Sep 2018 11:02:36 +0300
Subject: [PATCH 2/2] fix typos

commit 34924cdedd8552466fc22c1168d49236cb7ee915
Author: Adrian Lynch <adi_ady_ade@hotmail.com>
Date:   Sat Apr 4 21:59:15 2015 +0100

    Typos fixed

commit fd2a1e7
Author: Jan <jsteemann@users.noreply.github.com>
Date:   Sat Oct 27 19:13:01 2018 +0200

    Fix typos

    Fix typos

commit e14e47c1a234b53b0e103c5f6a1c61481cbcbb02
Author: Andy Lester <andy@petdance.com>
Date:   Fri Aug 2 22:30:07 2019 -0500

    Fix multiple misspellings of "following"

commit 79b948ce2dac6b453fe80995abbcaac04c213d5a
Author: Andy Lester <andy@petdance.com>
Date:   Fri Aug 2 22:24:28 2019 -0500

    Fix misspelling of create-cluster

commit 1fffde52666dc99ab35efbd31071a4c008cb5a71
Author: Andy Lester <andy@petdance.com>
Date:   Wed Jul 31 17:57:56 2019 -0500

    Fix typos

commit 204c9ba9651e9e05fd73936b452b9a30be456cfe
Author: Xiaobo Zhu <xiaobo.zhu@shopee.com>
Date:   Tue Aug 13 22:19:25 2019 +0800

    fix typos

Squashed commit of the following:

commit 1d9aaf8
Author: danmedani <danmedani@gmail.com>
Date:   Sun Aug 2 11:40:26 2015 -0700

README typo fix.

Squashed commit of the following:

commit 32bfa7c
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date:   Mon Jul 6 21:15:08 2015 +0200

Fixed grammer

Squashed commit of the following:

commit b24f69c
Author: Sisir Koppaka <sisir.koppaka@gmail.com>
Date:   Mon Mar 2 22:38:45 2015 -0500

utils/hashtable/rehashing.c: Fix typos

Squashed commit of the following:

commit 4e04082
Author: Erik Dubbelboer <erik@dubbelboer.com>
Date:   Mon Mar 23 08:22:21 2015 +0000

Small config file documentation improvements

Squashed commit of the following:

commit acb8773
Author: ctd1500 <ctd1500@gmail.com>
Date:   Fri May 8 01:52:48 2015 -0700

Typo and grammar fixes in readme

commit 2eb75b6
Author: ctd1500 <ctd1500@gmail.com>
Date:   Fri May 8 01:36:18 2015 -0700

fixed redis.conf comment

Squashed commit of the following:

commit a8249a2
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Date:   Fri Dec 11 11:39:52 2015 +0530

Revise correction of typos.

Squashed commit of the following:

commit 3c02028
Author: zhaojun11 <zhaojun11@jd.com>
Date:   Wed Jan 17 19:05:28 2018 +0800

Fix typos include two code typos in cluster.c and latency.c

Squashed commit of the following:

commit 9dba47c
Author: q191201771 <191201771@qq.com>
Date:   Sat Jan 4 11:31:04 2020 +0800

fix function listCreate comment in adlist.c

Update src/server.c

commit 2c7c2cb536e78dd211b1ac6f7bda00f0f54faaeb
Author: charpty <charpty@gmail.com>
Date:   Tue May 1 23:16:59 2018 +0800

    server.c typo: modules system dictionary type comment

    Signed-off-by: charpty <charpty@gmail.com>

commit a8395323fb63cb59cb3591cb0f0c8edb7c29a680
Author: Itamar Haber <itamar@redislabs.com>
Date:   Sun May 6 00:25:18 2018 +0300

    Updates test_helper.tcl's help with undocumented options

    Specifically:

    * Host
    * Port
    * Client

commit bde6f9ced15755cd6407b4af7d601b030f36d60b
Author: wxisme <850885154@qq.com>
Date:   Wed Aug 8 15:19:19 2018 +0800

    fix comments in deps files

commit 3172474ba991532ab799ee1873439f3402412331
Author: wxisme <850885154@qq.com>
Date:   Wed Aug 8 14:33:49 2018 +0800

    fix some comments

commit 01b6f2b6858b5cf2ce4ad5092d2c746e755f53f0
Author: Thor Juhasz <thor@juhasz.pro>
Date:   Sun Nov 18 14:37:41 2018 +0100

    Minor fixes to comments

    Found some parts a little unclear on a first read, which prompted me to have a better look at the file and fix some minor things I noticed.
    Fixing minor typos and grammar. There are no changes to configuration options.
    These changes are only meant to help the user better understand the explanations to the various configuration options

(cherry picked from commit 285ef446b0)
2020-10-27 09:12:01 +02:00
John Sully 67003ec714 Disarm not release D'oh
Former-commit-id: 3e33fbcd35
2020-10-27 06:41:33 +00:00
John Sully c3ef2f00bb Active replica test reliability enhancements
Former-commit-id: 444555d3e4
2020-10-27 06:23:14 +00:00
John Sully 2ae013910b Prevent crashes on shutdown due to lock being held
Former-commit-id: 6a74f524e5
2020-10-27 04:53:19 +00:00
John Sully 366ef70f6e Ensure MVCC timestamp is incremented after the real time is updated
Former-commit-id: 9c5b59ac01
2020-10-27 04:52:35 +00:00
John Sully a3323d2b5b Fix multithreaded test failure
Former-commit-id: 1840601f8e
2020-10-27 01:54:13 +00:00
John Sully 418b6206ea Avoid unnecessary memory fences
Former-commit-id: 88962af8b2
2020-10-26 02:28:38 +00:00
John Sully 19a4d2d358 Remove addReply*Async methods since we already know if its async or not. This is just a source of bugs
Former-commit-id: df22cdf6e9
2020-10-24 02:18:03 +00:00
John Sully 7a9fbad132 Allow the locker to be used even without a client
Former-commit-id: 041446005b
2020-10-23 20:21:49 +00:00
John Sully 0691608ba0 Fix multithread test failures
Former-commit-id: 7c39a9b0e1
2020-10-23 15:57:39 +00:00
John Sully 5fb0c880a8 Remove leak warning with ASAN in the CLI
Former-commit-id: 05cd92f766
2020-10-21 21:16:08 +00:00
John Sully 4c4a8da208 run when necessary
Former-commit-id: d724e7226c
2020-10-16 07:00:03 +00:00
John Sully 91388bd42d Fix replica buffer overflows
Former-commit-id: 738c782f02
2020-10-16 06:47:40 +00:00
John Sully 9c65bd8f3d Avoid locking if we won't run a time event
Former-commit-id: 33b05c859a
2020-10-16 06:19:52 +00:00
John Sully 85492ccee8 Reduce async write copies
Former-commit-id: ed369d7223
2020-10-15 23:10:17 +00:00
John Sully 654379bd0c Fix branding
Former-commit-id: fb32bb12b1
2020-10-15 20:15:35 +00:00
John Sully f275456439 Relax memory order where possible
Former-commit-id: 3e996035ea
2020-10-13 06:35:16 +00:00
John Sully 8c33983e57 Significantly improve perf in replication scenarios
Former-commit-id: ae8a94d615
2020-10-12 15:27:03 +00:00
John Sully 6496ea5145 Avoid excess locking, seeing up to 8% performance improvements
Former-commit-id: 69a74a567b
2020-10-12 05:50:58 +00:00
John Sully 6de6515bfc Perf: remove unnecessary vector operations
Former-commit-id: 1b46d4f09a
2020-10-12 04:28:39 +00:00
John Sully 27e17220c2 Remove dead code
Former-commit-id: c6f13892e0
2020-10-09 21:02:09 +00:00
Hanif Bin Ariffin b238eca1ce Fixed non-empty check in src/Makefile
Per [GNU Make Manual](https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html).
To properly check for non-empty variable, one must strip whitespaces.

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Former-commit-id: 05e0f32345
2020-10-05 10:58:49 -04:00
Hanif Bin Ariffin 4b63a5202b Removed dead code from a macro in zmalloc.cpp
I think the compiler would have removed this no-op anyways but it
definitely wasted me some 30 minutes on this :(

I was hoping I could remove the branch through some bit-hacking but
apparently its dead code :). Oh well, its 30 minutes of refreshing
bit hacking.

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>

Former-commit-id: 8171e6de13
2020-10-03 20:41:26 -04:00
John Sully 9d8897c50e Delete CONTRIBUTING
Former-commit-id: b042495f37
2020-10-01 11:17:56 -04:00
John Sully 04f834037a Fix module test failures due to locking
Former-commit-id: 420ccdfbae
2020-10-01 00:08:54 +00:00
John Sully 3529a1564b Fix TLS test failure due to bad merge
Former-commit-id: 41466a4147
2020-09-30 20:21:40 +00:00
John Sully 13d472b160 Keep redis-cli.c C89 compatible
Former-commit-id: 9798f2d711
2020-09-30 20:17:51 +00:00
John Sully 5fd3c39c05 Mac build break fix
Former-commit-id: 5f3543921b
2020-09-30 20:17:02 +00:00
John Sully 6448de4461 Fix stream replication failure with active replication, issue #238
Former-commit-id: a41366cc3a
2020-09-30 20:12:54 +00:00
John Sully 14daf6f909 Merge tag '6.0.8' into unstable
Former-commit-id: 4c7e4b91a6
2020-09-30 19:47:55 +00:00
John Sully c0df1ac173 Test RDB merge on load with active replication
Former-commit-id: 28183f4b66
2020-09-29 03:26:06 +00:00
Ben Schermel a0ca031b8c update deb changelog
Former-commit-id: 63c47a09e9
2020-09-28 23:42:54 +00:00
Ben Schermel f338a3024b update deb changelog
Former-commit-id: 087af94c22
2020-09-28 20:51:31 +00:00
John Sully 3fbb5b5efa Drop min-clients-per-thread to a more reasonable number
Former-commit-id: bf3a3225fc
2020-09-28 19:19:47 +00:00
John Sully 59e86a111b Drop min-clients-per-thread to a more reasonable number
Former-commit-id: a0abc1eddd
2020-09-28 19:17:36 +00:00
John Sully bdd58afb8f bump version 6.0.16
Former-commit-id: dab9296d7c
2020-09-28 19:14:17 +00:00
John Sully 0f9bb23dc5 Merge branch 'unstable' into RELEASE_6
Former-commit-id: a6f5a391a1
2020-09-28 18:55:24 +00:00
John Sully cb6bc67a87 Merge branch 'unstable' into keydbpro
Former-commit-id: d1986d9fcdfd56f2c30ee95edef6d5260e0aa777
2020-09-24 22:02:30 +00:00
John Sully c373c2b652 Support read only replicas attaching to active replicas (Bug #229)
Former-commit-id: 676644f2db
2020-09-23 04:16:08 +00:00
John Sully 28fdf8d7d4 Active replicas memory leak
Former-commit-id: 22ac56d62d
2020-09-22 21:38:35 +00:00
John Sully 18a3e0ba35 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 143f7f634d
2020-09-21 04:42:46 +00:00
Dmitry Dorofeev a830b2fdbf Fix to support FreeBSD pthread_getthreadid_np call
Former-commit-id: 955faef23a
2020-09-21 00:41:41 -04:00
John Sully b81dee212a Fix TSAN errors in fastlock
Former-commit-id: 2e159e6ea3
2020-09-21 03:26:50 +00:00
John Sully 3b66147997 Fix issue #222
Former-commit-id: 02b533fec3
2020-09-21 01:09:58 +00:00
John Sully d38583454c Make multimaster replication info statelessly paresable
Former-commit-id: de3099e6d8
2020-09-20 23:57:06 +00:00
John Sully 17648d9705 Dramatically improve the performance of subkey expires
Former-commit-id: 368f67f422
2020-09-20 23:30:21 +00:00
John Sully fb53b5630c Reduce test noise
Former-commit-id: 13c9a094d1
2020-09-19 22:00:17 +00:00
John Sully 2f1a99efa5 Fix CI failure due to apt host changes
Former-commit-id: 0f8b7a19ef
2020-09-19 21:49:59 +00:00
John Sully bf6569afb3 Avoid memory overhead in situations it won't be used (active rep only)
Former-commit-id: 8f7d977f90
2020-09-19 21:44:59 +00:00
John Sully ced0413189 Update endurance test for ubuntu 20
Former-commit-id: 064440ee84
2020-09-17 02:10:18 +00:00
John Sully ec72a9451e Fix build break
Former-commit-id: 50641d0569
2020-09-17 00:53:56 +00:00
John Sully 17592f1da3 master_global_link_status should respect the quorum
Former-commit-id: f5ecc77e29
2020-09-17 00:31:10 +00:00
John Sully de3769b3ee Allow reads during an active replica load, optionally allow writes as an experimental feature
Former-commit-id: 655bb6e21c
2020-09-17 00:13:03 +00:00
John Sully e125742671 Implement replica-quorum config
Former-commit-id: ab4cdd2ed4
2020-09-16 03:26:31 +00:00
Yossi Gottlieb 3d111508a1 TLS: Session caching configuration support. (#7420)
* TLS: Session caching configuration support.
* TLS: Remove redundant config initialization.


Former-commit-id: d3834c5069
2020-09-16 02:10:29 +00:00
John Sully dc9b75314b Protocol error in client command
Former-commit-id: 7a1b2c58c3
2020-09-11 20:48:18 +00:00
John Sully 4a3e312551 Fix more protocol errors
Former-commit-id: 7fc6d6c6b1
2020-09-11 20:47:27 +00:00
John Sully caac3d12f9 Fix protocol difference with Redis
Former-commit-id: dec5db4e71
2020-09-11 20:08:26 +00:00
Oran Agra 40f2c892e5 6.0.8 2020-09-10 14:09:00 +03:00
Oran Agra e4a7840d34 Fix RESP3 response for HKEYS/HVALS on non-existing key 2020-09-10 14:09:00 +03:00
Oran Agra 4de93718a7 Fix leak in new blockedclient module API test
(cherry picked from commit 0e20ad14a6a857cb168b808f94721df19b23dc0c)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb d3945c636d Tests: fix oom-score-adj false positives. (#7772)
The key save delay is too short and on certain systems the child process
is gone before we have a chance to inspect it.

(cherry picked from commit 1abc94155a)
2020-09-10 14:09:00 +03:00
杨博东 d12e141780 Tests: Add aclfile load and save tests (#7765)
improves test coverage

(cherry picked from commit ce14668316)
2020-09-10 14:09:00 +03:00
Roi Lipman ee3e45ac6e RM_ThreadSafeContextTryLock a non-blocking method for acquiring GIL (#7738)
Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit b1de173ec0)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb 8fb8c23746 Tests: validate CONFIG REWRITE for all params. (#7764)
This is a catch-all test to confirm that that rewrite produces a valid
output for all parameters and that this process does not introduce
undesired configuration changes.

(cherry picked from commit 995f1fc53f)
2020-09-10 14:09:00 +03:00
Oran Agra de8c720c74 Change THP warning to use madvise rather than never (#7771)
completes 60097d361d

(cherry picked from commit 73e0cd5a7d)
2020-09-10 14:09:00 +03:00
Itamar Haber dc11921961 Documents RM_Call's fmt (#5448)
Improve RM_Call inline documentation about the fmt argument
so that we don't completely depend on the web docs.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit c13fa0aa36)
2020-09-10 14:09:00 +03:00
Jan-Erik Rediger b8dec46e0b Check that THP is not set to always (madvise is ok) (#4001)
THP can also be set to madvise, in which case it shouldn't cause
problems for Redis since redis (or the allocator) doesn't use madvise
to activate it.

(cherry picked from commit 60097d361d)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb 82aee21c92 Tests: clean up stale .cli files. (#7768)
(cherry picked from commit e5b1ad413b)
2020-09-10 14:09:00 +03:00
Eran Liberty 7fa69e6394 Allow exec with read commands on readonly replica in cluster (#7766)
There was a bug. Although cluster replicas would allow read commands,
they would not allow a MULTI-EXEC that's composed solely of read commands.
Adds tests for coverage.

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: Eran Liberty <eranl@amazon.com>
(cherry picked from commit 7bee51bb5b)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb aa54351c5b Fix CONFIG REWRITE of oom-score-adj-values. (#7761)
(cherry picked from commit b3782098ae)
2020-09-10 14:09:00 +03:00
Oran Agra 826b49bcb4 handle cur_test for nested tests
if there are nested tests and nested servers, we need to restore the
previous value of cur_test when a test exist.

example:
```
test{test 1} {
	start_server {
		test{test 1.1 - master only} {
		}
		start_server {
		    test{test 1.2 - with replication} {
            }
		}
	}
}
```
when `test 1.1 - master only exists`, we're still inside `test 1`

(cherry picked from commit 610b4ff16a)
2020-09-10 14:09:00 +03:00
Oran Agra 25efadabbe Add daily CI for MacOS (#7759)
(cherry picked from commit 1701f23b1f)
2020-09-10 14:09:00 +03:00
bodong.ybd cb4f96657b Tests: Some fixes for macOS
1) cur_test: when restart_server, "no such variable" error occurs
  ./runtest --single integration/rdb
  test {client freed during loading}
      SET ::cur_test
      restart_server
        kill_server
          test "Check for memory leaks (pid $pid)"
          SET ::cur_test
          UNSET ::cur_test
      UNSET ::cur_test // This global variable has been unset.

2) `ps --ppid` not available on macOS platform, can be replaced with
`pgrep -P pid`.

(cherry picked from commit e90385e223)
2020-09-10 14:09:00 +03:00
Oran Agra 95966ceb24 Fix cluster consistency-check test (#7754)
This test was failing from time to time see discussion at the bottom of #7635
This was probably due to timing, the DEBUG SLEEP executed by redis-cli
didn't sleep for enough time.

This commit changes:
1) use SET-ACTIVE-EXPIRE instead of DEBUG SLEEP
2) reduce many `after` sleeps with retry loops to speed up the test.
3) add many comment explaining the different steps of the test and
   it's purpose.
4) config appendonly before populating the volatile keys, so that they'll
   be part of the AOF command stream rather than the preamble RDB portion.

other complications: recently kill_instance switched from SIGKILL to
SIGTERM, and this would sometimes fail since there was an AOFRW running
in the background. now we wait for it to end before attempting the kill.

(cherry picked from commit 541d2709a0)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb 9275c8b990 Tests: fix unmonitored servers. (#7756)
There is an inherent race condition in port allocation for spawned
servers. If a server fails to start because a port is taken, a new port
is allocated. This fixes a problem where the logs are not truncated and
as a result a large number of unmonitored servers are started.

(cherry picked from commit 871e85b8a7)
2020-09-10 14:09:00 +03:00
Oran Agra d37b034321 fix broken cluster/sentinel tests by recent commit (#7752)
da723a917 added a file for stderr to keep valgrind log but i forgot to
add a similar thing when valgrind isn't being used.
the result is that `glob */err.txt` fails.

(cherry picked from commit 470de9a516)
2020-09-10 14:09:00 +03:00
Oran Agra 540841d6f7 Improve valgrind support for cluster tests (#7725)
- redirect valgrind reports to a dedicated file rather than console
- try to avoid killing instances with SIGKILL so that we get the memory
  leak report (killing with SIGTERM before resorting to SIGKILL)
- search for valgrind reports when done, print them and fail the tests
- add --dont-clean option to keep the logs on exit
- fix exit error code when crash is found (would have exited with 0)

changes that affect the normal redis test suite:
- refactor check_valgrind_errors into two functions one to search and
  one to report
- move the search half into util.tcl to serve the cluster tests too
- ignore "address range perms" valgrind warnings which seem non relevant.

(cherry picked from commit da723a917d)
2020-09-10 14:09:00 +03:00
Oran Agra 81476c0cf7 test infra - add durable mode to work around test suite crashing
in some cases a command that returns an error possibly due to a timing
issue causes the tcl code to crash and thus prevents the rest of the
tests from running. this adds an option to make the test proceed despite
the crash.
maybe it should be the default mode some day.

(cherry picked from commit cf22e8eb91)
2020-09-10 14:09:00 +03:00
Oran Agra e001152825 test infra - wait_done_loading
reduce code duplication in aof.tcl.
move creation of clients into the test so that it can be skipped

(cherry picked from commit cc455a710c)
2020-09-10 14:09:00 +03:00
Oran Agra f180326b65 test infra - flushall between tests in external mode
(cherry picked from commit 2468c17a32)
2020-09-10 14:09:00 +03:00
Oran Agra 575d07b7a8 test infra - improve test skipping ability
- skip full units
- skip a single test (not just a list of tests)
- when skipping tag, skip spinning up servers, not just the tests
- skip tags when running against an external server too
- allow using multiple tags (split them)

(cherry picked from commit 5c61f1a6ed)
2020-09-10 14:09:00 +03:00
Oran Agra 7d3cec9686 test infra - reduce disk space usage
this is important when running a test with --loop

(cherry picked from commit fc18f16260)
2020-09-10 14:09:00 +03:00
Oran Agra 60bec0c20c test infra - write test name to logfile
(cherry picked from commit e783c03dd1)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb e5db52f19f redis-cli: fix writeConn() buffer handling. (#7749)
Fix issues with writeConn() which resulted with corruption of the stream by leaving an extra byte in the buffer. The trigger for this is partial writes or write errors which were not experienced on Linux but reported on macOS.

(cherry picked from commit 94cd74e5de)
2020-09-10 14:09:00 +03:00
Oran Agra 894016c396 Print server startup messages after daemonization (#7743)
When redis isn't configured to have a log file, having these prints
before damonization puts them in the calling process stdout rather than
/dev/null

(cherry picked from commit 0db61f5649)
2020-09-10 14:09:00 +03:00
Thandayuthapani f8d0d902a5 Add masters/replicas options to redis-cli --cluster call command (#6491)
* Add master/slave option in --cluster call command

* Update src/redis-cli.c

* Update src/redis-cli.c

Co-authored-by: Itamar Haber <itamar@redislabs.com>
(cherry picked from commit 5352220639)
2020-09-10 14:09:00 +03:00
Oran Agra 9f60eb0a3e fix README about BUILD_WITH_SYSTEMD usage (#7739)
BUILD_WITH_SYSTEMD is an internal variable. Users should use USE_SYSTEMD=yes.

(cherry picked from commit 9b61917d7f)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb 7aa207ad2c Fix double-make issue with make && make install. (#7734)
All user-supplied variables that affect the build should be explicitly
persisted.

Fixes #7254

(cherry picked from commit d377b116ba)
2020-09-10 14:09:00 +03:00
John Sully ac42f938e8 Fix whitespace
Former-commit-id: d47aeb1fc8
2020-09-07 03:35:46 +00:00
John Sully 1c1b114555 Dramatically improve perf by blocking commands
Former-commit-id: e47584b286
2020-09-07 00:49:53 +00:00
Oran Agra 6e7733c276 Redis 6.0.7 2020-09-01 09:27:58 +03:00
Oran Agra 6041fc99b5 Reduce the probability of failure when start redis in runtest-cluster #7554 (#7635)
When runtest-cluster, at first, we need to create a cluster use spawn_instance,
a port which is not used is choosen, however sometimes we can't run server on
the port. possibley due to a race with another process taking it first.
such as redis/redis/runs/896537490. It may be due to the machine problem or
In order to reduce the probability of failure when start redis in
runtest-cluster, we attemp to use another port when find server do not start up.

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: yanhui13 <yanhui13@meituan.com>
(cherry picked from commit 1deaad884c)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb f2ab7ac5d7 Backport Lua 5.2.2 stack overflow fix. (#7733)
This fixes the issue described in CVE-2014-5461. At this time we cannot
confirm that the original issue has a real impact on Redis, but it is
included as an extra safety measure.

(cherry picked from commit 374270d3a0)
2020-09-01 09:27:58 +03:00
Leoš Literák 6c68ac1d4c Update README.md with instructions how to build with systemd support (#7730)
#7728 - update instructions for systemd support

(cherry picked from commit 635d6ca639)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb ba1da77a3d Fix oom-score-adj on older distros. (#7724)
Don't assume `ps` handles `-h` to display output without headers and
manually trim headers line from output.

(cherry picked from commit ae8420298c)
2020-09-01 09:27:58 +03:00
Wang Yuan a399ca9bf7 Fix wrong format specifiers of 'sdscatfmt' for the INFO command (#7706)
unlike printf, sdscatfmt doesn't take %d

(cherry picked from commit 48a00e6b99)
2020-09-01 09:27:58 +03:00
Wen Hui edcc2032e4 fix make warnings (#7692)
(cherry picked from commit 7386b998e8)
2020-09-01 09:27:58 +03:00
Nathan Scott 7b04660be7 Annotate module API functions in redismodule.h for use with -fno-common (#6900)
In order to keep the redismodule.h self-contained but still usable with
gcc v10 and later, annotate each API function tentative definition with
the __common__ attribute.  This avoids the 'multiple definition' errors
modules will otherwise see for all API functions at link time.

Further details at gcc.gnu.org/gcc-10/porting_to.html

Turn the existing __attribute__ ((unused)), ((__common__)) and ((print))
annotations into conditional macros for any compilers not accepting this
syntax.  These macros only expand to API annotations under gcc.

Provide a pre- and post- macro for every API function, so that they can
be defined differently by the file that includes redismodule.h.

Removing REDISMODULE_API_FUNC in the interest of keeping the function
declarations readable.

Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 9d4736b044)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb f0e28abc07 Add oom-score-adj configuration option to control Linux OOM killer. (#1690)
Add Linux kernel OOM killer control option.

This adds the ability to control the Linux OOM killer oom_score_adj
parameter for all Redis processes, depending on the process role (i.e.
master, replica, background child).

A oom-score-adj global boolean flag control this feature. In addition,
specific values can be configured using oom-score-adj-values if
additional tuning is required.

(cherry picked from commit 70c823a64e)
2020-09-01 09:27:58 +03:00
Meir Shpilraien (Spielrein) 63e3f1e449 see #7544, added RedisModule_HoldString api. (#7577)
Added RedisModule_HoldString that either returns a
shallow copy of the given String (by increasing
the String ref count) or a new deep copy of String
in case its not possible to get a shallow copy.

Co-authored-by: Itamar Haber <itamar@redislabs.com>
(cherry picked from commit 4f99b22118)
2020-09-01 09:27:58 +03:00
ShooterIT d8ddc73796 [Redis-benchmark] Remove zrem test, add zpopmin test
(cherry picked from commit 8925fac395)
2020-09-01 09:27:58 +03:00
ShooterIT e7ce996d8c [Redis-benchmark] Support zset type
(cherry picked from commit e6c811cd85)
2020-09-01 09:27:58 +03:00
Arun Ranganathan 57c6b0e718 Show threading configuration in INFO output (#7446)
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 444b53e640)
2020-09-01 09:27:58 +03:00
Meir Shpilraien (Spielrein) f63e428e5b This PR introduces a new loaded keyspace event (#7536)
Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: Itamar Haber <itamar@redislabs.com>
(cherry picked from commit 73198c5019)
2020-09-01 09:27:58 +03:00
Oran Agra 888cbf6822 Fix rejectCommand trims newline in shared error objects, hung clients (#7714)
fe8d6fe74 (released in 6.0.6) has a side effect, when processCommand
rejects a command with pre-made shared object error string, it trims the
newlines from the end of the string. if that string is later used with
addReply, the newline will be missing, breaking the protocol, and
leaving the client hung.

It seems that the only scenario which this happens is when replying with
-LOADING to some command, and later using that reply from the CONFIG
SET command (still during loading). this will result in hung client.

Refactoring the code in order to avoid trimming these newlines from
shared string objects, and do the newline trimming only in other cases
where it's needed.

Co-authored-by: Guy Benoish <guy.benoish@redislabs.com>
(cherry picked from commit 2640897e3a)
2020-09-01 09:27:58 +03:00
valentinogeron 3c136a7777 EXEC with only read commands should not be rejected when OOM (#7696)
If the server gets MULTI command followed by only read
commands, and right before it gets the EXEC it reaches OOM,
the client will get OOM response.

So, from now on, it will get OOM response only if there was
at least one command that was tagged with `use-memory` flag

(cherry picked from commit 0292720ccb)
2020-09-01 09:27:58 +03:00
Itamar Haber c77e8e2f1c Expands lazyfree's effort estimate to include Streams (#5794)
Otherwise, it is treated as a single allocation and freed synchronously. The following logic is used for estimating the effort in constant-ish time complexity:

1. Check the number of nodes.
1. Add an allocation for each consumer group registered inside the stream.
1. Check the number of PELs in the first CG, and then add this count times the number of CGs.
1. Check the number of consumers in the first CG, and then add this count times the number of CGs.

(cherry picked from commit cb504d7fdd)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb fe6da3c36b Add language servers stuff, test/tls to gitignore. (#7698)
(cherry picked from commit 74d9d95449)
2020-09-01 09:27:58 +03:00
Valentino Geron d727f52723 Assert that setDeferredAggregateLen isn't called with negative value
In case the redis is about to return broken reply we want to crash
with assert so that we are notified about the bug. see #7687.

(cherry picked from commit 7e6c9ef881)
2020-09-01 09:27:58 +03:00
Valentino Geron 34124fff88 Fix LPOS command when RANK is greater than matches
When calling to LPOS command when RANK is higher than matches,
the return value is non valid response. For example:
```
LPUSH l a
:1
LPOS l b RANK 5 COUNT 10
*-4
```
It may break client-side parser.

Now, we count how many replies were replied in the array.
```
LPUSH l a
:1
LPOS l b RANK 5 COUNT 10
*0
```

(cherry picked from commit 7a555da64f)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb c5675c66bc Tests: fix redis-cli with remote hosts. (#7693)
(cherry picked from commit 257f9f462f)
2020-09-01 09:27:58 +03:00
huangzhw 907b0124e8 RedisModuleEvent_LoadingProgress always at 100% progress (#7685)
It was also using the wrong struct, but luckily RedisModuleFlushInfo and RedisModuleLoadingProgress
are identical.

(cherry picked from commit b980e99929)
2020-09-01 09:27:58 +03:00
guybe7 d0b8583167 Modules: Invalidate saved_oparray after use (#7688)
We wanna avoid a chance of someone using the pointer in it after it'll be freed / realloced.

(cherry picked from commit 4de17eb032)
2020-09-01 09:27:58 +03:00
杨博东 b42976bd56 Fix flock cluster config may cause failure to restart after kill -9 (#7674)
After fork, the child process(redis-aof-rewrite) will get the fd opened
by the parent process(redis), when redis killed by kill -9, it will not
graceful exit(call prepareForShutdown()), so redis-aof-rewrite thread may still
alive, the fd(lock) will still be held by redis-aof-rewrite thread, and
redis restart will fail to get lock, means fail to start.

This issue was causing failures in the cluster tests in github actions.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 5e6212e087)
2020-09-01 09:27:58 +03:00
Raghav Muddur 3564aab1a5 Update clusterMsgDataPublish to clusterMsgModule (#7682)
Correcting the variable to clusterMsgModule.

(cherry picked from commit f7cf24b5da)
2020-09-01 09:27:58 +03:00
Madelyn Olson f80b756076 Fixed hset error since it's shared with hmset (#7678)
(cherry picked from commit 17c6b3c7ee)
2020-09-01 09:27:58 +03:00
guybe7 d74a98eaac PERSIST should signalModifiedKey (Like EXPIRE does) (#7671)
(cherry picked from commit 64cceb12ad)
2020-09-01 09:27:58 +03:00
Oran Agra 299c092077 OOM Crash log include size of allocation attempt. (#7670)
Since users often post just the crash log in github issues, the log
print that's above it is missing.
No reason not to include the size in the panic message itself.

(cherry picked from commit 1b5cc94836)
2020-09-01 09:27:58 +03:00
Wen Hui 3e11f9d967 [module] using predefined REDISMODULE_NO_EXPIRE in RM_GetExpire (#7669)
It was already defined in the API header and the documentation, but not used by the implementation.

(cherry picked from commit b7236f0002)
2020-09-01 09:27:58 +03:00
Oran Agra b091e0059d Trim trailing spaces in error replies coming from rejectCommand (#7668)
fe8d6fe749 added rejectCommand which takes an robj reply and passes it
through addReplyErrorSafe to addReplyErrorLength.
The robj contains newline at it's end, but addReplyErrorSafe converts it
to spaces, and passes it to addReplyErrorLength which adds the protocol
newlines.

The result was that most error replies (like OOM) had extra two trailing
spaces in them.

(cherry picked from commit 05a4af3464)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb d13c44583c Module API: fix missing RM_CLIENTINFO_FLAG_SSL. (#7666)
The `REDISMODULE_CLIENTINFO_FLAG_SSL` flag was already a part of the `RedisModuleClientInfo` structure but was not implemented.

(cherry picked from commit 2ec11f941a)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb 3ed7d0af20 TLS: relax verification on CONFIG SET. (#7665)
Avoid re-configuring (and validating) SSL/TLS configuration on `CONFIG
SET` when TLS is not actively enabled for incoming connections, cluster
bus or replication.

This fixes failures when tests run without `--tls` on binaries that were
built with TLS support.

An additional benefit is that it's now possible to perform a multi-step
configuration process while TLS is disabled. The new configuration will
be verified and applied only when TLS is effectively enabled.

(cherry picked from commit 24efd22e89)
2020-09-01 09:27:58 +03:00
Madelyn Olson e0f6c0de33 Fixed timer warning (#5953)
(cherry picked from commit 46ce35c55e)
2020-09-01 09:27:58 +03:00
Wagner Francisco Mezaroba 4772370a87 allow --pattern to be used along with --bigkeys (#3586)
Adds --pattern option to cli's --bigkeys, --hotkeys & --scan modes

(cherry picked from commit 3ec7f8e915)
2020-09-01 09:27:58 +03:00
zhaozhao.zz a42e7f6876 redis-benchmark: fix wrong random key for hset (#4895)
(cherry picked from commit b1a242b84a)
2020-09-01 09:27:58 +03:00
zhaozhao.zz f573b23187 CLIENT_MASTER should ignore server.proto_max_bulk_len
(cherry picked from commit 0061dbba04)
2020-09-01 09:27:58 +03:00
zhaozhao.zz f0f4ef4423 config: proto-max-bulk-len must be 1mb or greater
(cherry picked from commit 46323cec56)
2020-09-01 09:27:58 +03:00
zhaozhao.zz 0d78615532 using proto-max-bulk-len in checkStringLength for SETRANGE and APPEND
(cherry picked from commit 912b48e4b9)
2020-09-01 09:27:58 +03:00
YoongHM 5e0a3e2626 Start redis after network is online (#7639)
The two lines allow systemd to start redis.service after the network is online. Only after the network is online that Redis could bind to IP address other than 127.0.0.1 during initial boot up process.

(cherry picked from commit 1c6caaaef7)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb 9c7c0c511a Run daily workflow on main repo only (no forks). (#7646)
(cherry picked from commit b8f0c2de4a)
2020-09-01 09:27:58 +03:00
WuYunlong 5240ad73ef see #7250, fix signature of RedisModule_DeauthenticateAndCloseClient (#7645)
In redismodule.h, RedisModule_DeauthenticateAndCloseClient returns void
`void REDISMODULE_API_FUNC(RedisModule_DeauthenticateAndCloseClient)(RedisModuleCtx *ctx, uint64_t client_id);`
But in module.c, RM_DeauthenticateAndCloseClient returns int
`int RM_DeauthenticateAndCloseClient(RedisModuleCtx *ctx, uint64_t client_id)`

It it safe to change return value from `void` to `int` from the user's perspective.

(cherry picked from commit dd08aec539)
2020-09-01 09:27:58 +03:00
Wang Yuan 753ff31fa3 Print error info if failed opening config file (#6943)
(cherry picked from commit 514a1e223d)
2020-09-01 09:27:58 +03:00
Wen Hui 9b7da52c3b fix memory leak in ACLLoadFromFile error handling (#7623)
(cherry picked from commit 30ead1edae)
2020-09-01 09:27:58 +03:00
Oran Agra 6f6658ab60 redis-cli --cluster-yes - negate force flag for clarity
this internal flag is there so that some commands do not comply to `--cluster-yes`

(cherry picked from commit f519dcb216)
2020-09-01 09:27:58 +03:00
Frank Meier d5f7ec90bc reintroduce REDISCLI_CLUSTER_YES env variable in redis-cli
the variable was introduced only in the 5.0 branch in #5879 bc6c1c40db

(cherry picked from commit c6ac2588db)
2020-09-01 09:27:58 +03:00
Frank Meier 05e54ec962 add force option to 'create-cluster create' script call (#7612)
(cherry picked from commit c8f3182f37)
2020-09-01 09:27:58 +03:00
Oran Agra b4a6b4f28d fix new rdb test failing on timing issues (#7604)
apparenlty on github actions sometimes 500ms is not enough

(cherry picked from commit 191b118102)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb dd94ca7295 Fix test-centos7-tls daily job. (#7598)
(cherry picked from commit e97cec2f28)
2020-09-01 09:27:58 +03:00
Oran Agra 3a4ee4b6d6 module hook for master link up missing on successful psync (#7584)
besides, hooks test was time sensitive. when the replica managed to
reconnect quickly after the client kill, the test would fail

(cherry picked from commit c5d85c69c7)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb 0dbf112caf CI: Add daily CentOS 7.x jobs. (#7582)
(cherry picked from commit 92e089b1ab)
2020-09-01 09:27:58 +03:00
WuYunlong 37fba8f4d8 Fix running single test 14-consistency-check.tcl (#7587)
(cherry picked from commit be11e1b5ea)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb 2428b64d5a Clarify RM_BlockClient() error condition. (#6093)
(cherry picked from commit 342d9a642f)
2020-09-01 09:27:58 +03:00
namtsui 3d98418f4a Avoid an out-of-bounds read in the redis-sentinel (#7443)
The Redis sentinel would crash with a segfault after a few minutes
because it tried to read from a page without read permissions. Check up
front whether the sds is long enough to contain redis:slave or
redis:master before memcmp() as is done everywhere else in
sentinelRefreshInstanceInfo().

Bug report and commit message from Theo Buehler. Fix from Nam Nguyen.

Co-authored-by: Nam Nguyen <namn@berkeley.edu>
(cherry picked from commit 8c03eb90da)
2020-09-01 09:27:58 +03:00
Wen Hui 46686af7f5 Add SignalModifiedKey hook in XGROUP CREATE with MKSTREAM option (#7562)
(cherry picked from commit 0a2b019b79)
2020-09-01 09:27:58 +03:00
Wen Hui 9f873c6c2a fix leak in error handling of debug populate command (#7062)
valsize was not modified during the for loop below instead of getting from c->argv[4], therefore there is no need to put inside the for loop.. Moreover, putting the check outside loop will also avoid memory leaking, decrRefCount(key) should be called in the original code if we put the check in for loop

(cherry picked from commit 2afa308306)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb 2e6563cdcf Fix TLS cluster tests. (#7578)
Fix consistency test added in 0c9916d00 without considering TLS
redis-cli configuration.

(cherry picked from commit 675b00c7e0)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb ebdfa71584 TLS: Propagate and handle SSL_new() failures. (#7576)
The connection API may create an accepted connection object in an error
state, and callers are expected to check it before attempting to use it.

Co-authored-by: mrpre <mrpre@163.com>
(cherry picked from commit bc450c5f63)
2020-09-01 09:27:58 +03:00
Oran Agra 10a8407a4f Fix failing tests due to issues with wait_for_log_message (#7572)
- the test now waits for specific set of log messages rather than wait for
  timeout looking for just one message.
- we don't wanna sample the current length of the log after an action, due
  to a race, we need to start the search from the line number of the last
  message we where waiting for.
- when attempting to trigger a full sync, use multi-exec to avoid a race
  where the replica manages to re-connect before we completed the set of
  actions that should force a full sync.
- fix verify_log_message which was broken and unused

(cherry picked from commit 06aaeabaea)
2020-09-01 09:27:58 +03:00
Jiayuan Chen 7b2af98316 Add optional tls verification (#7502)
Adds an `optional` value to the previously boolean `tls-auth-clients` configuration keyword.

Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
(cherry picked from commit 198770751f)
2020-09-01 09:27:58 +03:00
Oran Agra d2ef4c0347 Daily github action: run cluster and sentinel tests with tls (#7575)
(cherry picked from commit 62e84b42d2)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb ba559dc903 TLS: support cluster/replication without tls-port.
Initialize and configure OpenSSL even when tls-port is not used, because
we may still have tls-cluster or tls-replication.

Also, make sure to reconfigure OpenSSL when these parameters are changed
as TLS could have been enabled for the first time.

(cherry picked from commit b76a93c362)
2020-09-01 09:27:58 +03:00
grishaf 53f36dc5b6 Fix prepareForShutdown function declaration (#7566)
(cherry picked from commit f8751d03ba)
2020-09-01 09:27:58 +03:00
Oran Agra 558a343b3c Stabilize bgsave test that sometimes fails with valgrind (#7559)
on ci.redis.io the test fails a lot, reporting that bgsave didn't end.
increaseing the timeout we wait for that bgsave to get aborted.
in addition to that, i also verify that it indeed got aborted by
checking that the save counter wasn't reset.

add another test to verify that a successful bgsave indeed resets the
change counter.

(cherry picked from commit 49d4aebce0)
2020-09-01 09:27:58 +03:00
Madelyn Olson 32d225c644 Properly reset errno for rdbLoad (#7542)
(cherry picked from commit 9615c7480d)
2020-09-01 09:27:58 +03:00
Oran Agra 2b45c88a6a testsuite may leave servers alive on error (#7549)
in cases where you have
test name {
  start_server {
    start_server {
      assert
    }
  }
}

the exception will be thrown to the test proc, and the servers are
supposed to be killed on the way out. but it seems there was always a
bug of not cleaning the server stack, and recently (#7404) we started
relying on that stack in order to kill them, so with that bug sometimes
we would have tried to kill the same server twice, and leave one alive.

luckly, in most cases the pattern is:
start_server {
  test name {
  }
}

(cherry picked from commit bb170fa06e)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb 6d80011e73 Tests: drop TCL 8.6 dependency. (#7548)
This re-implements the redis-cli --pipe test so it no longer depends on a close feature available only in TCL 8.6.

Basically what this test does is run redis-cli --pipe, generates a bunch of commands and pipes them through redis-cli, and inspects the result in both Redis and the redis-cli output.

To do that, we need to close stdin for redis-cli to indicate we're done so it can flush its buffers and exit. TCL has bi-directional channels can only offers a way to "one-way close" a channel with TCL 8.6. To work around that, we now generate the commands into a file and feed that file to redis-cli directly.

As we're writing to an actual file, the number of commands is now reduced.

(cherry picked from commit dbc0a64843)
2020-09-01 09:27:58 +03:00
Oran Agra d2fac9bdb9 Fixes to release scripts (#7547)
(cherry picked from commit a472f35efd)
2020-09-01 09:27:58 +03:00
Remi Collet 443e57b08e Fix deprecated tail syntax in tests (#7543)
(cherry picked from commit 7853d8410b)
2020-09-01 09:27:58 +03:00
Wen Hui fb9b6e0919 Add missing calls to raxStop (#7532)
Since the dynamic allocations in raxIterator are only used for deep walks, memory
leak due to missing call to raxStop can only happen for rax with key names longer
than 32 bytes.

Out of all the missing calls, the only ones that may lead to a leak are the rax
for consumer groups and consumers, and these were only in AOFRW and rdbSave, which
normally only happen in fork or at shutdown.

(cherry picked from commit 0b8d47a985)
2020-09-01 09:27:58 +03:00
Wen Hui 25ab97cbe3 add missing caching command in client help (#7399)
(cherry picked from commit e035e5218f)
2020-09-01 09:27:58 +03:00
zhaozhao.zz 8739408147 replication: need handle -NOPERM error after send ping (#7538)
(cherry picked from commit 57fbe4cbaf)
2020-09-01 09:27:58 +03:00
Scott Brenner 925f1ce51e GitHub Actions workflows - use latest version of actions/checkout (#7534)
(cherry picked from commit c7644eda71)
2020-09-01 09:27:58 +03:00
John Sully ff9df842d8 Implement use-fork config (fails with diskless repl)
Former-commit-id: f2d5c2bca22e9fd506db123c47b7f60cdded7e2c
2020-08-24 03:17:59 +00:00
John Sully 91bd125fb4 Implement use-fork config (fails with diskless repl)
Former-commit-id: 4e941b8d30612c1051a9dde67effaf8c5a86456f
2020-08-24 03:17:31 +00:00
John Sully dcf607622c Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: ed98be0ba81ffdc501847ea0d2486f5f01391319
2020-08-17 02:26:51 +00:00
John Sully 93a67abe52 Fix ARM build of RocksDB
Former-commit-id: 7301d6d5e76b65115e2610a5fc5afee443782d7c
2020-08-17 02:25:45 +00:00
John Sully e8e7061a73 Fast cleanup of snapshots without leaving them forever
Former-commit-id: fdd83b2b49244ed2988b080892ee5cffe9fd2684
2020-08-17 00:33:37 +00:00
John Sully c0586b3aed Allow garbage collection of generic data
Former-commit-id: feadb7fb1845027422bcfca43dbcb6097409b8dc
2020-08-17 00:32:48 +00:00
John Sully 00934cd341 Add snapshot depth to info string
Former-commit-id: 66aef678e9d6d7ab6c28622d54ada0ea8cdd2a99
2020-08-16 00:27:10 +00:00
John Sully 4a356ac13f Don't try and consolidate snapshots with a depth of 1
Former-commit-id: 26c298bd9bc4e2c6981de5c20284120ea54580c3
2020-08-16 00:26:05 +00:00
John Sully 3093d9e117 Only save MVCC tstamps if its an active replica
Former-commit-id: 5aded7dbad055308dc3932f7797fc71684b60966
2020-08-16 00:24:18 +00:00
John Sully cf4e74006f Don't free snapshot objects in a critical path (under the AE lock)
Former-commit-id: d0da3d3cb74334cc8a2d14f4bdaef7935181700a
2020-08-16 00:13:19 +00:00
John Sully 311b286d41 BUG: Cannot have an EMBSTR bigger than 255
Former-commit-id: e2d6e2d9d585cb7a73f469a8580f9cb0ec71a429
2020-08-15 23:30:22 +00:00
John Sully 82989540c4 remove unnecessary allocation in rdb save
Former-commit-id: dfa76f04fd862e0cc7b4d3284b3922e3a5e5549d
2020-08-15 23:27:32 +00:00
John Sully ce69a765f8 Remove unnecessary key comparisons in perf critical snapshot paths
Former-commit-id: 40f8a8d102fdca9443399ef03a47df609b146d58
2020-08-15 23:25:58 +00:00
John Sully 1055543817 dictMerge perf improvements
Former-commit-id: 48401ec369c5693689ef658cca518dc94ab1402e
2020-08-15 23:14:29 +00:00
John Sully eb572c57e2 Rehash efficiency
Former-commit-id: fab383156626ec683881101c22eb2f6c2cea4c5d
2020-08-15 23:05:56 +00:00
John Sully 6c6ca43eef Prevent unnecessary copy when overwriting a value from a snapshot
Former-commit-id: 654a7bc6ea82f4ac45a1c1a25c794e1c27c0d902
2020-08-15 22:59:01 +00:00
John Sully c804b28446 Merge branch 'unstable' into keydbpro
Former-commit-id: ae482585f0dc470efd73833f74111c2f87a172c5
2020-08-15 21:29:00 +00:00
John Sully 6b8e979434 Prehash the tombstone for cleanup
Former-commit-id: c9d97a7c7448fc769486175bea1648589487c87c
2020-08-14 16:05:39 +00:00
benschermel b3861ac64c update changelog
Former-commit-id: 6709f3c8b776921fafd59046c646283f383cab71
2020-08-11 04:39:08 +00:00
John Sully 636ea4db9f 6.0.15 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 05140de5a46d05e39815472f96be526868800f30
2020-08-11 00:27:31 -04:00
John Sully 9090e26aca Add build flag to disable MVCC tstamps
Former-commit-id: f17d178d03
2020-08-10 06:10:24 +00:00
John Sully 9928562dad Fix lock after free in module API
Former-commit-id: d88fd1588d
2020-08-10 06:10:24 +00:00
John Sully 0cb8d4ca63 MVCC Perf fixes
Former-commit-id: 5a4afe5fb4231bec34d434f9e3214a7320842091
2020-08-10 05:45:56 +00:00
John Sully 4037ee98a4 Fix assert caused by freeTombstoneObjects and null check in consolidate_children
Former-commit-id: 8565a02b331cd2bba2a1c7c6693dfb3f6e61c845
2020-08-10 05:01:36 +00:00
John Sully 848057ff19 RocksDB Read Performance Improvements
Former-commit-id: 80cca4869888e048e10e11f1f20796c482c3e5b3
2020-08-09 23:36:20 +00:00
John Sully 94020160dc Ensure we use the SSE CRC32 instruction
Former-commit-id: 78ef8976e86d07d4c1fa7c4631a610babf2f4776
2020-08-09 01:47:53 +00:00
John Sully 80dc68e497 Start off storage cache with a larger size
Former-commit-id: 5f6fb970a81cc73586ba595b35564e7865e7262d
2020-08-09 00:57:56 +00:00
John Sully 3c13a4bc25 Disable compression it destroys read perf
Former-commit-id: d3fffc12ae5339886f54c064127497f277393b00
2020-08-06 22:30:56 +00:00
John Sully ef7198e24d keydbpro unstable version should be 0.0.0
Former-commit-id: 4a6e0772f36d5dd721ad2e9b83f9fccce2e38ff0
2020-08-06 02:13:23 +00:00
John Sully 2c9c4a98ea Latency normalization with SCAN
Former-commit-id: 237f25d854e70d4d7a3095fdf56aaa80770e492e
2020-08-04 04:37:16 +00:00
Oran Agra 1c356d2084 Redis 6.0.6. 2020-07-20 21:08:26 +03:00
Oran Agra 3da969eeaa Run daily CI on PRs to release a branch 2020-07-20 21:08:26 +03:00
Itamar Haber c662a4e01b Adds SHA256SUM to redis-stable tarball upload
(cherry picked from commit efb04ab4a2)
2020-07-20 21:08:26 +03:00
yoav-steinberg 575ffeb879 Support passing stack allocated module strings to moduleCreateArgvFromUserFormat (#7528)
Specifically, the key passed to the module aof_rewrite callback is a stack allocated robj. When passing it to RedisModule_EmitAOF (with appropriate "s" fmt string) redis used to panic when trying to inc the ref count of the stack allocated robj. Now support such robjs by coying them to a new heap robj. This doesn't affect performance because using the alternative "c" or "b" format strings also copies the input to a new heap robj.

(cherry picked from commit 8a2b0472a7)
2020-07-20 21:08:26 +03:00
Luke Palmer 2871eb287a Send null for invalidate on flush (#7469)
(cherry picked from commit df4c74ef07)
2020-07-20 21:08:26 +03:00
dmurnane 81d36bc6c8 Notify systemd on sentinel startup (#7168)
Co-authored-by: Daniel Murnane <dmurnane@eitccorp.com>
(cherry picked from commit c292d43fec)
2020-07-20 21:08:26 +03:00
Developer-Ecosystem-Engineering 1e144396e0 Add registers dump support for Apple silicon (#7453)
Export following environment variables before building on macOS on Apple silicon

export ARCH_FLAGS="-arch arm64"
export SDK_NAME=macosx
export SDK_PATH=$(xcrun --show-sdk-path --sdk $SDK_NAME)
export CFLAGS="$ARCH_FLAGS -isysroot $SDK_PATH -I$SDK_PATH/usr/include"
export CXXFLAGS=$CFLAGS
export LDFLAGS="$ARCH_FLAGS"
export CC="$(xcrun -sdk $SDK_PATH --find clang) $CFLAGS"
export CXX="$(xcrun -sdk $SDK_PATH --find clang++) $CXXFLAGS"
export LD="$(xcrun -sdk $SDK_PATH --find ld) $LDFLAGS"

make
make test
..
All tests passed without errors!

Backtrack logging assumes x86 and required updating

(cherry picked from commit 004479c184)
2020-07-20 21:08:26 +03:00
Wen Hui b06b71a442 correct error msg for num connections reaching maxclients in cluster mode (#7444)
(cherry picked from commit 6c5f98b24b)
2020-07-20 21:08:26 +03:00
WuYunlong 8b20802a09 Fix command help for unexpected options (#7476)
(cherry picked from commit e5166eccee)
2020-07-20 21:08:26 +03:00
WuYunlong bcf9ca362c Refactor RM_KeyType() by using macro. (#7486)
(cherry picked from commit 7da8c062d5)
2020-07-20 21:08:26 +03:00
Oran Agra b0f08a04e0 diskless master disconnect replicas when rdb child failed (#7518)
in case the rdb child failed, crashed or terminated unexpectedly redis
would have marked the replica clients with repl_put_online_on_ack and
then kill them only after a minute when no ack was received.

it would not stream anything to these connections, so the only effect of
this bug is a delay of 1 minute in the replicas attempt to re-connect.

(cherry picked from commit a3df709234)
2020-07-20 21:08:26 +03:00
Oran Agra 6bdc5a4a08 redis-cli tests, fix valgrind timing issue (#7519)
this test when run with valgrind on github actions takes 160 seconds

(cherry picked from commit 8a14ce8634)
2020-07-20 21:08:26 +03:00
WuYunlong b80f2ec8ac Fix out of update help info in tcl tests. (#7516)
Before this commit, the output of "./runtest-cluster --help" is incorrect.
After this commit, the format of the following 3 output is consistent:
./runtest --help
./runtest-cluster --help
./runtest-sentinel --help

(cherry picked from commit 24b6f62741)
2020-07-20 21:08:26 +03:00
Qu Chen 2c8ecc9713 Replica always reports master's config epoch in CLUSTER NODES output. (#7235)
(cherry picked from commit a517043c7a)
2020-07-20 21:08:26 +03:00
Oran Agra 90b6ed7a2c RESTORE ABSTTL skip expired keys - leak (#7511)
(cherry picked from commit c10eabeeca)
2020-07-20 21:08:26 +03:00
Oran Agra dde79afbf7 fix recently added time sensitive tests failing with valgrind (#7512)
interestingly the latency monitor test fails because valgrind is slow
enough so that the time inside PEXPIREAT command from the moment of
the first mstime() call to get the basetime until checkAlreadyExpired
calls mstime() again is more than 1ms, and that test was too sensitive.

using this opportunity to speed up the test (unrelated to the failure)
the fix is just the longer time passed to PEXPIRE.

(cherry picked from commit 663e637da8)
2020-07-20 21:08:26 +03:00
Oran Agra 905ffb72e9 runtest --stop pause stops before terminating the redis server (#7513)
in the majority of the cases (on this rarely used feature) we want to
stop and be able to connect to the shard with redis-cli.
since these are two different processes interracting with the tty we
need to stop both, and we'll have to hit enter twice, but it's not that
bad considering it is rarely used.

(cherry picked from commit 3351549c22)
2020-07-20 21:08:26 +03:00
Oran Agra 7fff1d3500 update release scripts for new hosts, and CI to run more tests (#7480)
* update daily CI to include cluster and sentinel tests
* update daily CI to run when creating a new release
* update release scripts to work on the new redis.io hosts

(cherry picked from commit 2ee300481f)
2020-07-20 21:08:26 +03:00
jimgreen2013 8610a17696 fix description about ziplist, the code is ok (#6318)
* fix description about ZIP_BIG_PREVLEN(the code is ok), it's similar to
antirez#4705

* fix description about ziplist entry encoding field (the code is ok),
the max length should be 2^32 - 1 when encoding is 5 bytes

(cherry picked from commit c05d8a0a31)
2020-07-20 21:08:26 +03:00
马永泽 796cbb68c9 fix benchmark in cluster mode fails to authenticate (#7488)
Co-authored-by: Oran Agra <oran@redislabs.com> (styling)
(cherry picked from commit 40e930dab5)
2020-07-20 21:08:26 +03:00
Abhishek Soni 650f4c538d fix: typo in CI job name (#7466)
(cherry picked from commit 6d8fa206bb)
2020-07-20 21:08:26 +03:00
Jiayuan Chen b42a2bef01 Fix typo in deps README (#7500)
(cherry picked from commit f8c6c32178)
2020-07-20 21:08:26 +03:00
WuYunlong b6fd631d04 Add missing latency-monitor tcl test to test_helper.tcl. (#6782)
(cherry picked from commit 136e5efeab)
2020-07-20 21:08:26 +03:00
Yossi Gottlieb 27d44fbf73 TLS: Session caching configuration support. (#7420)
* TLS: Session caching configuration support.
* TLS: Remove redundant config initialization.

(cherry picked from commit c611a836f6)
2020-07-20 21:08:26 +03:00
Yossi Gottlieb 8bacdf8b48 TLS: Ignore client cert when tls-auth-clients off. (#7457)
(cherry picked from commit 6dfbccc212)
2020-07-20 21:08:26 +03:00
James Hilliard e76db7509d Use pkg-config to properly detect libssl and libcrypto libraries (#7452)
(cherry picked from commit 5f16b65a5f)
2020-07-20 21:08:26 +03:00
Yossi Gottlieb 6af3d57beb TLS: Add missing redis-cli options. (#7456)
* Tests: fix and reintroduce redis-cli tests.

These tests have been broken and disabled for 10 years now!

* TLS: add remaining redis-cli support.

This adds support for the redis-cli --pipe, --rdb and --replica options
previously unsupported in --tls mode.

* Fix writeConn().

(cherry picked from commit 99b920534f)
2020-07-20 21:08:26 +03:00
Oran Agra 1f9793c996 redis-cli --hotkeys fixed to handle non-printable key names
(cherry picked from commit a11940b112)
2020-07-20 21:08:26 +03:00
Oran Agra 86e45052c3 redis-cli --bigkeys fixed to handle non-printable key names
(cherry picked from commit 3d760eaea2)
2020-07-20 21:08:26 +03:00
Oran Agra da96665c04 RESTORE ABSTTL won't store expired keys into the db (#7472)
Similarly to EXPIREAT with TTL in the past, which implicitly deletes the
key and return success, RESTORE should not store key that are already
expired into the db.
When used together with REPLACE it should emit a DEL to keyspace
notification and replication stream.

(cherry picked from commit 1c35f8741b)
2020-07-20 21:08:26 +03:00
huangzhw 5728ec50d3 defrag.c activeDefragSdsListAndDict when defrag sdsele, We can't use (#7492)
it to calculate hash, we should use newsds.

(cherry picked from commit 84bef6691b)
2020-07-20 21:08:26 +03:00
Oran Agra cf116e08cc skip a test that uses +inf on valgrind (#7440)
On some platforms strtold("+inf") with valgrind returns a non-inf result

[err]: INCRBYFLOAT does not allow NaN or Infinity in tests/unit/type/incr.tcl
Expected 'ERR*would produce*' to equal or match '1189731495357231765085759.....'

(cherry picked from commit 6b53c630d9)
2020-07-20 21:08:26 +03:00
Oran Agra c994e73c8e stabilize tests that look for log lines (#7367)
tests were sensitive to additional log lines appearing in the log
causing the search to come empty handed.

instead of just looking for the n last log lines, capture the log lines
before performing the action, and then search from that offset.

(cherry picked from commit efc4189b62)
2020-07-20 21:08:26 +03:00
Oran Agra 298e93c360 tests/valgrind: don't use debug restart (#7404)
* tests/valgrind: don't use debug restart

DEBUG REATART causes two issues:
1. it uses execve which replaces the original process and valgrind doesn't
   have a chance to check for errors, so leaks go unreported.
2. valgrind report invalid calls to close() which we're unable to resolve.

So now the tests use restart_server mechanism in the tests, that terminates
the old server and starts a new one, new PID, but same stdout, stderr.

since the stderr can contain two or more valgrind report, it is not enough
to just check for the absence of leaks, we also need to check for some known
errors, we do both, and fail if we either find an error, or can't find a
report saying there are no leaks.

other changes:
- when killing a server that was already terminated we check for leaks too.
- adding DEBUG LEAK which was used to test it.
- adding --trace-children to valgrind, although no longer needed.
- since the stdout contains two or more runs, we need slightly different way
  of checking if the new process is up (explicitly looking for the new PID)
- move the code that handles --wait-server to happen earlier (before
  watching the startup message in the log), and serve the restarted server too.

* squashme - CR fixes

(cherry picked from commit 8d4f055e43)
2020-07-20 21:08:26 +03:00
Oran Agra b71330af50 change references to the github repo location (#7479)
(cherry picked from commit 8df9882075)
2020-07-20 21:08:26 +03:00
zhaozhao.zz a17f059d21 BITOP: propagate only when it really SET or DEL targetkey (#5783)
For example:
    BITOP not targetkey sourcekey

If targetkey and sourcekey doesn't exist, BITOP has no effect,
we do not propagate it, thus can save aof and replica flow.

(cherry picked from commit 2cf11ce5ca)
2020-07-20 21:08:26 +03:00
antirez ae2bcd49db Update comment to clarify change in #7398.
(cherry picked from commit 7bb0342201)
2020-07-20 21:08:26 +03:00
antirez ecb2743e8a LPOS: option FIRST renamed RANK.
(cherry picked from commit 5b16c2f174)
2020-07-20 21:08:26 +03:00
Dave Nielsen a88be2c6eb updated copyright year
Changed "2015" to "2020"

(cherry picked from commit e54ea02c43)
2020-07-20 21:08:26 +03:00
Oran Agra 8510588213 EXEC always fails with EXECABORT and multi-state is cleared
In order to support the use of multi-exec in pipeline, it is important that
MULTI and EXEC are never rejected and it is easy for the client to know if the
connection is still in multi state.

It was easy to make sure MULTI and DISCARD never fail (done by previous
commits) since these only change the client state and don't do any actual
change in the server, but EXEC is a different story.

Since in the past, it was possible for clients to handle some EXEC errors and
retry the EXEC, we now can't affort to return any error on EXEC other than
EXECABORT, which now carries with it the real reason for the abort too.

Other fixes in this commit:
- Some checks that where performed at the time of queuing need to be re-
  validated when EXEC runs, for instance if the transaction contains writes
  commands, it needs to be aborted. there was one check that was already done
  in execCommand (-READONLY), but other checks where missing: -OOM, -MISCONF,
  -NOREPLICAS, -MASTERDOWN
- When a command is rejected by processCommand it was rejected with addReply,
  which was not recognized as an error in case the bad command came from the
  master. this will enable to count or MONITOR these errors in the future.
- make it easier for tests to create additional (non deferred) clients.
- add tests for the fixes of this commit.

(cherry picked from commit fe8d6fe749)
2020-07-20 21:08:26 +03:00
antirez 63073e6a44 Include cluster.h for getClusterConnectionsCount().
(cherry picked from commit 79e15d1686)
2020-07-20 21:08:26 +03:00
antirez 5f889001cf Fix BITFIELD i64 type handling, see #7417.
(cherry picked from commit 448a8bb0ed)
2020-07-20 21:08:26 +03:00
antirez 93fa64f65a Clarify maxclients and cluster in conf. Remove myself too.
(cherry picked from commit c10a7a040f)
2020-07-20 21:08:26 +03:00
hwware e4e223ad79 fix memory leak in sentinel connection sharing
(cherry picked from commit bdac36b70e)
2020-07-20 21:08:26 +03:00
chenhui0212 ee992ea113 Fix comments in function raxLowWalk of listpack.c
(cherry picked from commit 44235ac718)
2020-07-20 21:08:26 +03:00
Tomasz Poradowski f13381da22 ensure SHUTDOWN_NOSAVE in Sentinel mode
- enforcing of SHUTDOWN_NOSAVE flag in one place to make it consitent
  when running in Sentinel mode

(cherry picked from commit 6782243054)
2020-07-20 21:08:26 +03:00
chenhui0212 1c733df3d8 fix comments in listpack.c
(cherry picked from commit 6b82471098)
2020-07-20 21:08:26 +03:00
antirez 7412dbbef5 Use cluster connections too, to limit maxclients.
See #7401.

(cherry picked from commit fc08cafdb0)
2020-07-20 21:08:26 +03:00
antirez d5515331e2 Tracking: fix enableBcastTrackingForPrefix() invalid sdslen() call.
Related to #7387.

(cherry picked from commit ae770c3034)
2020-07-20 21:08:26 +03:00
root 09e960ff62 cluster.c remove if of clusterSendFail in markNodeAsFailingIfNeeded
(cherry picked from commit 009a2d443a)
2020-07-20 21:08:26 +03:00
meir@redislabs.com cb06a48ef3 Fix RM_ScanKey module api not to return int encoded strings
The scan key module API provides the scan callback with the current
field name and value (if it exists). Those arguments are RedisModuleString*
which means it supposes to point to robj which is encoded as a string.
Using createStringObjectFromLongLong function might return robj that
points to an integer and so break a module that tries for example to
use RedisModule_StringPtrLen on the given field/value.

The PR introduces a fix that uses the createObject function and sdsfromlonglong function.
Using those function promise that the field and value pass to the to the
scan callback will be Strings.

The PR also changes the Scan test module to use RedisModule_StringPtrLen
to catch the issue. without this, the issue is hidden because
RedisModule_ReplyWithString knows to handle integer encoding of the
given robj (RedisModuleString).

The PR also introduces a new test to verify the issue is solved.

(cherry picked from commit e37c16e425)
2020-07-20 21:08:26 +03:00
antirez 9d3e874179 Fix LCS object type checking. Related to #7379.
(cherry picked from commit 00e1f87a08)
2020-07-20 21:08:26 +03:00
hwware 3dbde34323 fix memory leak
(cherry picked from commit 8ab655bd7b)
2020-07-20 21:08:26 +03:00
hwware 4a03e1e1f8 fix server crash in STRALGO command
(cherry picked from commit 44195a2047)
2020-07-20 21:08:26 +03:00
Benjamin Sergeant 2f9da08ead Update redis-cli.c
(cherry picked from commit 52a477c661)
2020-07-20 21:08:26 +03:00
Jamie Scott 333f763693 minor fix
(cherry picked from commit 3ba9724d16)
2020-07-20 21:08:26 +03:00
John Sully 6f320425d6 Bump version
Former-commit-id: 76c557e9f3c15094aa4f2c5f8a4484f73c7a96a4
2020-07-16 22:45:13 +00:00
John Sully d12e90823c Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 9bc0cb29f1c8dc8258603ea1c353fe495c1228ae
2020-07-16 22:42:48 +00:00
John Sully 6ec308c30f Fix memory leak in MVCC scan
Former-commit-id: 3acf80f8dd5ebc311670398745ef3400333a1fcb
2020-07-16 22:42:24 +00:00
John Sully 4f908b1096 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: eb00c2dddc385dad4b0695d64b4f99f7a003c208
2020-07-14 04:34:56 +00:00
John Sully 658ebaa454 Fix test failure
Former-commit-id: 05d84f5fc184676d32c4bb61ac5957f1787cd4f8
2020-07-14 04:34:40 +00:00
John Sully 6cf5e8f2b2 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 08264b4e755cee34704c85b191606a2b28d6d883
2020-07-14 04:25:05 +00:00
John Sully 9112445059 Add new storage-provider-options config
Former-commit-id: 195a28beecc6094f959ddafef7fe33f5b55e4047
2020-07-14 04:24:46 +00:00
John Sully 198db651d2 Remove gitter, we don't check it often enough
Former-commit-id: 119797014c
2020-07-13 21:14:03 -04:00
John Sully c9ff0292d8 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 86eb3f5c5ea3c17d798e74126e08114a2dd2449e
2020-07-13 18:16:05 +00:00
John Sully 731de57fb7 Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: 7ce91d858f298d6172df7152fcf49188ca8251f3
2020-07-13 18:15:15 +00:00
John Sully 503ca68e8c Perf fixes on expire lock
Former-commit-id: 7f23ac087720317f54a0bc0e0c4774e7b0ef4337
2020-07-13 18:14:52 +00:00
John Sully ad5ad52841 Build fixes from cherry-pick
Former-commit-id: 70efd87cf71bb230e8b53d1c4ed3dd91997b4d23
2020-07-13 16:09:03 +00:00
John Sully af10f809b4 unoredered_map is faster, reduce latency with the switch
Former-commit-id: f241e435ed0fd2988ada887f02e19884fd82be51
2020-07-13 16:04:00 +00:00
John Sully fc119b3e56 Remove unnecessary work from critical path (Latency Fixes)
Former-commit-id: 096a90deb7afe489875d3186f3f8f43e41fea329
2020-07-13 16:03:52 +00:00
benschermel a8b68d0a45 updating deb changelog
Former-commit-id: ea03d462ceddfbece66099304a91cc706fc93411
2020-07-13 01:41:18 -04:00
benschermel 2cbf586ec7 update deb changelog
Former-commit-id: a6782a3c0d
2020-07-13 01:35:25 -04:00
John Sully 15ce65a170 Bump version
Former-commit-id: 297f50e491030c2a65448aa80ec543263e28c298
2020-07-13 04:00:24 +00:00
John Sully 7ed6e1a197 Bump version
Former-commit-id: f7d7baccc9
2020-07-13 03:59:16 +00:00
John Sully 414b3102ca Merge branch 'flash_cache' into keydbpro
Former-commit-id: 2a721ef645921d62b39f1374c0a3f5c92b00fae5
2020-07-13 03:53:34 +00:00
John Sully 8c2c0fba12 Merge branch 'PRO_RELEASE_6' into keydbpro
Former-commit-id: bffe010ea5279bee869bc61cc6d933979e10bbea
2020-07-13 03:32:14 +00:00
John Sully f17dab1f67 Merge branch 'unstable' into keydbpro
Former-commit-id: 0dafbc254a0efd5ee302d5c58fb2ca0a85110104
2020-07-13 03:31:47 +00:00
John Sully 7ace525b7b Merge branch 'unstable' into RELEASE_6
Former-commit-id: eff294e374
2020-07-13 01:05:36 +00:00
John Sully 6f8e9a64fa Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: e8f568644b
2020-07-13 01:05:17 +00:00
John Sully 7f36b5541e Merge branch 'unstable' into RELEASE_6
Former-commit-id: f7c2006bf6
2020-07-13 01:04:49 +00:00
John Sully 84bf240caa Merge tag '6.0.5' into unstable
Redis 6.0.5


Former-commit-id: b736a95b0d
2020-07-13 00:55:23 +00:00
benschermel ed77abee5e update rpm permissions
Former-commit-id: 7aec1e5c6463ea77d27833c66e124e8184c4a123
2020-07-12 18:08:29 -04:00
benschermel 76426c3172 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: d909d12cb3
2020-07-12 18:04:40 -04:00
benschermel 6c48ba994e update rpm permissions
Former-commit-id: 201ffa9d62
2020-07-12 18:03:21 -04:00
John Sully 70824b3bdb Add the KEYDB.MEXISTS command, see issue #203
Former-commit-id: 5619f51528
2020-07-12 21:42:11 +00:00
John Sully f853142083 Add multi-master-no-forward command to reduce bus traffic with multi-master
Former-commit-id: d99d06b125
2020-07-12 19:25:19 +00:00
John Sully c6e5ba8313 Document min-clients-per-thread
Former-commit-id: 1b9ade7f65
2020-07-12 18:49:02 +00:00
John Sully 6158cdfd29 Prevent deadlock in RM_ThreadSafeContextLock() when triggered as part of a module callback in a server thread
Former-commit-id: e01312642b
2020-07-12 18:17:53 +00:00
John Sully 3eca9ea38d Fix CLI crash on arch with hostname
Former-commit-id: 55fd37e8d6c3775d0b1bd13966ca033f63945d7e
2020-07-12 05:38:08 +00:00
John Sully 336ee77691 Fix CLI crash on arch with hostname
Former-commit-id: a5b584d7d36c60cbbcf815572229b6c80a3a3dce
2020-07-12 05:37:43 +00:00
John Sully dedfe2d63c Fix failure to replicate with license key
Former-commit-id: d34723c567b36f8222c93fac6f0ed1f79104f33e
2020-07-12 05:15:22 +00:00
John Sully 6c66fef004 Fix failure to replicate with license key
Former-commit-id: 41a72a795ade90b1aea509e9e3ebad819a997acf
2020-07-12 05:14:59 +00:00
John Sully 785779ee40 Fix failure to merge databases on active replica sync, due to bad merge with Redis 6
Former-commit-id: cd9514f4c8
2020-07-12 01:13:22 +00:00
John Sully d1a03fcd62 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 507b791211b4b0c3251dc538fa385cd95a189e80
2020-07-11 22:27:32 +00:00
John Sully ead6e22865 Add KeyDB Pro info section
Former-commit-id: d73015fae36ece6db7b088cc55843385688b1866
2020-07-11 22:21:12 +00:00
John Sully 074cb1edc1 Sentinel doesn't need a license key
Former-commit-id: bc2d8c18255214b873bf45d8db8af3727ebc4723
2020-07-11 22:13:07 +00:00
John Sully 06a8e2aa2a Fix failure to replicate with non-pro server when license key is set
Former-commit-id: a69beef7d92223c8dcebb9c39ca2409183571e57
2020-07-11 22:09:27 +00:00
John Sully 3af243a447 Support missing Redis 6 config options
Former-commit-id: f111c23415
2020-07-11 21:39:20 +00:00
John Sully 4b58160c61 Support missing Redis 6 config options
Former-commit-id: d467701c6cd8ebe2937c6fda816a706a6b17182a
2020-07-11 21:38:17 +00:00
John Sully d67265de66 Implement storage key cache, and writeback memory model
Former-commit-id: 732bd9c153459f1174475ad67de36c399ddbe359
2020-07-11 21:23:48 +00:00
John Sully 6912b10aed Eliminate eviction loops. And don't OOM so often with storage providers set
Former-commit-id: 6e61cd33b4366f008b07aae88f49fd0ac9cbcaec
2020-07-11 06:51:08 +00:00
John Sully a3cf9ce109 Eliminate eviction loops. And don't OOM so often with storage providers set
Former-commit-id: 189674aea74c483bf0869050ecf7bf2b0b49f34e
2020-07-11 04:23:35 +00:00
John Sully 8256661b7a Bump version
Former-commit-id: ee5a281ed0012aca359b9448df5236bef719f4a7
2020-07-10 04:13:42 +00:00
John Sully 2cc88a96ab Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 243dcb3853cc965109cb24a940229db7844cdd11
2020-07-10 04:11:57 +00:00
John Sully dab9d8d90b Merge branch 'mvcc_scan' into keydbpro
Former-commit-id: f0a3f491b61a9bb7ee4ab86098958cb161b75f59
2020-07-10 03:44:20 +00:00
John Sully 2192c97d35 MVCC scan support filtering by type on the async thread
Former-commit-id: 14f8c0ff686b93976eead5fa6bf526c2eecb5ae0
2020-07-10 03:43:56 +00:00
John Sully 3692771457 Fix issue where SCAN misses elements while snapshot is in flight
Former-commit-id: ce005d748ebf0e116d674a96f74d698d17394010
2020-07-10 01:43:51 +00:00
John Sully 1fef6c42b7 Disable MVCC GET, the overhead is not worth it
Former-commit-id: 8c7e1001e98be0d0e6fe0079fc9406d5d65366ff
2020-07-10 01:43:32 +00:00
John Sully 4ec5c3eb31 Fix issue where we fail to return all data
Former-commit-id: 7341c9ed14d13386a045afd6deda9c0db422cd5f
2020-07-10 00:18:10 +00:00
John Sully 2db9eef2b1 Graceful shutdown running async jobs
Former-commit-id: 2ce5b94741d384b2dfd6d3b347fa1582cd45df8f
2020-07-10 00:17:39 +00:00
John Sully 993359e1bb Fix race in db iterators in scan
Former-commit-id: a6444870660c0d3f52cd7b1dc0b80223f0d58e70
2020-07-09 22:29:27 +00:00
John Sully bce5cb098b Do actual filtering on the async thread
Former-commit-id: 64b17139b7b5ff55bb52f27dc6f91cb81adde031
2020-07-09 21:58:06 +00:00
John Sully 29e4973d7b Initial scan implementation (not tested)
Former-commit-id: 0f3911d56e6878d91b6e3cacc7d637934ffe6099
2020-07-09 12:57:35 -04:00
John Sully ffc3aefc41 Latency fixes
Former-commit-id: 6857c4c208
2020-07-01 21:59:38 -04:00
Muhammad Zahalqa f024fe30f4 replace memcpy with cctor on objects
Former-commit-id: 52897f8f9a
2020-06-24 23:20:59 -04:00
Muhammad Zahalqa ec28161271 unique lock used with cv.wait already owns mutex
Former-commit-id: 8bc70e9840
2020-06-24 23:18:53 -04:00
Muhammad Zahalqa 63bb6cb419 Fix bug in condition_variabe.wait usage
consition variable wait should always be called with a locked mutex.
This code break the pre-conditions of using wait.


Former-commit-id: 5b81303f04
2020-06-24 23:18:53 -04:00
Muhammad Zahalqa e25ec37484 fixes for robj_sharedptr
1. fix cases where null pointer might be accessed
2. make assignmnet op safe
3. make operator bool explicit (safe bool idiom)
4. make comparison operators symetric

fix robj_sharedptr use in rdb.cpp


Former-commit-id: ede524c064
2020-06-24 23:18:27 -04:00
Muhammad Zahalqa c4cd846388 aeCommand objects no need for memset and missing init of some memebers.
Former-commit-id: aeed09c346
2020-06-24 23:15:29 -04:00
benschermel cd8b82db55 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 6e9ec7ae3ca49a6054f012e567eb74307227c330
2020-06-24 00:34:35 -04:00
benschermel 9c2769804e update deb changelog
Former-commit-id: 85fe16238fdb692067f77f631b0589366823ba34
2020-06-24 00:32:10 -04:00
John Sully 638926621a Merge PKG files from unstable
No code change


Former-commit-id: 42c4d85d72
2020-06-24 00:16:21 -04:00
Ben Schermel 4d6b7c278b bump version after merge
Former-commit-id: 59279d36e9337ca89518c4d1edef6c26911ea190
2020-06-16 14:17:20 -04:00
Ben Schermel e0d2a1cff6 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: cf7ed118553af55a27c3a57c121bc26e18e0ab7e
2020-06-16 14:16:03 -04:00
Ben Schermel 38f5ed20a0 Merge branch 'PRO_RELEASE_6' of https://github.com/JohnSully/KeyDB-Pro into PRO_RELEASE_6
Former-commit-id: ff7ec3ec39d692ed59c945ace5c9a4ec140f5e52
2020-06-16 14:15:51 -04:00
John Sully e81a4a159a Fix crash in async delete when storage provider is not set and key doesn't actually exist
Former-commit-id: 4a4828390118ab52851d8bf229c4ae853100053c
2020-06-15 19:47:06 -04:00
antirez d05cc51e4e help.h updated. 2020-06-12 12:16:24 +02:00
antirez 3dc6657ea8 LPOS: tests + crash fix. 2020-06-12 12:08:06 +02:00
antirez 010dd2b320 LPOS: update to latest proposal.
See https://gist.github.com/antirez/3591c5096bc79cad8b5a992e08304f48
2020-06-12 12:08:06 +02:00
antirez 00e400ed66 LPOS: implement the final design. 2020-06-12 12:08:06 +02:00
Paul Spooren 795c807fed LRANK: Add command (the command will be renamed LPOS).
The `LRANK` command returns the index (position) of a given element
within a list. Using the `direction` argument it is possible to specify
going from head to tail (acending, 1) or from tail to head (decending,
-1). Only the first found index is returend. The complexity is O(N).

When using lists as a queue it can be of interest at what position a
given element is, for instance to monitor a job processing through a
work queue. This came up within the Python `rq` project which is based
on Redis[0].

[0]: https://github.com/rq/rq/issues/1197

Signed-off-by: Paul Spooren <mail@aparcar.org>
2020-06-12 12:08:06 +02:00
Ben Schermel 9e9064782d Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 97280cec291bca779739e008b9467fbb40a19a5f
2020-06-10 17:35:21 -04:00
Ben Schermel b301f19c7e Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: f70e34b999ba842617ed39b88a7f5bb453d570c5
2020-06-10 17:27:34 -04:00
John Sully ab9e3f1d2a Fix failure to find expire during rehash
Former-commit-id: b66269865cb71a5e1dd33588b012206da2765824
2020-06-10 12:48:54 -04:00
John Sully 15e2b066f3 Bump version
Former-commit-id: c7b16835b1c52e9d8a4859a5b6e42ea5f6a31df2
2020-06-09 21:03:11 -04:00
John Sully 10908dc384 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 9d8d3a54fdb9eaad0a7cfc3d938fa35d2819fa93
2020-06-09 21:02:55 -04:00
John Sully 29faa06028 Fix assert false alarm when freeTombstoneObjects is called
Former-commit-id: e21a011072505cfa0a37afefb94f7270e80625c5
2020-06-09 20:59:09 -04:00
John Sully ec01cc23b1 Fix lock inversion
Former-commit-id: 430cf88623fce8f0675ea19f73d98f6cafe9070f
2020-06-09 20:58:03 -04:00
John Sully 324e8e01f2 COW pointer is not thread safe so we need a global expire lock
Former-commit-id: ac12eef75301564d920e622a08e4f586486fd395
2020-06-09 19:58:42 -04:00
John Sully 725fa84a06 keys command should look at the snapshots expire datastructure
Former-commit-id: 70563afab48e607e127c07d637660d94d1eede6d
2020-06-09 18:57:36 -04:00
John Sully 49fecbe1d4 Implement replicaof remove as requested in issue #192
Former-commit-id: 70b80aa5fa
2020-06-09 12:43:58 -04:00
antirez ce8f107a5e Redis 6.0.5. 2020-06-09 12:19:30 +02:00
antirez 93e76ba456 Adapt EVAL+busy script test to new behavior. 2020-06-09 12:19:30 +02:00
antirez e819e3ee26 Temporary fix for #7353 issue about EVAL during -BUSY. 2020-06-09 11:53:01 +02:00
xhe 5fae6590a1 return the correct proto version
HELLO should return the current proto version, while the code hardcoded
3
2020-06-09 11:53:01 +02:00
Oran Agra 640a4479b0 Don't queue commands in an already aborted MULTI state 2020-06-09 11:53:01 +02:00
Oran Agra 881d2c4663 Avoid rejecting WATCH / UNWATCH, like MULTI/EXEC/DISCARD
Much like MULTI/EXEC/DISCARD, the WATCH and UNWATCH are not actually
operating on the database or server state, but instead operate on the
client state. the client may send them all in one long pipeline and check
all the responses only at the end, so failing them may lead to a
mismatch between the client state on the server and the one on the
client end, and execute the wrong commands (ones that were meant to be
discarded)

the watched keys are not actually stored in the client struct, but they
are in fact part of the client state. for instance, they're not cleared
or moved in SWAPDB or FLUSHDB.
2020-06-09 11:53:01 +02:00
zhaozhao.zz d496ce7271 AOF: append origin SET if no expire option 2020-06-09 11:53:01 +02:00
Oran Agra 216b5a1aae fix disconnectSlaves, to try to free each slave.
the recent change in that loop (iteration rather than waiting for it to
be empty) was intended to avoid an endless loop in case some slave would
refuse to be freed.

but the lookup of the first client remained, which would have caused it
to try the first one again and again instead of moving on.
2020-06-09 11:53:01 +02:00
zhaozhao.zz 2a8ee55176 donot free protected client in freeClientsInAsyncFreeQueue
related #7234
2020-06-09 11:53:01 +02:00
Ben Schermel 18527706b6 fix issues from rebase
Former-commit-id: 5d7cc28208bbe7b49eed0d1b1c2bb1c31e65e865
2020-06-09 00:10:58 -04:00
Ben Schermel c6dea493ac update Dockerfile
Former-commit-id: 3f8dcfdf865ca0857bf2d5261b858cc3daa22f3f
2020-06-09 00:10:58 -04:00
Ben Schermel e0ab07a560 updating changelog
Former-commit-id: 5affe6dd268bb333214f70f5f809050e4b00b28b
2020-06-09 00:10:58 -04:00
Ben Schermel aecd839fa9 dh9 for stretch deb pkg
Former-commit-id: 5cf02197ba418b5302759c14195ffa33a1db70fe
2020-06-09 00:10:58 -04:00
Ben Schermel 6f52e35b02 fix missing sentinel
Former-commit-id: 01fe9274e8cb73a065d8550f220d07e5eacd0156
2020-06-09 00:10:58 -04:00
Ben Schermel 267c11b427 update changelog
Former-commit-id: e2be81157e9cd1f57b9d734c5536dc0f4d5dbb0b
2020-06-09 00:10:58 -04:00
Ben Schermel 6eac8be435 update changelog
Former-commit-id: f0fe6c6b3f249a919ad5f4a233049c7a931bf5cc
2020-06-09 00:10:58 -04:00
Ben Schermel 7be2964052 update changelog
Former-commit-id: 5acb71ac79be4b0404fc56e82485a28f9664a017
2020-06-09 00:10:58 -04:00
Ben Schermel 267b7e72ef update changelog
Former-commit-id: adb5f42d945960cbe153e3614a1126972c8ce841
2020-06-09 00:10:58 -04:00
Ben Schermel d7a1fe14a8 include support for dists < dh11
Former-commit-id: 1930b759a9acce126342709acfb7884649023f3d
2020-06-09 00:10:58 -04:00
Ben Schermel ada1407ac8 enable source build from dh9 where applicable
Former-commit-id: 9e8ea41f73674fb836f89e5d53474b271abf10d8
2020-06-09 00:10:58 -04:00
Ben Schermel 33afd43dde update rpm versioning
Former-commit-id: a3ccaeee78279356ec70b136df07026a9fdd43d7
2020-06-09 00:10:58 -04:00
Ben Schermel 46e96f23a4 fix rpmbuild dirs
Former-commit-id: 2cf077e6d3bc98cf75120185c7985030b0aa4040
2020-06-09 00:10:58 -04:00
Ben Schermel c8e6e23fb8 fix rpmbuild directories
Former-commit-id: 185b6459b065c740990ca503fad880e87d15c436
2020-06-09 00:10:58 -04:00
Ben Schermel ac1e1cec8b fix rpmbuild directories
Former-commit-id: 314639460f4959ad6f9d4342d5baa6ad4446e7d4
2020-06-09 00:10:58 -04:00
Ben Schermel 7778eb248b use dh_installsystemd
Former-commit-id: 9d6d4fba41550442bf04153dc6d6f19a42afb207
2020-06-09 00:10:58 -04:00
Ben Schermel 7b1ae4ceb9 adding dh_installsystemd
Former-commit-id: 39817055d85b4f6a0d575b94737f1b1b2c952708
2020-06-09 00:10:58 -04:00
Ben Schermel 9e067c12c7 fix pkg errors
Former-commit-id: 91ef1a50fb8602c7f09156a84eca17dca70b3d2e
2020-06-09 00:10:58 -04:00
Ben Schermel 54b1e673ce adding packaging
Former-commit-id: 108c58ba5333129eabf64f775e69f5cb7b6cbdf9
2020-06-09 00:10:58 -04:00
John Sully 8503b69bf9 Merge branch 'unstable' into keydbpro
Former-commit-id: ca3a50537e987bd30aec38265be535d89bb260f3
2020-06-08 16:51:16 -04:00
John Sully 76070d51a6 Update gcov for C++
Former-commit-id: e8d4d095cc
2020-06-08 16:48:44 -04:00
Ben Schermel 804f45b86f update Dockerfile
Former-commit-id: c50a3568a5
2020-06-08 15:34:22 -04:00
Ben Schermel d46b26cbc5 updating changelog
Former-commit-id: 17e96b91b5
2020-06-08 15:34:22 -04:00
Ben Schermel 5213d7e873 dh9 for stretch deb pkg
Former-commit-id: c5e7a8517b
2020-06-08 15:34:22 -04:00
Ben Schermel 0cd8d8abb7 fix missing sentinel
Former-commit-id: c36773777d
2020-06-08 15:34:22 -04:00
Ben Schermel 10ebe65658 update changelog
Former-commit-id: d69e0b8561
2020-06-08 15:34:22 -04:00
Ben Schermel 110cc2d6fc update changelog
Former-commit-id: 19ccc22a43
2020-06-08 15:34:22 -04:00
Ben Schermel a38376bf37 update changelog
Former-commit-id: 6968a0cfcb
2020-06-08 15:34:22 -04:00
Ben Schermel 5969877486 include support for dists < dh11
Former-commit-id: df618fbd9f
2020-06-08 15:34:22 -04:00
Ben Schermel b3dbf5d520 fix rpmbuild dirs
Former-commit-id: 94acd43340
2020-06-08 15:34:22 -04:00
Ben Schermel 4fe2e7d6fe fix rpmbuild dirs
Former-commit-id: 14bdd745d1
2020-06-08 15:34:22 -04:00
Ben Schermel b36b726312 adding dh_installsystemd
Former-commit-id: aa3f5de16f
2020-06-08 15:34:22 -04:00
Ben Schermel 58823a969f strip unused from deb source
Former-commit-id: 9f7890cb1a
2020-06-08 15:34:22 -04:00
benschermel f03f51694c add deb/rpm/docker support
Former-commit-id: 1dc34c16b5
2020-06-08 15:34:22 -04:00
benschermel d279e38f8c add deb/rpm/docker support
Former-commit-id: b0e7be7ce2
2020-06-08 15:34:22 -04:00
benschermel 1f331f05ef update github CI for deb
Former-commit-id: 026ab4c922
2020-06-08 15:34:22 -04:00
Ben Schermel 628a9d5cd1 update rpm versioning
Former-commit-id: 07ba64c200
2020-06-08 15:34:22 -04:00
benschermel 5ebad6291f add package utilities
Former-commit-id: b4b35cf904
2020-06-08 15:34:22 -04:00
John Sully ad4d76422c Some valgrind fixes
Former-commit-id: ba974c9810
2020-06-07 23:20:10 -04:00
John Sully f252cc9e41 fix valgrind false error
Former-commit-id: 9817db7edd
2020-06-07 20:17:47 -04:00
John Sully 27f454bafc fix valgrind false error
Former-commit-id: 887d8bdd110e04b30ffb215726e8aade39f0387a
2020-06-07 20:17:32 -04:00
John Sully 46f14ffc54 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 3106f60e0ebdba5db944e704d4b148ea81c806f6
2020-06-07 17:05:00 -04:00
John Sully 3004ca80a4 Fix merge bug
Former-commit-id: cc03c32271997d26ce7f07f96588f126c5939e69
2020-06-07 17:04:46 -04:00
John Sully 08842f8d6e Endurance mode for tests ignore flaky ones
Former-commit-id: 515bb0e6bd
2020-06-07 16:59:59 -04:00
John Sully 00ae6d58a9 Bump version
Former-commit-id: 4a3e1f3b9b
2020-06-07 16:43:07 -04:00
John Sully f26d5048cd Solo tests should work with loopn
Former-commit-id: 575fc98010
2020-06-07 16:43:07 -04:00
John Sully 3c63be7159 Stream tests rely on deferring clients, mitigate races caused by them
Former-commit-id: eb18345a61
2020-06-07 16:43:07 -04:00
John Sully cb7b03aeea replication test race
Former-commit-id: d528c5c2c2
2020-06-07 16:43:07 -04:00
John Sully 3b083f4ed9 fix race in test
Former-commit-id: fa03a539f3
2020-06-07 16:43:07 -04:00
John Sully 668d482f08 Make lazyfree more reliable
Former-commit-id: 9646b1d944
2020-06-07 16:43:07 -04:00
John Sully 55633ab401 Detect issues like #189
Former-commit-id: cc5e906ebd
2020-06-07 16:43:07 -04:00
John Sully d0d24e04f0 Ensure CRON jobs run in a clean environment
Former-commit-id: b0e14683b2
2020-06-07 16:43:07 -04:00
John Sully e2cd106d2d Undecorated new is OK to use
Former-commit-id: 8d5cc4cf0c
2020-06-07 16:43:07 -04:00
John Sully 16f86db5e4 Bump version
Former-commit-id: 52a0556ba15b26d84ca9b5c804eb8fe438c9c888
2020-06-07 16:41:59 -04:00
John Sully 8c24082f87 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 6495fe1c7878f96dffa25a2879cb2b825c9e10b2
2020-06-07 16:41:36 -04:00
John Sully 4001a99481 Merge branch 'unstable' into keydbpro
Former-commit-id: 461eea07260a31cd75753d5b7be691f5793a6f1b
2020-06-07 16:41:21 -04:00
John Sully d1208196ee Report flash disk usage
Former-commit-id: 8e4a71ccd31e3c643a6f7b5154d8f2a65d2de76f
2020-06-07 16:40:03 -04:00
John Sully 0120d23a48 Solo tests should work with loopn
Former-commit-id: bc7ea8fb20
2020-06-07 15:06:50 -04:00
John Sully 97908941bf Stream tests rely on deferring clients, mitigate races caused by them
Former-commit-id: 2caf8e4c80
2020-06-07 13:59:41 -04:00
John Sully 7384abfe56 replication test race
Former-commit-id: e1f3cd6ec3
2020-06-07 01:14:57 -04:00
John Sully c60bf228b4 fix race in test
Former-commit-id: 02e821530a
2020-06-07 00:44:11 -04:00
John Sully ebf5d2826a Make lazyfree more reliable
Former-commit-id: b6c3d80edb
2020-06-07 00:40:58 -04:00
Oran Agra fed743b2e1 fix pingoff test race 2020-06-06 11:44:21 +02:00
Kevin Fwu ce014c2a3b Fix TLS certificate loading for chained certificates.
This impacts client verification for chained certificates (such as Lets
Encrypt certificates). Client Verify requires the full chain in order to
properly verify the certificate.
2020-06-06 11:44:21 +02:00
antirez bec1ac9899 Revert "Implements sendfile for redis."
This reverts commit 5675053269.
2020-06-06 11:43:29 +02:00
antirez 8bfdba1e08 Revert "avoid using sendfile if tls-replication is enabled"
This reverts commit 13bbd165e8.
2020-06-06 11:43:29 +02:00
Liu Zhen 123d94ffc0 fix clusters mixing accidentally by gossip
`clusterStartHandshake` will start hand handshake
and eventually send CLUSTER MEET message, which is strictly prohibited
in the REDIS CLUSTER SPEC.
Only system administrator can initiate CLUSTER MEET message.
Futher, according to the SPEC, rather than IP/PORT pairs, only nodeid
can be trusted.
2020-06-06 11:43:29 +02:00
antirez a5f0fa7f7a Fix handling of special chars in ACL LOAD.
Now it is also possible for ACL SETUSER to accept empty strings
as valid operations (doing nothing), so for instance

    ACL SETUSER myuser ""

Will have just the effect of creating a user in the default state.

This should fix #7329.
2020-06-06 11:43:29 +02:00
John Sully 8f8015bb22 Detect issues like #189
Former-commit-id: 0042586190
2020-06-05 22:18:28 -04:00
John Sully 779023beff Ensure CRON jobs run in a clean environment
Former-commit-id: c6dce838b7
2020-06-05 21:35:47 -04:00
John Sully 848cd33d51 We need to search snapshots before deciding to not save a key
Former-commit-id: 357b09c500eecfe61970e121644a7200ac2387b9
2020-06-05 00:39:58 -04:00
John Sully a0e502684d Fix dangling lock
Former-commit-id: 212e56984edfa3221c73b1d3c083efcd28f0dd25
2020-06-04 22:59:24 -04:00
John Sully 9204f7b629 Fix race when we free an item before we finish writing to disk making it temporarily unavailable
Former-commit-id: 6139cfee295261d0210f2af6217c2a23eeaf52b8
2020-06-04 22:18:03 -04:00
John Sully e522540e2f Add latency marker for process changes phase for FLASH
Former-commit-id: 61e20b025d45b0af8ed60aab96246b30e4d0ed3d
2020-06-04 01:29:17 -04:00
John Sully bec9bb1e0f Latency doctor updated for KeyDB Pro
Former-commit-id: a2690fca4a74e92eb44d5e38f886b08363a6d7b0
2020-06-04 01:28:52 -04:00
John Sully 689c1354be maxmem samples way too high
Former-commit-id: 599cac856d4ec77d59c5f5b4fae5b9f194c202ef
2020-06-04 01:28:34 -04:00
John Sully 8888498bfd Make snapshot completion faster and add latency monitor
Former-commit-id: 8063be6ee70a652c22c3263dccf318366e208891
2020-06-04 01:07:14 -04:00
John Sully cb4bb9d7eb Consolidate snapshots should not consider keys in bulk storage
Former-commit-id: e02a8f503d45daf63150c60a8a8c3751b9b8581e
2020-06-04 00:26:51 -04:00
John Sully e7586ddca1 Disambiguate temp rdb files so its less likely two servers with the same working dir will collide
Former-commit-id: 8fbc5a63c54589bb42aa1b1b53c56f399211605c
2020-06-04 00:25:37 -04:00
John Sully f50ed30ad2 Only set tombstone if there is something to mask
Former-commit-id: ea092693f53ff0803c44a851219993a933166cc3
2020-06-04 00:23:37 -04:00
John Sully 28397f140a Extra debug checks in dictmerge
Former-commit-id: 839b2a151e6bad67017de87d7a637359f6ae63d1
2020-06-04 00:22:59 -04:00
John Sully b39f917335 Clear tombstone dict when clearing database we don't need it
Former-commit-id: a8e1ef075eacfc0b767302f2514ca6f0342982bc
2020-06-04 00:17:19 -04:00
John Sully 4cf14b6e49 Fix crash where tombstone is evicted
Former-commit-id: 1f6ff7cc0fc0173610d77a69076eeaf478c3b701
2020-06-03 23:30:35 -04:00
John Sully 1f9ca52b35 RocksDB compression is too slow
Former-commit-id: 665a8ff0a0a10ffecc36a8410030abd73879944c
2020-06-03 22:21:03 -04:00
John Sully cebc1b7e48 Add DB commit latency samples
Former-commit-id: 557ea8d285045496105e3330f0007e02aa4359d7
2020-06-03 22:06:05 -04:00
John Sully 589448bdf0 Fix crash when overwriting key stored in FLASH but not in ram during a BGSAVE while clustering is enabled
Former-commit-id: 32967b1d671b151bed976e3d13ce26c7e1496c82
2020-06-02 23:59:24 -04:00
John Sully f0849df48c Endurance not setup for pro
Former-commit-id: 97ad41effac1322a4ad14c441e23838bb20528da
2020-06-02 23:47:13 -04:00
John Sully 638993d992 Fix unmerged script
Former-commit-id: bb0df646cf4362b7f56b29ded89d167fc0f832a9
2020-06-02 21:16:24 -04:00
John Sully ffbd43fbfa Bump maxmemory samples by a lot
Former-commit-id: ae46d64b2e6b16f81df6b4e12ddc9fed63a9785b
2020-06-02 17:22:45 -04:00
John Sully ad174ab352 Merge error, server always flushes on eviction
Former-commit-id: 9b3b0c9a40ab5dcdac9620f0fbad84887cc9c832
2020-06-02 17:21:41 -04:00
John Sully 64adf015b1 Undecorated new is OK to use
Former-commit-id: 5b885bb164
2020-06-01 23:36:01 -04:00
John Sully 8bdca52222 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: a901505e562c0dc341fa939cce502da25642f7ba
2020-06-01 17:42:32 -04:00
John Sully 69a4ab0851 Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: dd8cd6a00851b00120db9e52030c0bb85d15b54f
2020-06-01 17:42:09 -04:00
John Sully df3f1e8d8e Merge branch 'unstable' into keydbpro
Former-commit-id: 08a36155e3db9918048e87c3d691b7317787c9ab
2020-06-01 17:41:37 -04:00
John Sully a90ff44fb8 RELEASE endurance tests should run offset from unstable
Former-commit-id: b608acb349
2020-06-01 17:02:16 -04:00
John Sully c799f6855b Bump version
Former-commit-id: 8dbea2a050
2020-06-01 17:01:50 -04:00
John Sully 419720d5ef maxmem tests should be run solo for higher reliability
Former-commit-id: 95f46e6077
2020-06-01 16:50:30 -04:00
John Sully b2a885c98f Remove debug logs that shouldn't have been checked in
Former-commit-id: 31f58311e3
2020-06-01 16:34:05 -04:00
John Sully 4820142896 PSYNC test shouldn't wait forever
Former-commit-id: 130613e166
2020-06-01 16:13:58 -04:00
John Sully 92de178bfe PSYNC test reliability improvements (test only issue)
Former-commit-id: 50fd4fa7e6
2020-06-01 16:01:26 -04:00
John Sully 9e87395c34 Fix for issue #187 we need to properly handle the case where a key with a subkey expirey itself expires during load
Former-commit-id: e6a9a6b428
2020-06-01 15:33:19 -04:00
John Sully 02d602b3fd Update endurance.yml
Former-commit-id: d6be93537e
2020-06-01 00:25:31 -04:00
John Sully 0a9a32e5d7 Fix module multithreaded test failures
Former-commit-id: 1ef35cf466
2020-05-31 23:46:12 -04:00
John Sully 08fca5ef31 sendfile has high latency in some scenarios, don't use it
Former-commit-id: 1eb0e3c1c6
2020-05-31 23:22:25 -04:00
John Sully b30fa046f4 we must always respect the output of sdscat, also change the string so its not a substring of other config params
Former-commit-id: e50313b207
2020-05-31 23:22:10 -04:00
John Sully 9b9c54b4ce Do another iteration for endurance
Former-commit-id: ac3f8d1ac7
2020-05-31 22:51:02 -04:00
John Sully 4b317392be Don't start multimaster tests until all nodes are connected
Former-commit-id: 202b97eff7
2020-05-31 22:50:30 -04:00
John Sully de0540d34b Fix client race in test (test only issue)
Former-commit-id: f25aebf269
2020-05-31 21:39:50 -04:00
John Sully dd45ade779 --loop should run forever
Former-commit-id: 9b1e636a66
2020-05-31 21:27:15 -04:00
John Sully 9ab9a7684d PUBSUB test reliability: A client race was erroneously failing tests (test only issue)
Former-commit-id: 5147f0153a
2020-05-31 21:27:15 -04:00
John Sully 8919c770fe Update endurance.yml
Former-commit-id: 88f7739ae0
2020-05-31 17:50:02 -04:00
John Sully 7eb0563241 Active replicas referencing eachother should connect one at a time
Former-commit-id: c0c033a0c1
2020-05-31 16:03:50 -04:00
John Sully 891977d9b7 Fix race in futex_sleep
Former-commit-id: 73300c5700
2020-05-31 16:03:50 -04:00
John Sully 4a110615f3 Update endurance.yml
Former-commit-id: 37033179fe
2020-05-31 14:18:12 -04:00
John Sully e00b2a6386 Update endurance.yml
Former-commit-id: 3e6a5ac9cf
2020-05-31 03:43:06 -04:00
John Sully 412df47945 Endurance tests need more cores
Former-commit-id: dcd297eb5b
2020-05-30 22:16:56 -04:00
John Sully b58db1f7b9 Update endurance.yml
Former-commit-id: 4a9742e696
2020-05-30 20:03:04 -04:00
John Sully d344d9b0b9 Auto tune lock for high CPU tension scenarios
Former-commit-id: 8edbae2e04
2020-05-30 18:22:27 -04:00
John Sully 003dfea7f9 Ensure endurance run can complete in an hour
Former-commit-id: 63c6735ffc
2020-05-30 15:31:54 -04:00
John Sully baadab90e7 We only want one master connection in progress at a time, ensure that if the connection fails we try a different master
Former-commit-id: 8a0441c144
2020-05-30 15:13:28 -04:00
John Sully fcf183e4b5 daily CI config fix
Former-commit-id: 460c5ed2b3
2020-05-30 03:27:37 -04:00
John Sully 8fec593def More clients for endurance
Former-commit-id: 8f44f0937b
2020-05-30 03:13:04 -04:00
John Sully 73db61ea86 Endurance tests need to be faster, reduce loops
Former-commit-id: 1803b1587b
2020-05-30 02:40:44 -04:00
John Sully e48e8511ec Only CI ARM daily
Former-commit-id: a5325061f2
2020-05-30 02:34:37 -04:00
John Sully cc49720fd5 Also test with multiple threads
Former-commit-id: a10a0df09f
2020-05-30 02:10:00 -04:00
John Sully aedbb558ab Reduce clients for endurance test
Former-commit-id: 031044c7ea
2020-05-30 02:07:30 -04:00
John Sully d3b89c69ad Fix cron syntax
Former-commit-id: ca755e4905
2020-05-30 01:53:21 -04:00
John Sully 76b5b55da9 Add endurance CI tests
Former-commit-id: 3063a028b3
2020-05-30 01:47:26 -04:00
John Sully 7000884239 Update daily CI job
Former-commit-id: 2c659acc7d
2020-05-30 01:21:50 -04:00
John Sully f37ee5bd4d TLS requires we explicitly marshal connected sockets when using them on a different thread
Former-commit-id: 341a8caef9
2020-05-30 01:14:53 -04:00
John Sully ed77c35b15 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 366f8c2dc6
2020-05-30 00:06:23 -04:00
John Sully bbff81e891 Fix memory test failures with multithreading enabled
Former-commit-id: 5803540422
2020-05-30 00:06:15 -04:00
Ben Schermel be6f1df429 centos build fix
Former-commit-id: f17c492a63
2020-05-29 22:23:48 -04:00
Ben Schermel 9936463c07 centos build fix
Former-commit-id: 6fe4571bf959432127b8741c22d8264fd55969b8
2020-05-29 22:21:01 -04:00
John Sully 5316f656d9 sendFile blocks too long for use with active replication
Former-commit-id: aad6a7ce15
2020-05-29 20:27:45 -04:00
John Sully 68bf5a04a0 Unify beforeSleep handling
Former-commit-id: 1cb48c7bf6
2020-05-29 17:44:55 -04:00
John Sully f18ba66242 Cluster crash
Former-commit-id: f25c405ad2
2020-05-29 03:40:52 -04:00
John Sully 2e0c684324 active replica tests on slow computers
Former-commit-id: c9920849dd
2020-05-29 01:58:15 -04:00
John Sully 688dceb3a8 Fix test issue with TLS
Former-commit-id: 81b240f81d
2020-05-29 01:44:52 -04:00
John Sully f79cc0011a Fix CI
Former-commit-id: 6a902b29e1
2020-05-29 01:01:41 -04:00
John Sully ed2e0e66f6 Merge tag '6.0.4' into unstable
Redis 6.0.4.


Former-commit-id: 9c31ac7925
2020-05-29 00:57:07 -04:00
John Sully a768c260dc Fix TLS tests
Former-commit-id: f0d8d1680f
2020-05-29 00:16:06 -04:00
John Sully 34d3bac791 gencert its own step
Former-commit-id: 6dcbcacb10
2020-05-28 23:49:13 -04:00
John Sully 8bb3ac40f1 CI yml syntax error
Former-commit-id: 3196717cee
2020-05-28 23:18:02 -04:00
John Sully f4f9e83ead Fix TLS tests in CI
Former-commit-id: f95578ac02
2020-05-28 23:16:42 -04:00
John Sully 71fbeb65b6 fix TLS test failure
Former-commit-id: 57ca6facc3
2020-05-28 23:16:27 -04:00
antirez c512f64428 Redis 6.0.4. 2020-05-28 12:18:38 +02:00
antirez 41bb699867 Test: take PSYNC2 test master timeout high during switch.
This will likely avoid false positives due to trailing pings.
2020-05-28 10:56:14 +02:00
antirez 40578433c7 Test: add the tracking unit as default. 2020-05-28 10:22:29 +02:00
Oran Agra 571b03021a tests: find_available_port start search from next port
i.e. don't start the search from scratch hitting the used ones again.
this will also reduce the likelihood of collisions (if there are any
left) by increasing the time until we re-use a port we did use in the
past.
2020-05-28 10:09:51 +02:00
Oran Agra 4653d796f0 tests: each test client work on a distinct port range
apparently when running tests in parallel (the default of --clients 16),
there's a chance for two tests to use the same port.
specifically, one test might shutdown a master and still have the
replica up, and then another test will re-use the port number of master
for another master, and then that replica will connect to the master of
the other test.

this can cause a master to count too many full syncs and fail a test if
we run the tests with --single integration/psync2 --loop --stop

see Probmem 2 in #7314
2020-05-28 10:09:51 +02:00
Oran Agra 31bd963557 32bit CI needs to build modules correctly 2020-05-28 10:09:51 +02:00
Oran Agra 01039e5964 adjust revived meaningful offset tests
these tests create several edge cases that are otherwise uncovered (at
least not consistently) by the test suite, so although they're no longer
testing what they were meant to test, it's still a good idea to keep
them in hope that they'll expose some issue in the future.
2020-05-28 10:09:51 +02:00
Oran Agra 98e6f2cd5b revive meaningful offset tests 2020-05-28 10:09:51 +02:00
antirez 84117d13b7 Replication: showLatestBacklog() refactored out. 2020-05-28 10:09:51 +02:00
antirez 14d99c183f Drop useless line from replicationCacheMaster(). 2020-05-28 10:09:51 +02:00
antirez 0163e4e495 Another meaningful offset test removed. 2020-05-28 10:09:51 +02:00
antirez 24a0f7bf55 Remove the PSYNC2 meaningful offset test. 2020-05-28 10:09:51 +02:00
antirez 911c579b68 Remove the meaningful offset feature.
After a closer look, the Redis core devleopers all believe that this was
too fragile, caused many bugs that we didn't expect and that were very
hard to track. Better to find an alternative solution that is simpler.
2020-05-28 10:09:51 +02:00
antirez 7e55485b21 Set a protocol error if master use the inline protocol.
We want to react a bit more aggressively if we sense that the master is
sending us some corrupted stream. By setting the protocol error we both
ensure that the replica will disconnect, and avoid caching the master so
that a full SYNC will be required. This is protective against
replication bugs.
2020-05-28 10:09:51 +02:00
Oran Agra abb9dcd975 daily CI test with tls 2020-05-28 10:09:51 +02:00
Oran Agra 0705a29959 avoid using sendfile if tls-replication is enabled
this obviously broke the tests, but went unnoticed so far since tls
wasn't often tested.
2020-05-28 10:09:51 +02:00
antirez fee0c76304 Replication: log backlog creation event. 2020-05-28 10:09:51 +02:00
antirez 2411e4e33f Test: PSYNC2 test can now show server logs. 2020-05-28 10:09:51 +02:00
John Sully d9164a07b5 Test TLS as part of CI
Former-commit-id: 561a1f8d8a
2020-05-26 01:39:54 -04:00
John Sully 8ff703992c Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: f98c1999f95ec59f7201056781cb89dc465a1461
2020-05-26 01:38:52 -04:00
John Sully ef32f81fd9 Complete TLS merge
Former-commit-id: 856d23023259d59ce766e9cd00526de0e7d06c2f
2020-05-26 01:38:29 -04:00
John Sully f617eafbe1 Merge branch 'unstable' into keydbpro
Former-commit-id: b0636273806ce323627ce31c1ad7f86ceb39696d
2020-05-26 01:34:19 -04:00
John Sully ef4284c439 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 1449c8b9fe
2020-05-26 01:29:08 -04:00
John Sully 5b44b62854 Fix client tracking, also ensure tracking tests are enabled
Former-commit-id: 1938af27f5
2020-05-26 01:28:52 -04:00
antirez 7a32a8485e Clarify what is happening in PR #7320. 2020-05-25 12:08:01 +02:00
zhaozhao.zz d089cc8963 PSYNC2: second_replid_offset should be real meaningful offset
After adjustMeaningfulReplOffset(), all the other related variable
should be updated, including server.second_replid_offset.

Or the old version redis like 5.0 may receive wrong data from
replication stream, cause redis 5.0 can sync with redis 6.0,
but doesn't know meaningful offset.
2020-05-25 12:08:01 +02:00
Oran Agra 1f5163f454 add CI for 32bit build 2020-05-25 12:08:01 +02:00
antirez 8a4e01f2bc Make disconnectSlaves() synchronous in the base case.
Otherwise we run into that:

Backtrace:
src/redis-server 127.0.0.1:21322(logStackTrace+0x45)[0x479035]
src/redis-server 127.0.0.1:21322(sigsegvHandler+0xb9)[0x4797f9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fd373c5e390]
src/redis-server 127.0.0.1:21322(_serverAssert+0x6a)[0x47660a]
src/redis-server 127.0.0.1:21322(freeReplicationBacklog+0x42)[0x451282]
src/redis-server 127.0.0.1:21322[0x4552d4]
src/redis-server 127.0.0.1:21322[0x4c5593]
src/redis-server 127.0.0.1:21322(aeProcessEvents+0x2e6)[0x42e786]
src/redis-server 127.0.0.1:21322(aeMain+0x1d)[0x42eb0d]
src/redis-server 127.0.0.1:21322(main+0x4c5)[0x42b145]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fd3738a3830]
src/redis-server 127.0.0.1:21322(_start+0x29)[0x42b409]

Since we disconnect all the replicas and free the replication backlog in
certain replication paths, and the code that will free the replication
backlog expects that no replica is connected.

However we still need to free the replicas asynchronously in certain
cases, as documented in the top comment of disconnectSlaves().
2020-05-25 12:08:01 +02:00
ShooterIT fc18f9a798 Implements sendfile for redis. 2020-05-25 12:08:01 +02:00
antirez ed3fd6c524 Fix #7306 less aggressively.
Citing from the issue:

btw I suggest we change this fix to something else:
* We revert the fix.
* We add a call that disconnects chained replicas in the place where we trim the replica (that is a master i this case) offset.
This way we can avoid disconnections when there is no trimming of the backlog.

Note that we now want to disconnect replicas asynchronously in
disconnectSlaves(), because it's in general safer now that we can call
it from freeClient(). Otherwise for instance the command:

    CLIENT KILL TYPE master

May crash: clientCommand() starts running the linked of of clients,
looking for clients to kill. However it finds the master, kills it
calling freeClient(), but this in turn calls replicationCacheMaster()
that may also call disconnectSlaves() now. So the linked list iterator
of the clientCommand() will no longer be valid.
2020-05-25 12:08:01 +02:00
Maxime de Roucy c0f60008cb acl: @replication command group
containing mandatory commands for replication (used by masteruser user)


Former-commit-id: 123bc125cf
2020-05-25 02:35:22 -04:00
John Sully 4bb5c35548 Fix issue #170. Intermittent crash destroying fastlock due to implicit type conversion in assert
Former-commit-id: ecbe168b54
2020-05-25 02:13:57 -04:00
John Sully 9a357ec4b5 Fix infinite logs of Error in rreplay
Former-commit-id: 00cef78858
2020-05-24 20:05:22 -04:00
John Sully 845027c291 Enable TLS connections
Former-commit-id: d05da0fabd
2020-05-24 19:57:16 -04:00
John Sully 2857bed8bd bump version
Former-commit-id: 9353b3aac2ab65120f2ad5caa2f8272ae02df380
2020-05-24 18:35:03 -04:00
John Sully 9267a55e42 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 056c672cf60a00980cb10e97fc5da93d8eada937
2020-05-24 18:34:15 -04:00
John Sully 25f0bdf527 Fix test failures
Former-commit-id: c0b2263478d79f33d04ed409a68caa312884fa4c
2020-05-24 18:33:15 -04:00
John Sully 7db546130f Fix crash on shutdown with snapshots pending
Former-commit-id: 124e79a81d6995ea7d5ba39d1830b591b705acbf
2020-05-24 17:11:56 -04:00
John Sully 1e39ccbb2d Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: 9e473a9957f274f641ddad16d67d848f9a3c93c1
2020-05-24 14:47:55 -04:00
John Sully e0a0d93a07 Merge branch 'unstable' into keydbpro
Former-commit-id: a830cf85df236885558c5571c0bf23cfb23e3655
2020-05-24 14:41:53 -04:00
John Sully d176ae50ec don't keep feeding data to clients pending close
Former-commit-id: 4db3f2a443
2020-05-24 12:46:11 -04:00
John Sully 5c35593937 Quiet TSAN during exit
Former-commit-id: fd710d590a
2020-05-24 12:45:10 -04:00
John Sully 6b93792f8f Install deps for daily workflow
Former-commit-id: 9b98c9edd3
2020-05-24 11:19:53 -04:00
John Sully 7630b63f06 Hold the AE lock until we process the repl backlog after a command
Former-commit-id: 4893eedacb
2020-05-24 11:19:23 -04:00
John Sully 0d8c7c7182 Add standardized way to post client dependent functions
Former-commit-id: fb50163b47
2020-05-24 02:46:39 -04:00
John Sully 65e4f82982 remove unnecessary cplusplus guard
Former-commit-id: 3b8463f9d2
2020-05-24 02:45:55 -04:00
John Sully 0dd0ea7eda race in connection state when setting a handler on a different thread
Former-commit-id: 42c7677690
2020-05-24 02:45:11 -04:00
John Sully d3bd1ab56b Fix ASAN races
Former-commit-id: 8665f25031
2020-05-24 01:58:33 -04:00
John Sully 4136a1084b Incorrect locking in replication error paths
Former-commit-id: 1c6b573147
2020-05-24 01:57:49 -04:00
John Sully 2ea5bf4f55 Incorrect memory order on weak ordered architectures
Former-commit-id: 90162da1a6
2020-05-24 01:57:18 -04:00
John Sully dde860c60b If we request shutdown from a client on a different thread than a blocking lua script we fail to actually shutdown until the script completes
Former-commit-id: 1ca6c1dd56
2020-05-24 01:56:23 -04:00
John Sully aaff167eb9 race calculating client overhead
Former-commit-id: 2d27c8ecdb
2020-05-24 01:53:43 -04:00
John Sully 3813d5835e During RDB load we can only handle clients on the main thread as our workers are not yet created. This change also unifies the accept logic across the socket types
Former-commit-id: 59cda9cfb9
2020-05-23 16:03:24 -04:00
John Sully 3c0e1a1baf Diskless replication handler needs to run on the main thread
Former-commit-id: 091af64003
2020-05-23 15:15:42 -04:00
ShooterIT 646cc81c96 Fix reply bytes calculation error
Fix #7275.


Former-commit-id: a12210c875
2020-05-23 13:02:55 -04:00
John Sully 36032618b2 Merge tag '6.0.3' into unstable
Redis 6.0.3


Former-commit-id: 43649fc5b4
2020-05-22 16:53:10 -04:00
John Sully c86b45c6a0 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 01cc25653a
2020-05-22 16:45:27 -04:00
John Sully fa0be83fd9 Merge tag '6.0.2' into unstable
Redis 6.0.2


Former-commit-id: a010e4a4b2
2020-05-22 16:45:18 -04:00
John Sully c03e9a3e2c Merge commit 'e834acb91c89d083d0075e320dea6ad7188f2d0d' into unstable
Former-commit-id: 817a11ff11
2020-05-22 15:56:35 -04:00
John Sully bd3deb6c67 Merge commit '05b332e550e7ce32e364dde6cdd8820e8665eb21' into unstable
Former-commit-id: c52e1fc78c
2020-05-22 15:42:50 -04:00
John Sully 5a7ce664d0 Merge commit '78cbd3039858407837632bc37abb36e36ec60ce5' into unstable
Former-commit-id: d74871da40
2020-05-22 15:36:44 -04:00
John Sully 1ee6c44a96 Update README.md
Former-commit-id: a25cf15ecd
2020-05-22 14:03:29 -04:00
Madelyn Olson 8802cbbcde EAGAIN for tls during diskless load 2020-05-22 12:37:59 +02:00
Qu Chen 5d59bbb6d9 Disconnect chained replicas when the replica performs PSYNC with the master always to avoid replication offset mismatch between master and chained replicas. 2020-05-22 12:37:59 +02:00
hwware 08c70f7dce using moreargs variable 2020-05-22 12:37:59 +02:00
hwware 5c70dab9fc fix server crash for STRALGO command 2020-05-22 12:37:49 +02:00
ShooterIT e60f63a718 Replace addDeferredMultiBulkLength with addReplyDeferredLen in comment 2020-05-22 12:37:49 +02:00
Yossi Gottlieb 26143c2936 TLS: Improve tls-protocols clarity in redis.conf. 2020-05-22 12:37:49 +02:00
ShooterIT 9d1265240f Fix reply bytes calculation error
Fix #7275.
2020-05-22 12:37:49 +02:00
zhaozhao.zz 830c674845 Tracking: flag CLIENT_TRACKING_BROKEN_REDIR when redir broken 2020-05-22 12:37:49 +02:00
Oran Agra 56d63f4d7d fix a rare active defrag edge case bug leading to stagnation
There's a rare case which leads to stagnation in the defragger, causing
it to keep scanning the keyspace and do nothing (not moving any
allocation), this happens when all the allocator slabs of a certain bin
have the same % utilization, but the slab from which new allocations are
made have a lower utilization.

this commit fixes it by removing the current slab from the overall
average utilization of the bin, and also eliminate any precision loss in
the utilization calculation and move the decision about the defrag to
reside inside jemalloc.

and also add a test that consistently reproduce this issue.
2020-05-22 12:37:49 +02:00
Oran Agra 4f8e19f877 improve DEBUG MALLCTL to be able to write to write only fields.
also support:
  debug mallctl-str thread.tcache.flush VOID
2020-05-22 12:37:49 +02:00
hujie 6bb5b6d942 fix clear USER_FLAG_ALLCOMMANDS flag in acl
in ACLSetUserCommandBit, when the command bit overflows, no operation
is performed, so no need clear the USER_FLAG_ALLCOMMANDS flag.

in ACLSetUser, when adding subcommand, we don't need to call
ACLGetCommandID ahead since subcommand may be empty.
2020-05-22 12:37:49 +02:00
ShooterIT 2478a83ce7 Redis Benchmark: generate random test data
The function of generating random data is designed by antirez. See #7196.
2020-05-22 12:37:49 +02:00
hwware 3ffb3ac7ea Redis-Benchmark: avoid potentical memmory leaking 2020-05-22 12:37:49 +02:00
WuYunlong 65de5a1a7d Handle keys with hash tag when computing hash slot using tcl cluster client. 2020-05-22 12:37:49 +02:00
WuYunlong 71036d4cdb Add a test to prove current tcl cluster client can not handle keys with hash tag. 2020-05-22 12:37:49 +02:00
ShooterIT e113af7448 Use dictSize to get the size of dict in dict.c 2020-05-22 12:37:49 +02:00
Madelyn Olson 1d84b89fb6 Converge hash validation for adding and removing 2020-05-22 12:37:49 +02:00
Benjamin Sergeant 5d88c23555 do not handle --cluster-yes for cluster fix mode 2020-05-22 12:37:49 +02:00
Benjamin Sergeant dc2f7e0ad7 fix typo ... 2020-05-22 12:37:49 +02:00
Benjamin Sergeant 902e82efd2 Redis-cli 6.0.1 --cluster-yes doesn't work (fix #7246)
This make it so that all prompts for all redis-cli --cluster commands are automatically answered with a yes.
2020-05-22 12:37:49 +02:00
Oran Agra 7d8259d151 fix valgrind test failure in replication test
in 00323f342 i added more keys to that test to make it run longer
but in valgrind this now means the test times out, give valgrind more
time.
2020-05-22 12:37:49 +02:00
Oran Agra 5e75739bfd add regression test for the race in #7205
with the original version of 6.0.0, this test detects an excessive full
sync.
with the fix in 146201c69, this test detects memory corruption,
especially when using libc allocator with or without valgrind.
2020-05-22 12:37:49 +02:00
antirez 3d478f2e3f Improve the PSYNC2 test reliability. 2020-05-22 12:37:49 +02:00
John Sully 2fa3fb9573 Merge tag '6.0.1' into unstable
Redis 6.0.1.


Former-commit-id: c505df8830
2020-05-21 23:41:36 -04:00
John Sully 6402c28d5c Missing noexcept
Former-commit-id: f214ada545
2020-05-21 23:25:50 -04:00
John Sully 62261642cc build failure on macos
Former-commit-id: c10aa3b8b0
2020-05-21 23:24:34 -04:00
John Sully 193d7c76cb Fix bad merge in CI.yml
Former-commit-id: 6311d709c3
2020-05-21 22:09:06 -04:00
John Sully e245fdbb89 Merge commit '97e58ee026675e70fbd8843f7a86e98f53a3c791' into unstable
Former-commit-id: 8ab77465db
2020-05-21 19:37:42 -04:00
John Sully cc8d7c1afd Merge commit '3b373fbb0b05ee862dfef32199cfb63459019cd9' into unstable
Former-commit-id: 201bf73ef7
2020-05-21 18:57:28 -04:00
John Sully ccedb2fa73 Merge commit 'd7b07d3ded06b4cd843baffd3a6d33dd96efd401' into unstable
Former-commit-id: 49784c8122
2020-05-21 18:48:49 -04:00
John Sully 8377df8330 Merge commit '87924d673138531cbaf606015ea7b6a9e3ae2465' into unstable
Former-commit-id: 3e03f308b5
2020-05-21 17:55:09 -04:00
John Sully 327d543f2c Merge commit 'c5d805f87771581d3f6b29861ed2062c0ae2a688' into unstable
Former-commit-id: 95cecb0229
2020-05-21 17:45:15 -04:00
John Sully 4246199553 Merge commit '7cb94fd6cc9e1ad106964171023457ae3ff0a40b' into unstable
Former-commit-id: 7676f5b15f
2020-05-21 17:36:53 -04:00
John Sully b47d7715a4 Merge commit '71134e357ffd6ced7c40c145205dbbac173ee181' into unstable
Former-commit-id: d5b057534a
2020-05-21 17:32:53 -04:00
John Sully 5935707790 Merge commit '2535a172c1247d5d32d6f2fefe51b95c27ba8ae1' into unstable
Former-commit-id: 7a15f6dfc7
2020-05-21 17:30:56 -04:00
John Sully 903aeda836 Override missing new, fix new/delete mismatch
Former-commit-id: 712d825c23
2020-05-20 15:57:08 -04:00
antirez 8ca98ae414 Redis 6.0.3. 2020-05-16 18:11:58 +02:00
antirez ae73a26f14 Remove the client from CLOSE_ASAP list before caching the master.
This was broken in 146201c: we identified a crash in the CI, what
was happening before the fix should be like that:

1. The client gets in the async free list.
2. However freeClient() gets called again against the same client
   which is a master.
3. The client arrived in freeClient() with the CLOSE_ASAP flag set.
4. The master gets cached, but NOT removed from the CLOSE_ASAP linked
   list.
5. The master client that was cached was immediately removed since it
   was still in the list.
6. Redis accessed a freed cached master.

This is how the crash looked like:

=== REDIS BUG REPORT START: Cut & paste starting from here ===
1092:S 16 May 2020 11:44:09.731 # Redis 999.999.999 crashed by signal: 11
1092:S 16 May 2020 11:44:09.731 # Crashed running the instruction at: 0x447e18
1092:S 16 May 2020 11:44:09.731 # Accessing address: 0xffffffffffffffff
1092:S 16 May 2020 11:44:09.731 # Failed assertion:  (:0)

------ STACK TRACE ------
EIP:
src/redis-server 127.0.0.1:21300(readQueryFromClient+0x48)[0x447e18]

And the 0xffff address access likely comes from accessing an SDS that is
set to NULL (we go -1 offset to read the header).
2020-05-16 18:04:17 +02:00
antirez 38cc6cbbb4 Redis 6.0.2. 2020-05-15 22:29:52 +02:00
Yossi Gottlieb 114d06ea1f TLS: Fix test failures on recent Debian/Ubuntu.
Seems like on some systems choosing specific TLS v1/v1.1 versions no
longer works as expected. Test is reduced for v1.2 now which is still
good enough to test the mechansim, and matters most anyway.
2020-05-15 22:23:24 +02:00
Yossi Gottlieb c8b490b216 TLS: Add crypto locks for older OpenSSL support.
This is really required only for older OpenSSL versions.

Also, at the moment Redis does not use OpenSSL from multiple threads so
this will only be useful if modules end up doing that.
2020-05-15 22:23:24 +02:00
David Carlier b1e21f4672 NetBSD build update.
This platform supports CPU affinity (but not OpenBSD).
2020-05-15 22:23:24 +02:00
Madelyn Olson a7ba7a2e9e Added a refcount on timer events to prevent deletion of recursive timer calls 2020-05-15 22:23:24 +02:00
antirez 22a6d152f3 Cache master without checking of deferred close flags.
The context is issue #7205: since the introduction of threaded I/O we close
clients asynchronously by default from readQueryFromClient(). So we
should no longer prevent the caching of the master client, to later
PSYNC incrementally, if such flags are set. However we also don't want
the master client to be cached with such flags (would be closed
immediately after being restored). And yet we want a way to understand
if a master was closed because of a protocol error, and in that case
prevent the caching.
2020-05-15 22:23:24 +02:00
John Sully fe8acd0b30 Remove debugging logs
Former-commit-id: 4073758874
2020-05-14 22:18:29 -04:00
antirez 9d7e2fef3d Track events processed while blocked globally.
Related to #7234.
2020-05-14 11:29:43 +02:00
antirez e1b134e972 Some rework of #7234. 2020-05-14 11:29:43 +02:00
Oran Agra a3dd04410d fix redis 6.0 not freeing closed connections during loading.
This bug was introduced by a recent change in which readQueryFromClient
is using freeClientAsync, and despite the fact that now
freeClientsInAsyncFreeQueue is in beforeSleep, that's not enough since
it's not called during loading in processEventsWhileBlocked.
furthermore, afterSleep was called in that case but beforeSleep wasn't.

This bug also caused slowness sine the level-triggered mode of epoll
kept signaling these connections as readable causing us to keep doing
connRead again and again for ll of these, which keep accumulating.

now both before and after sleep are called, but not all of their actions
are performed during loading, some are only reserved for the main loop.

fixes issue #7215
2020-05-14 11:29:43 +02:00
antirez 60a6f16ced Regression test for #7249. 2020-05-14 11:29:43 +02:00
antirez 9ad227dca8 rax.c updated from upstream antirez/rax. 2020-05-14 11:29:43 +02:00
antirez 0b21426a45 Tracking: send eviction messages when evicting entries.
A fix for #7249.
2020-05-14 11:29:43 +02:00
Oran Agra 5258341880 fix unstable replication test
this test which has coverage for varoius flows of diskless master was
failing randomly from time to time.

the failure was:
[err]: diskless all replicas drop during rdb pipe in tests/integration/replication.tcl
log message of '*Diskless rdb transfer, last replica dropped, killing fork child*' not found

what seemed to have happened is that the master didn't detect that all
replicas dropped by the time the replication ended, it thought that one
replica is still connected.

now the test takes a few seconds longer but it seems stable.
2020-05-14 11:29:43 +02:00
John Sully 14e32ff682 Update ci.yml
Former-commit-id: d4b1d3f755f7c1f6ca4642b5258b4a5157eacb5a
2020-05-12 01:06:08 -04:00
John Sully 27e605293e Update ci.yml
Former-commit-id: d06c6c67ea36a21e515390405a0f947a23ec4b42
2020-05-11 22:09:27 -04:00
John Sully 35ad3b53fc Reduce test load for more reliability
Former-commit-id: 3f8f9743c1f6d75647cfbdbc1544a8c8a5142df3
2020-05-11 22:04:52 -04:00
John Sully 464326eb07 limit clients to make tests more reliable
Former-commit-id: 2c130a816647bacaba5d99d76c19e09b9c9875da
2020-05-11 21:56:17 -04:00
John Sully 84ce8b3ca8 Update cached time only in main cron
Former-commit-id: 5396dd9587599d6672e8d80967aa1fd8ba16e7ec
2020-05-11 20:31:47 -04:00
John 063672dbdb more reliability fixes for multimaster
Former-commit-id: 3543a3c763
2020-05-11 05:38:21 -04:00
John b03c4ccc50 more reliability fixes for multimaster
Former-commit-id: fd5b541260908423c35227ff9e42a83f96ace6c0
2020-05-11 09:37:42 +00:00
John 0e6add2e84 Make multimaster tests more reliable
Former-commit-id: 3122912920
2020-05-11 05:23:47 -04:00
John 680a6ac90f Make multimaster tests more reliable
Former-commit-id: 4fe59ba11b720864ea0124885b358cb72127cc2d
2020-05-11 09:22:27 +00:00
John Sully c48c9a57a9 too many clients makes tests unreliable
Former-commit-id: 89b39629980ab3e2930663c2922141e18e2fc38c
2020-05-11 04:54:17 -04:00
John 519db6a56d Run tests with more clients if possible
Former-commit-id: 3c73eb41bd904953c1e0e2d655d42599f3e9d2a2
2020-05-11 08:25:13 +00:00
John 39a7f92a97 link dependent libs
Former-commit-id: 165eb203f2a64f588b42b765afaafc370c547a25
2020-05-11 08:19:08 +00:00
John Sully 96744f633d run on self hosted
Former-commit-id: 51dba847764abc0014ef3be17a03afebd038854d
2020-05-11 03:10:27 -04:00
John Sully 42297389eb update ci.yml
Former-commit-id: 92a31cfd4d5bcf913f55c0f127b28738056f2a0a
2020-05-11 01:08:46 -04:00
John Sully 0ca8d8371c Fix bug merging LFU fix
Former-commit-id: 319099e1cb337d13444c16df1b5e1c300e6f2d15
2020-05-11 01:05:57 -04:00
John Sully 268f2efb48 Fix crash during RDB save with module events
Former-commit-id: 0f7eac411eccb853d7e50152e2bbd1ee28e6ee53
2020-05-11 01:02:58 -04:00
John Sully 5ea1948d68 Merge branch 'unstable' into keydbpro
Former-commit-id: d89c15518f984c1d4d4e7638a4e8ac5aa499632a
2020-05-11 00:53:38 -04:00
John Sully 87a9f79e20 Update access LFU/LRU access times when overwriting key
Former-commit-id: f11fdf6717
2020-05-11 00:42:46 -04:00
John Sully 4477a8b145 We should still send replies even if an async close is pending
Former-commit-id: 572bcca9c2
2020-05-10 23:56:29 -04:00
John Sully 344699b2ce Fix race on clients_to_close
Former-commit-id: 10fa064109
2020-05-10 23:14:15 -04:00
John Sully 73c436dba2 Fix crash in client unblock command
Former-commit-id: 7cd779d304
2020-05-10 22:08:50 -04:00
John Sully 03b811b13c Fix crash during hook module test
Former-commit-id: 628d168049
2020-05-10 21:57:16 -04:00
John Sully f76a52b957 Fix crash in module tests
Former-commit-id: 37423757b5
2020-05-10 21:06:38 -04:00
John Sully 73f60aca33 Run sentinel and module tests under CI
Former-commit-id: 58752bb8fe
2020-05-10 18:05:05 -04:00
John Sully f30fb5554f add help for hrename
Former-commit-id: 7e7f70ff3e
2020-05-10 17:41:01 -04:00
John Sully da7765a84e hrename tests
Former-commit-id: f77c227b2d
2020-05-10 17:14:44 -04:00
John Sully 02311d5c85 Implement keydb.hrename command
Former-commit-id: 21d842b0b0
2020-05-10 17:04:22 -04:00
ShooterIT acda6d9f70 Redis Benchmark: Fix coredump because of double free 2020-05-09 11:14:58 +02:00
antirez c2caa62ea3 Cluster: clarify we always resolve the sender. 2020-05-09 11:14:58 +02:00
antirez 94b9c321f8 Cluster: refactor ping/data delay handling. 2020-05-09 11:14:58 +02:00
antirez 2a5f56e67a Cluster: introduce data_received field.
We want to send pings and pongs at specific intervals, since our packets
also contain information about the configuration of the cluster and are
used for gossip. However since our cluster bus is used in a mixed way
for data (such as Pub/Sub or modules cluster messages) and metadata,
sometimes a very busy channel may delay the reception of pong packets.
So after discussing it in #7216, this commit introduces a new field that
is not exposed in the cluster, is only an internal information about
the last time we received any data from a given node: we use this field
in order to avoid detecting failures, claiming data reception of new
data from the node is a proof of liveness.
2020-05-09 11:14:58 +02:00
antirez 24075946c7 Don't propagate spurious MULTI on DEBUG LOADAOF. 2020-05-08 10:37:36 +02:00
antirez 351a891407 stringmatchlen() should not expect null terminated strings. 2020-05-08 10:37:36 +02:00
antirez e3ea90b0d7 Dump recent backlog on master query generating errors. 2020-05-08 10:37:36 +02:00
Brad Dunbar 1fd555da79 Remove unreachable branch. 2020-05-08 10:37:36 +02:00
Titouan Christophe 1e3555e85c make struct user anonymous (only typedefed)
This works because this struct is never referenced by its name,
but always by its type.

This prevents a conflict with struct user from <sys/user.h>
when compiling against uclibc.

Signed-off-by: Titouan Christophe <titouan.christophe@railnova.eu>
2020-05-08 10:37:36 +02:00
hwware dbc58bcf6f add jemalloc-bg-thread config in redis conf 2020-05-08 10:37:36 +02:00
antirez 8134e0b3f1 Test: --dont-clean should do first cleanup. 2020-05-08 10:37:36 +02:00
hwware 2e96a8263f add include guard for lolwut.h 2020-05-08 10:37:36 +02:00
Benjamin Sergeant f357735e8b Add --user argument to redis-benchmark.c (ACL) 2020-05-08 10:37:36 +02:00
antirez 96a8cdf767 Drop not needed part from #7194. 2020-05-08 10:37:36 +02:00
Muhammad Zahalqa 6bbfb97a89 Fix compiler warnings on function rev(unsigned long) 2020-05-08 10:37:36 +02:00
Guy Benoish 3843eb300d XPENDING should not update consumer's seen-time
Same goes for XGROUP DELCONSUMER (But in this case, it doesn't
have any visible effect)
2020-05-08 10:37:35 +02:00
Deliang Yang 5133e970cc reformat code 2020-05-08 10:37:35 +02:00
antirez 6b8fdaa8d6 Move CRC64 initialization in main(). 2020-05-08 10:37:35 +02:00
Oran Agra 8b40f686fb optimize memory usage of deferred replies - fixed
When deffered reply is added the previous reply node cannot be used so
all the extra space we allocated in it is wasted. in case someone uses
deffered replies in a loop, each time adding a small reply, each of
these reply nodes (the small string reply) would have consumed a 16k
block.
now when we add anther diferred reply node, we trim the unused portion
of the previous reply block.

see #7123

cherry picked from commit 4ed5b7cb74
with fix to handle a crash with LIBC allocator, which apparently can
return the same pointer despite changing it's size.
i.e. shrinking an allocation of 16k into 56 bytes without changing the
pointer.
2020-05-08 10:37:35 +02:00
Oran Agra eb9d28903d add daily github actions with libc malloc and valgrind
* fix memlry leaks with diskless replica short read.
* fix a few timing issues with valgrind runs
* fix issue with valgrind and watchdog schedule signal

about the valgrind WD issue:
the stack trace test in logging.tcl, has issues with valgrind:
==28808== Can't extend stack to 0x1ffeffdb38 during signal delivery for thread 1:
==28808==   too small or bad protection modes

it seems to be some valgrind bug with SA_ONSTACK.
SA_ONSTACK seems unneeded since WD is not recursive (SA_NODEFER was removed),
also, not sure if it's even valid without a call to sigaltstack()
2020-05-08 10:37:35 +02:00
antirez b7ec0cb259 Fix CRC64 initialization outside the Redis server itself. 2020-05-08 10:37:35 +02:00
hwware d45fd94b8a Client Side Caching: Add Tracking Prefix Number Stats in Server Info 2020-05-08 10:37:35 +02:00
antirez 07dab1935e Fix NetBSD build by fixing redis_set_thread_title() support.
See #7188.
2020-05-08 10:37:35 +02:00
antirez 3ed2e23fcb Rework a bit the documentation for CPU pinning. 2020-05-08 10:37:35 +02:00
zhenwei pi 1a632b6964 Support setcpuaffinity on linux/bsd
Currently, there are several types of threads/child processes of a
redis server. Sometimes we need deeply optimise the performance of
redis, so we would like to isolate threads/processes.

There were some discussion about cpu affinity cases in the issue:
https://github.com/antirez/redis/issues/2863

So implement cpu affinity setting by redis.conf in this patch, then
we can config server_cpulist/bio_cpulist/aof_rewrite_cpulist/
bgsave_cpulist by cpu list.

Examples of cpulist in redis.conf:
server_cpulist 0-7:2      means cpu affinity 0,2,4,6
bio_cpulist 1,3           means cpu affinity 1,3
aof_rewrite_cpulist 8-11  means cpu affinity 8,9,10,11
bgsave_cpulist 1,10-11    means cpu affinity 1,10,11

Test on linux/freebsd, both work fine.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-05-08 10:37:35 +02:00
John Sully 72293d62c9 Work around broken package installed on CI machines
Former-commit-id: 3340aaf8ad87fe0f7dd5c53254cd34605a3a8f12
2020-05-08 00:57:39 -04:00
John Sully bab6512408 Update CI
Former-commit-id: 332900e24a539c694929dd4163a25037ded6b19e
2020-05-08 00:44:00 -04:00
John Sully 87b5eb649a Bump version
Former-commit-id: 88eeb1c13cdf21df274ea9c364f35c4de522d215
2020-05-08 00:25:19 -04:00
John Sully e03a2bbb7f Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 219d7f3499fd826f039a1490ed3317791b084f94
2020-05-08 00:24:58 -04:00
John Sully f4e938e1af Free memory before we enter a script and may not have a chance
Former-commit-id: 7a3173c74ca617b4d0f9e852ab580731fa92f3df
2020-05-08 00:15:58 -04:00
John Sully da4cac6770 Fix bug where we don't correctly process maxmemory during bgsave
Former-commit-id: a0f2694d15784628df5d5ecb72b42c2979100f93
2020-05-08 00:14:55 -04:00
John Sully a3b80c293b Be *much* more aggressive flushing memory
Former-commit-id: f0bdc4fb5fce02d79c1aa2bcf384aa06580ff9e1
2020-05-07 23:07:31 -04:00
John Sully 22b46fa2f2 Disable cluster tests
They are unreliable on slow hardware.

Former-commit-id: 86f9ed6248
2020-05-07 01:49:04 -04:00
antirez d36292e2b8 Redis 6.0.1. 2020-05-02 00:10:20 +02:00
antirez 1812dc1644 Cast printf() argument to the format specifier.
We could use uint64_t specific macros, but after all it's simpler to
just use an obvious equivalent type plus casting: this will be a no op
and is simpler than fixed size types printf macros.
2020-05-02 00:04:19 +02:00
antirez 410e48ffb4 Revert "optimize memory usage of deferred replies"
This reverts commit 4ed5b7cb74.
2020-05-02 00:04:19 +02:00
antirez ef0c2a9268 Save a call to stopThreadedIOIfNeeded() for the base case.
Probably no performance changes, but the code should be trivial to
read as in "No threading? Use the normal function and return".
2020-05-02 00:04:19 +02:00
Diab Neiroukh 4e0d22e919 Clang requires libatomic to be linked via LDFLAGS
Clang requires the libatomic to be linked via LDFLAGS or else the linker
will fail to recognise __atomic macros.

An error as a result of not passing -latomic to the linker can be seen
below:

ld.lld: error: undefined symbol: __atomic_fetch_add_2
>>> referenced by sds.c:185
>>>               lto.tmp:(sdsdupshared)
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:276: keydb-server] Error 1
Former-commit-id: dcd7b684bb
2020-04-30 15:06:10 -04:00
antirez 1367cb7b6d Redis 6.0.0 GA. 2020-04-30 15:04:41 +02:00
antirez c7e3501d25 Update help.h again before Redis 6 GA. 2020-04-30 13:43:58 +02:00
antirez 9d5ba2e7be redis-cli: fix hints with subcommands. 2020-04-30 13:43:58 +02:00
antirez 6ffa739c13 redis-cli command help updated. 2020-04-30 13:02:59 +02:00
zhaozhao.zz b5dc95d4cc lazyfree & eviction: record latency generated by lazyfree eviction
1. add eviction-lazyfree monitor
2. put eviction-del & eviction-lazyfree into eviction-cycle
   that means eviction-cycle contains all the latency in
   the eviction cycle including del and lazyfree
3. use getMaxmemoryState to check if we can break in lazyfree-evict
2020-04-30 13:02:59 +02:00
antirez c3aa13a46a MIGRATE AUTH2 for ACL support. 2020-04-30 13:02:59 +02:00
antirez 4f61650c3c CLIENT KILL USER <username>. 2020-04-30 13:02:59 +02:00
antirez aec7e4a836 Fix tracking table max keys option in redis.conf. 2020-04-30 13:02:58 +02:00
antirez 99569af4aa redis-cli: safer cluster fix with unreachalbe masters. 2020-04-30 13:02:58 +02:00
antirez 9a9953d331 redis-cli: simplify cluster nodes coverage display. 2020-04-30 13:02:58 +02:00
antirez dbf803bf9c redis-cli: try to make clusterManagerFixOpenSlot() more readable.
Also improve the message to make clear that there is no *clear* owner,
not that there is no owner at all.
2020-04-30 13:02:58 +02:00
Guy Benoish 20a9fe531c XINFO STREAM FULL should have a default COUNT of 10 2020-04-30 13:02:58 +02:00
antirez 78b9c097c9 Comment clearly why we moved some code in #6623. 2020-04-30 13:02:58 +02:00
srzhao e9811c3b12 fix pipelined WAIT performance issue.
If client gets blocked again in `processUnblockedClients`, redis will not send
`REPLCONF GETACK *` to slaves untill next eventloop, so the client will be
blocked for 100ms by default(10hz) if no other file event fired.

move server.get_ack_from_slaves sinppet after `processUnblockedClients`, so
that both the first WAIT command that puts client in blocked context and the
following WAIT command processed in processUnblockedClients would trigger
redis-sever to send `REPLCONF GETACK *`, so that the eventloop would get
`REPLCONG ACK <reploffset>` from slaves and unblocked ASAP.
2020-04-30 13:02:58 +02:00
antirez d66ac30fd4 Fix create-cluster BIN_PATH. 2020-04-30 13:02:58 +02:00
Guy Benoish dc3d865edc Extend XINFO STREAM output
Introducing XINFO STREAM <key> FULL
2020-04-30 13:02:58 +02:00
hwware 12bb6b0f08 Fix not used marco in cluster.c 2020-04-30 13:02:58 +02:00
Itamar Haber 1541e3e522 Update create-cluster 2020-04-30 13:02:58 +02:00
Itamar Haber c028751ef0 Adds BIN_PATH to create-cluster
Allows for setting the binaries path if used outside the upstream repo.

Also documents `call` in usage clause (TODO: port to
`redis-cli --cluster call` or just deprecate it).
2020-04-30 13:02:58 +02:00
John Sully a3e0c42dc4 cluster tests should be a named task
Former-commit-id: f715d0b860
2020-04-29 18:43:55 -04:00
John Sully 4a5aa68074 Run cluster tests as part of CI
Former-commit-id: 98d690b849
2020-04-29 18:41:51 -04:00
John Sully ad3de92c57 use serverAssert() instead of assert() to get callstacks in fastlock
Former-commit-id: 45535e8a63
2020-04-28 22:41:07 -04:00
John Sully d9409d3614 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: c78895aaea
2020-04-28 22:24:45 -04:00
John Sully 83118f2584 Bump version
Former-commit-id: 8e12ff0cd9e50867b42b165af278a7dc91fc17e1
2020-04-28 20:49:39 -04:00
John Sully c400e5825b Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 6e7ffcddfbde8ee310e07b510097b69104f862b8
2020-04-28 20:48:54 -04:00
John Sully 2ab2078085 Fix failure to count keys in cluster slots when reloading a FLASH database
Former-commit-id: f6dd863e51f91620f184ff80f08cfe518d29c87f
2020-04-28 20:48:46 -04:00
Oran Agra fb0a0c6451 hickup, re-fix dictEncObjKeyCompare
come to think of it, in theory (not in practice), getDecodedObject can
return the same original object with refcount incremented, so the
pointer comparision in the previous commit was invalid.
so now instead of checking the encoding, we explicitly check the
refcount.
2020-04-28 11:20:15 +02:00
Oran Agra a8995ce3c9 fix loading race in psync2 tests 2020-04-28 11:20:15 +02:00
antirez ffbe6543ab Rework comment in dictEncObjKeyCompare(). 2020-04-28 11:20:15 +02:00
Oran Agra d92f14e825 allow dictFind using static robj
since the recent addition of OBJ_STATIC_REFCOUNT and the assertion in
incrRefCount it is now impossible to use dictFind using a static robj,
because dictEncObjKeyCompare will call getDecodedObject which tries to
increment the refcount just in order to decrement it later.
2020-04-28 11:20:15 +02:00
Madelyn Olson e853b8f137 Added crcspeed library 2020-04-28 11:20:15 +02:00
Madelyn Olson e49a60d9df Made crc64 test consistent 2020-04-28 11:20:15 +02:00
Madelyn Olson 1652f7b897 Implemented CRC64 based on slice by 4 2020-04-28 11:20:15 +02:00
Oran Agra f1cd7f5880 optimize memory usage of deferred replies
When deffered reply is added the previous reply node cannot be used so
all the extra space we allocated in it is wasted. in case someone uses
deffered replies in a loop, each time adding a small reply, each of
these reply nodes (the small string reply) would have consumed a 16k
block.
now when we add anther diferred reply node, we trim the unused portion
of the previous reply block.

see #7123
2020-04-27 16:46:14 +02:00
Oran Agra 58619c1286 Keep track of meaningful replication offset in replicas too
Now both master and replicas keep track of the last replication offset
that contains meaningful data (ignoring the tailing pings), and both
trim that tail from the replication backlog, and the offset with which
they try to use for psync.

the implication is that if someone missed some pings, or even have
excessive pings that the promoted replica has, it'll still be able to
psync (avoid full sync).

the downside (which was already committed) is that replicas running old
code may fail to psync, since the promoted replica trims pings form it's
backlog.

This commit adds a test that reproduces several cases of promotions and
demotions with stale and non-stale pings

Background:
The mearningful offset on the master was added recently to solve a problem were
the master is left all alone, injecting PINGs into it's backlog when no one is
listening and then gets demoted and tries to replicate from a replica that didn't
have any of the PINGs (or at least not the last ones).

however, consider this case:
master A has two replicas (B and C) replicating directly from it.
there's no traffic at all, and also no network issues, just many pings in the
tail of the backlog. now B gets promoted, A becomes a replica of B, and C
remains a replica of A. when A gets demoted, it trims the pings from its
backlog, and successfully replicate from B. however, C is still aware of
these PINGs, when it'll disconnect and re-connect to A, it'll ask for something
that's not in the backlog anymore (since A trimmed the tail of it's backlog),
and be forced to do a full sync (something it didn't have to do before the
meaningful offset fix).

Besides that, the psync2 test was always failing randomly here and there, it
turns out the reason were PINGs. Investigating it shows the following scenario:

cycle 1: redis #1 is master, and all the rest are direct replicas of #1
cycle 2: redis #2 is promoted to master, #1 is a replica of #2 and #3 is replica of #1
now we see that when #1 is demoted it prints:
17339:S 21 Apr 2020 11:16:38.523 * Using the meaningful offset 3929963 instead of 3929977 to exclude the final PINGs (14 bytes difference)
17339:S 21 Apr 2020 11:16:39.391 * Trying a partial resynchronization (request e2b3f8817735fdfe5fa4626766daa938b61419e5:3929964).
17339:S 21 Apr 2020 11:16:39.392 * Successful partial resynchronization with master.
and when #3 connects to the demoted #2, #2 says:
17339:S 21 Apr 2020 11:16:40.084 * Partial resynchronization not accepted: Requested offset for secondary ID was 3929978, but I can reply up to 3929964

so the issue here is that the meaningful offset feature saved the day for the
demoted master (since it needs to sync from a replica that didn't get the last
ping), but it didn't help one of the other replicas which did get the last ping.
2020-04-27 15:52:49 +02:00
antirez a0c54d5622 Fix STRALGO command flags. 2020-04-27 15:52:49 +02:00
Dave-in-lafayette 1713328723 fix for unintended crash during panic response
If redis crashes early, before lua is set up (like, if File Descriptor 0 is closed before exec), it will crash again trying to print memory statistics.
2020-04-27 15:52:49 +02:00
Guy Benoish aafc91fcc9 Add the stream tag to XSETID tests 2020-04-27 15:52:49 +02:00
Dave-in-lafayette 4c30d6d732 fix for crash during panic before all threads are up
If there's a panic before all threads have been started (say, if file descriptor 0 is closed at exec), the panic response will crash here again.
2020-04-27 15:52:49 +02:00
John Sully 16fd1ed48e shared pointer comparisons with other pointers
Former-commit-id: d5ede50b04
2020-04-24 22:20:26 -04:00
John Sully 1d8ecd93de EMBSTR size is lower than it needs to be
Former-commit-id: fab6132cb3
2020-04-24 22:19:55 -04:00
antirez 262da0ba78 LCS -> STRALGO LCS.
STRALGO should be a container for mostly read-only string
algorithms in Redis. The algorithms should have two main
characteristics:

1. They should be non trivial to compute, and often not part of
programming language standard libraries.
2. They should be fast enough that it is a good idea to have optimized C
implementations.

Next thing I would love to see? A small strings compression algorithm.
2020-04-24 16:49:27 +02:00
antirez e772b55a9c Also use propagate() in streamPropagateGroupID(). 2020-04-24 10:15:04 +02:00
yanhui13 e0add7e0f1 add tcl test for cluster slots 2020-04-24 10:15:04 +02:00
yanhui13 782d9f2ff9 optimize the output of cluster slots 2020-04-24 10:15:04 +02:00
antirez 6d3bd2ed5a Minor aesthetic changes to #7135. 2020-04-24 10:15:04 +02:00
Valentino Geron a2a5b1d6ae XREADGROUP with NOACK should propagate only one XGROUP SETID command 2020-04-24 10:15:04 +02:00
antirez 408d4fb35d ACL: re-enable command execution of disabled users.
After all I changed idea again: enabled/disabled should have a more
clear meaning, and it only means: you can't authenticate with such user
with new connections, however old connections continue to work as
expected.
2020-04-24 10:15:04 +02:00
antirez 76aa8a43ab getRandomBytes(): use HMAC-SHA256.
Now that we have an interface to use this API directly, via ACL GENPASS,
we are no longer sure what people could do with it. So why don't make it
a strong primitive exported by Redis in order to create unique IDs and
so forth?

The implementation was tested against the test vectors that can
be found in RFC4231.
2020-04-24 10:14:48 +02:00
antirez 32c6699847 ACL GENPASS: take number of bits as argument. 2020-04-24 10:14:48 +02:00
antirez 9651156a7b ACL GENPASS: emit 256 bits instead of 128. 2020-04-24 10:14:48 +02:00
antirez de38fa2b65 ACL: deny commands execution of disabled users. 2020-04-24 10:14:48 +02:00
Theo Buehler 6a8f6ac1a3 TLS: Fix build with SSL_OP_NO_CLIENT_RENEGOTIATION
There is no ssl in this scope, so the build breaks.
All the other options are set directly on the ctx.
2020-04-24 10:14:48 +02:00
Yossi Gottlieb 48ff17e1de TLS: Fix build on older verisons of OpenSSL. 2020-04-24 10:14:48 +02:00
antirez 6666d30f6a Tracking: test expired keys notifications. 2020-04-24 10:14:48 +02:00
antirez 1b28c0cbab Tracking: NOLOOP tests. 2020-04-24 10:14:48 +02:00
antirez a05f6b064b Tracking: signal key as modified when evicting. 2020-04-24 10:14:48 +02:00
antirez 249d933215 Tracking: NOLOOP further implementation and fixes. 2020-04-24 10:14:48 +02:00
antirez f066273907 Tracking: NOLOOP internals implementation. 2020-04-24 10:14:48 +02:00
antirez 14758cdc63 Implement redis_set_thread_title for MacOS.
Strange enough, pthread_setname_np() produces a warning for not defined
function even if pthread is included. Moreover the MacOS documentation
claims the return value for the function is void, but actually is int.

Related to #7089.
2020-04-24 10:14:48 +02:00
zhenwei pi ff889d2c8a Threaded IO: set thread name for redis-server
Set thread name for each thread of redis-server, this helps us to
monitor the utilization and optimise the performance.

And suggested-by Salvatore, implement this feature for multi
platforms. Currently support linux and bsd, ignore other OS.

An exmaple on Linux:
 # top -d 5 -p `pidof redis-server ` -H

    PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
3682671 root      20   0  227744   8248   3836 R 99.2  0.0   0:19.53 redis-server
3682677 root      20   0  227744   8248   3836 S 26.4  0.0   0:04.15 io_thd_3
3682675 root      20   0  227744   8248   3836 S 23.6  0.0   0:03.98 io_thd_1
3682676 root      20   0  227744   8248   3836 S 23.6  0.0   0:03.97 io_thd_2
3682672 root      20   0  227744   8248   3836 S  0.2  0.0   0:00.02 bio_close_file
3682673 root      20   0  227744   8248   3836 S  0.2  0.0   0:00.02 bio_aof_fsync
3682674 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 bio_lazy_free
3682678 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 jemalloc_bg_thd
3682682 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 jemalloc_bg_thd
3682683 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 jemalloc_bg_thd
3682684 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 jemalloc_bg_thd
3682685 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 jemalloc_bg_thd
3682687 root      20   0  227744   8248   3836 S  0.0  0.0   0:00.00 jemalloc_bg_thd

Another exmaple on FreeBSD-12.1:
  PID USERNAME    PRI NICE   SIZE    RES STATE    C   TIME    WCPU COMMAND
 5212 root        100    0    48M  7280K CPU2     2   0:26  99.52% redis-server{redis-server}
 5212 root         38    0    48M  7280K umtxn    4   0:06  26.94% redis-server{io_thd_3}
 5212 root         36    0    48M  7280K umtxn    6   0:06  26.84% redis-server{io_thd_1}
 5212 root         39    0    48M  7280K umtxn    1   0:06  25.30% redis-server{io_thd_2}
 5212 root         20    0    48M  7280K uwait    3   0:00   0.00% redis-server{redis-server}
 5212 root         21    0    48M  7280K uwait    2   0:00   0.00% redis-server{bio_close_file}
 5212 root         21    0    48M  7280K uwait    3   0:00   0.00% redis-server{bio_aof_fsync}
 5212 root         21    0    48M  7280K uwait    0   0:00   0.00% redis-server{bio_lazy_free}

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-04-24 10:14:48 +02:00
antirez ac512f2928 Sentinel: small refactoring of sentinelCollectTerminatedScripts().
Related to #7113.
2020-04-24 10:14:48 +02:00
omg-by b949f7c173 fix(sentinel): sentinel.running_scripts will always increase more times and not reset
when trigger a always fail scripts, sentinel.running_scripts will increase ten times, however it
only decrease one times onretry the maximum. and it will't reset, when it become
SENTINEL_SCRIPT_MAX_RUNNING, sentinel don't trigger scripts.
2020-04-24 10:14:48 +02:00
John Sully 92703d32cc Default yes in apt install
Former-commit-id: e0a8709c09
2020-04-22 02:17:28 -04:00
John Sully 41fcbc881b Run arm CI builds
Former-commit-id: 17795fd5ce
2020-04-22 02:13:02 -04:00
John Sully 4acd49c4fc MacOS Build Break Fix
Former-commit-id: d6738ffa5d
2020-04-22 01:21:35 -04:00
John Sully 34f50a49df Add deps to CI yml
Former-commit-id: 29d9fba802a24ba3e29bf5a66ab684c7d9d0959a
2020-04-22 01:11:06 -04:00
John Sully 6b02c556e8 Bump version
Former-commit-id: f527649f156147f29efb81a7a20057909fe43748
2020-04-22 01:07:14 -04:00
John Sully d054555570 Merge branch 'PRO_RELEASE_6' of https://github.com/JohnSully/KeyDB-Pro into PRO_RELEASE_6
Former-commit-id: 859540b68c54f86f97c33c87802d8c3e74437325
2020-04-22 01:06:43 -04:00
John Sully 3a06dd8265 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 6b6a1c711dbb7786e30be29e2d1930582037f7f9
2020-04-22 01:06:24 -04:00
John Sully 71897819ed Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: 9004ecf11e31be1b0d43a0d8c6e8263636b3bac4
2020-04-22 01:06:06 -04:00
John Sully 7971c4b040 Don't CI build Pro on MacOS
Former-commit-id: aaed87516ea9f428ebea286dd936dd219691b4f6
2020-04-22 01:05:24 -04:00
John Sully e16dc21307 Don't show trial warning on license disabled builds
Former-commit-id: 08fd74360d1e0196db7a6b52717500325533576c
2020-04-22 01:04:29 -04:00
John Sully 435b926292 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 8ff5c0baef1d7ec8f225c3e115f37731e4ee8593
2020-04-22 00:56:43 -04:00
John Sully 0924f9b0c6 CI syntax error fix
Former-commit-id: 0845620384c08a3f937655931775a20728b19526
2020-04-22 00:55:31 -04:00
John Sully ace581d9f2 CI enable submodules
Former-commit-id: f57611e82fa7a63bd554568748338e8a116534b5
2020-04-22 00:53:31 -04:00
John Sully 9d407dd520 RDB load performance, eliminate useless reads
Former-commit-id: 68e5d1850dbba89a87710968d314cb8c0d3cb562
2020-04-22 00:47:49 -04:00
John Sully b7a9ef3fe4 Be more aggressive evicting when a storage provider is set
Former-commit-id: 4d1cabe2ab383939670e5ff0a2b91aa758f4e15e
2020-04-22 00:47:24 -04:00
John Sully 57ae5788f0 Periodically FLASH flush write queues during RDB load
Former-commit-id: 721129b18263eabfc2a29556a2b7a9a861110953
2020-04-21 21:39:36 -04:00
John Sully bd26d8bad7 don't swap iterators when swapping DB contents
Former-commit-id: 4971518d42218a63cf86919e91af54462f6dc8c0
2020-04-21 21:38:24 -04:00
antirez d4d2d24745 A few comments and name changes for #7103. 2020-04-17 13:02:40 +02:00
Oran Agra f37a123687 testsuite run the defrag latency test solo
this test is time sensitive and it sometimes fail to pass below the
latency threshold, even on strong machines.

this test was the reson we're running just 2 parallel tests in the
github actions CI, revering this.
2020-04-17 13:02:40 +02:00
Jamie Scott 63f039f122 Adding acllog-max-len to Redis.conf
While playing with ACLs I noticed that acllog-max-len wasn't in the redis.conf, but was a supported config. 

This PR documents and adds the directive to the redis.conf file.
2020-04-17 13:02:40 +02:00
antirez 0b1b56b6fc Fix XCLAIM propagation in AOF/replicas for blocking XREADGROUP.
See issue #7105.
2020-04-17 12:40:54 +02:00
John Sully 1739a6b2c2 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: e72642667f
2020-04-16 20:12:14 -04:00
John Sully 9bc3029a02 Fix some clang warnings
Former-commit-id: 3785b1efd4
2020-04-16 20:12:05 -04:00
John Sully 68c455a6d6 Always link libatomic
Former-commit-id: 7aeae62f84
2020-04-16 20:01:24 -04:00
John Sully fbecb9d5c9 Fix warning in cluster.cpp
Former-commit-id: e5e33f8cb7
2020-04-16 20:01:13 -04:00
John Sully 5a23a6da76 Merge branch 'unstable' into keydbpro
Former-commit-id: 642719cef20a88d23af84a16d3f6757088c23b1a
2020-04-16 17:06:33 -04:00
John Sully fe307bb1b1 quiet TSAN in serverLog
Former-commit-id: a836d5947d
2020-04-16 17:06:25 -04:00
John Sully f627dd8cbe Initial merge of unstable 6
Former-commit-id: aac140de199646914cc02997a45111c9c695e55d
2020-04-16 16:36:16 -04:00
antirez b3ff2337b9 Redis 6.0-RC4. 2020-04-16 16:18:02 +02:00
antirez 151fae1f23 Update SDS to latest version. 2020-04-16 16:09:06 +02:00
antirez 2dac74ffb4 RESP3: fix HELLO map len in Sentinel mode.
See #6160.
2020-04-16 11:22:18 +02:00
John Sully c3f05b72e2 Update Readme to use github CI badge
Former-commit-id: 7cdd5d9e41
2020-04-15 23:21:10 -04:00
John Sully e177cdcd3c update TLS readme for KeyDB
Former-commit-id: 3f5d3fec36
2020-04-15 23:19:05 -04:00
John Sully 34d768f5ad Deprecate travis and finish setting up github CI
Former-commit-id: 90094a2dca
2020-04-15 23:04:04 -04:00
John Sully c001ea5b41 Merge branch 'unstable' into redis_6_merge
Former-commit-id: cc9924ffa6
2020-04-15 23:00:13 -04:00
Ubuntu 412e3a059f updating version
Former-commit-id: f994436486b2e8b4eb63f8ce29ab9c8595e1a694
2020-04-16 02:56:49 +00:00
John Sully fe06034b33 OS X build break
Former-commit-id: 5e6b4ab99e
2020-04-15 22:43:40 -04:00
John Sully e08314988a more dependencies for CI
Former-commit-id: 2d6d374162
2020-04-15 22:39:47 -04:00
John Sully 6f5fc21d1e Add CI dependency
Former-commit-id: 3137d4f35c
2020-04-15 22:36:16 -04:00
John Sully 822f64ed2f During AOF reload we can erroneously read incorrect aof_state values, so this variable must be read with the global lock acquired
Former-commit-id: 6ff9d23fd4
2020-04-15 22:30:19 -04:00
John Sully 32b028b9cb Quiet test only ASAN fd race
Former-commit-id: d4939c838b
2020-04-15 22:27:45 -04:00
John Sully d9c08a1db3 Run all KeyDB instances in testmode during tests
Former-commit-id: cd306f1d23
2020-04-15 22:27:04 -04:00
John Sully c177e6e34d Fix race in sendBulk
Former-commit-id: 5fd07e0889
2020-04-15 22:26:00 -04:00
John Sully e8270a2f0b Convert variables accessed outside lock to atomics
Former-commit-id: b0796ff5fd
2020-04-15 22:25:17 -04:00
John Sully c64f9d5d30 ASAN races in leak checker
Former-commit-id: 9dfa074cd6
2020-04-15 22:24:12 -04:00
John Sully 2687677ba6 Multithreading reliability, force single thread for test relying on internal behavior
Former-commit-id: 033761c5f9
2020-04-15 20:52:25 -04:00
John Sully e197baa90a rename to KeyDB (merge)
Former-commit-id: 2926ac494e
2020-04-15 16:44:06 -04:00
John Sully 009895cc65 Log stdout and stderr for cluster tests
Former-commit-id: 06143c2e8c
2020-04-15 16:35:24 -04:00
John Sully 4fba2ce074 Fix TSAN race
Former-commit-id: f00d28fdab
2020-04-15 16:34:38 -04:00
John Sully 2da48575e4 Fix incorrect cluster slot tracking (regression from merge)
Former-commit-id: 4705f29e2f
2020-04-15 16:34:07 -04:00
antirez 9674ad9579 Don't allow empty spaces in ACL usernames.
Fixes issue #6418.
2020-04-15 18:40:11 +02:00
antirez 577b4b6908 Don't allow empty spaces in ACL key patterns.
Fixes issue #6418.
2020-04-15 18:40:11 +02:00
antirez 97e58ee026 Use the special static refcount for stack objects. 2020-04-15 16:03:16 +02:00
antirez 3b373fbb0b Speedup: unblock clients on keys in O(1).
See #7071.
2020-04-15 16:03:16 +02:00
liumiuyong ec68525829 FIX: truncate max/min longitude,latitude related geo_point (ex: {180, 85.05112878} ) 2020-04-15 16:03:16 +02:00
antirez ec24d65c06 RDB: refactor some RDB loading code into dbAddRDBLoad(). 2020-04-15 16:03:16 +02:00
Guy Benoish 157906ca8d Typo in getTimeoutFromObjectOrReply's error reply 2020-04-15 16:03:16 +02:00
antirez a889c94447 incrRefCount(): abort on statically allocated object. 2020-04-15 16:03:16 +02:00
antirez d1a7b69981 Fix HELLO reply in Sentinel mode, see #6160. 2020-04-15 16:03:16 +02:00
antirez d16b8275ff More powerful DEBUG RELOAD.
Related to #3243.
2020-04-15 16:03:16 +02:00
hwware 868ad19b96 fix spelling in acl.c 2020-04-15 16:03:16 +02:00
antirez 33725240c0 RDB: clarify a condition in rdbLoadRio(). 2020-04-15 16:03:16 +02:00
antirez 37a54d6e96 Fix zsetAdd() top comment spelling. 2020-04-15 16:03:16 +02:00
antirez 533fd1fe7b RDB: load files faster avoiding useless free+realloc.
Reloading of the RDB generated by

    DEBUG POPULATE 5000000
    SAVE

is now 25% faster.

This commit also prepares the ability to have more flexibility when
loading stuff from the RDB, since we no longer use dbAdd() but can
control exactly how things are added in the database.
2020-04-15 16:03:16 +02:00
hayleeliu ebc872725f fix spelling mistake in bitops.c 2020-04-15 16:03:16 +02:00
antirez e44a318939 Fix function names in zslDeleteNode() top comment. 2020-04-15 16:03:16 +02:00
antirez 02705216e0 RESP3: change streams items from maps to arrays.
Streams items are similar to dictionaries, however they preserve both
the order, and allow for duplicated field names. So a map is not a
semantically sounding way to deal with this.

https://twitter.com/antirez/status/1248261087553880069
2020-04-15 16:03:16 +02:00
John Sully f69c169c04 Merge tag '6.0-rc3' into redis_6_merge
Redis 6.0 RC3.


Former-commit-id: b2cb10de5f
2020-04-14 22:56:19 -04:00
John Sully f7a49753a8 Fix merge issues and move timeout to C++
Former-commit-id: 1005a725d4
2020-04-14 22:37:26 -04:00
John Sully 3e656bcb3f Merge commit '2a820251c8ffba152e00ef7b1ca5e7a477087d33' into redis_6_merge
Former-commit-id: 50768cd242
2020-04-14 22:25:44 -04:00
John Sully ce54857237 Merge commit '454e12cb8961f21c9dd8502dc82ae6ffd7e22fe0' into redis_6_merge
Former-commit-id: cc3ebbe519
2020-04-14 22:19:29 -04:00
John Sully 7aaed24204 Merge commit '714ae38ee1fc260df6fc5708463accd74a93c215' into redis_6_merge
Former-commit-id: 8056e349e0
2020-04-14 21:26:51 -04:00
John Sully b223579bac Merge commit 'd3491c5182b97535cfdf2c3d4f9d0762c608e1ff' into redis_6_merge
Former-commit-id: 0001f59c8d
2020-04-14 21:16:38 -04:00
John Sully 8750cb5a3b Merge commit '07c75f60f3fe0b300fd7913bab3d2d7e612afb03' into redis_6_merge
Former-commit-id: 2941792a85
2020-04-14 21:13:42 -04:00
John Sully 0725491043 Merge commit 'c609bf3f2c7f0982f632f82623ee4802868b8ef1' into redis_6_merge
Former-commit-id: 320bc3c032
2020-04-14 21:04:42 -04:00
John Sully 90cbdd5573 Merge commit 'c208956fbe077e8249d2965dec2ea1b9b7588d6d' into redis_6_merge
Former-commit-id: 2825e51550
2020-04-14 20:55:29 -04:00
John Sully 4d4a7d656b Merge commit '00e53fb140fb67d329aff6cd2200f1eaf9e80cf5' into redis_6_merge
Former-commit-id: cbdd47d056
2020-04-14 20:44:27 -04:00
John Sully 4f56e9c3b0 Merge commit 'e91ca9fee9c56ef319b407b104afc435be0c53cb' into redis_6_merge
Former-commit-id: 516c8c6e23
2020-04-14 20:42:48 -04:00
John Sully 68c50ae876 Merge commit '6718d5d37517bd927635649708913affb98f67c9' into redis_6_merge
Former-commit-id: ef1236b600
2020-04-14 20:19:48 -04:00
John Sully 2c049c16a2 Merge commit '79e8b17d7b44c793d8b22668b8583a297ee1b387' into redis_6_merge
Former-commit-id: 28cbed1d13
2020-04-14 20:09:53 -04:00
John Sully d48ea996e7 Merge commit '13fbdf970660b15011c4312f31137e58bbda5b2c' into redis_6_merge
Former-commit-id: cde199a797
2020-04-14 19:43:04 -04:00
John Sully 6df76a3bfa Merge commit 'a8e2bbe8f6a3f4833f286cc5049e6b52c87de1a9' into redis_6_merge
Former-commit-id: 5589a0a69c
2020-04-14 19:22:44 -04:00
John Sully 2038fa270a Merge commit '491949ee5bf4ffbfc746ea4ed5a6d673b0e2fb81' into redis_6_merge
Former-commit-id: 09e8fb17cd
2020-04-14 18:44:42 -04:00
John Sully 9039879f80 Merge commit '2ad427f862084e0e18fbd6c313af35ccdb6c68f7' into redis_6_merge
Former-commit-id: d71c4c2215
2020-04-14 18:30:26 -04:00
John Sully 06017d7900 Merge commit '9a39a227fff45baa0f1532dba017f31ac71b68e5' into redis_6_merge
Former-commit-id: 6f621e6480
2020-04-14 18:29:03 -04:00
John Sully c198d81582 Merge commit 'dff5370c8be0dcef1728b95b17906d2494ce9bf2' into redis_6_merge
Former-commit-id: 8e33c2d301
2020-04-14 18:05:10 -04:00
John Sully 17a1637c89 Merge commit '87d059a7454aad2c3a9810ddafd33c3a9e4be383' into redis_6_merge
Former-commit-id: 52aca124c3
2020-04-14 18:04:51 -04:00
antirez 910db44fc5 Jump to right label on AOF parsing error.
Related to #6054.


Former-commit-id: c7159d58f1
2020-04-14 18:03:22 -04:00
antirez c38bc83f47 PSYNC2: meaningful offset implemented.
A very commonly signaled operational problem with Redis master-replicas
sets is that, once the master becomes unavailable for some reason,
especially because of network problems, many times it wont be able to
perform a partial resynchronization with the new master, once it rejoins
the partition, for the following reason:

1. The master becomes isolated, however it keeps sending PINGs to the
replicas. Such PINGs will never be received since the link connection is
actually already severed.
2. On the other side, one of the replicas will turn into the new master,
setting its secondary replication ID offset to the one of the last
command received from the old master: this offset will not include the
PINGs sent by the master once the link was already disconnected.
3. When the master rejoins the partion and is turned into a replica, its
offset will be too advanced because of the PINGs, so a PSYNC will fail,
and a full synchronization will be required.

Related to issue #7002 and other discussion we had in the past around
this problem.


Former-commit-id: 5d6e8fe3e3
2020-04-14 17:56:09 -04:00
Oran Agra 031d5044bf reduce repeated calls to use_diskless_load
this function possibly iterates on the module list


Former-commit-id: 99762dac23
2020-04-14 17:34:36 -04:00
John Sully c168ae6cfe Fix merge conflicts from cherry-pick
Former-commit-id: 57956b3fd2
2020-04-14 17:33:54 -04:00
antirez f7e8240900 Remove RDB files used for replication in persistence-less instances.
Former-commit-id: b323645227
2020-04-14 17:27:05 -04:00
Johannes Truschnigg 0ef7e8e0b2 Signal systemd readiness atfer Partial Resync
"Partial Resynchronization" is a special variant of replication success
that we have to tell systemd about if it is managing redis-server via a
Type=Notify service unit.


Former-commit-id: dd9502f373
2020-04-14 17:22:30 -04:00
Guy Benoish 49dda32114 Diskless-load emptyDb-related fixes
1. Call emptyDb even in case of diskless-load: We want modules
   to get the same FLUSHDB event as disk-based replication.
2. Do not fire any module events when flushing the backups array.
3. Delete redundant call to signalFlushedDb (Called from emptyDb).


Former-commit-id: aa8a3077a2
2020-04-14 17:21:10 -04:00
John Sully 2ecff6eccf Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 1dd55bec28e7bba38ff9fbd7c6b22b23b911a4eb
2020-04-14 01:01:20 -04:00
John Sully 8fb3be9ce1 Cache fake client in replicaFeedSlaves
Former-commit-id: 8e81e5f29e
2020-04-13 22:45:15 -04:00
John Sully 4ed8f38a13 Don't do active replica work if we're not an active replica
Former-commit-id: 63dd1fb599
2020-04-13 22:35:06 -04:00
John Sully dfdc0cefdd Optimize replicaFeedSlaves by removing use of snprintf
Former-commit-id: 32561a9912
2020-04-13 22:11:34 -04:00
antirez d7b07d3ded Fix ACL HELP table missing comma. 2020-04-08 10:56:31 +02:00
mymilkbottles a953c6e55b Judge the log level in advance 2020-04-07 16:53:13 +02:00
antirez fdd6da647d Speedup INFO by counting client memory incrementally.
Related to #5145.

Design note: clients may change type when they turn into replicas or are
moved into the Pub/Sub category and so forth. Moreover the recomputation
of the bytes used is problematic for obvious reasons: it changes
continuously, so as a conservative way to avoid accumulating errors,
each client remembers the contribution it gave to the sum, and removes
it when it is freed or before updating it with the new memory usage.
2020-04-07 16:53:13 +02:00
qetu3790 5680ddd31d fix comments about RESIZE DB opcode in rdb.c
fix comments about RESIZE DB opcode in rdb.c
2020-04-07 16:53:13 +02:00
antirez b2f6881d83 Clarify redis.conf comment about lazyfree-lazy-user-del. 2020-04-07 16:53:13 +02:00
zhaozhao.zz 73e7bcc598 lazyfree: add a new configuration lazyfree-lazy-user-del
Delete keys in async way when executing DEL command, if
lazyfree-lazy-user-del is yes.
2020-04-07 16:53:13 +02:00
antirez 87924d6731 LCS: more tests. 2020-04-07 16:52:57 +02:00
antirez e835f0fe0c LCS: allow KEYS / STRINGS to be anywhere.
Initially they needed to be at the end so that we could extend to N
strings in the future, but after further consideration I no longer
believe it's worth it.
2020-04-07 16:52:57 +02:00
antirez 106501fab0 LCS tests. 2020-04-07 16:52:57 +02:00
antirez e46275a1dc LCS: get rid of STOREIDX option. Fix get keys helper. 2020-04-07 16:52:57 +02:00
antirez 9682cd452f LCS: fix stale comment. 2020-04-07 16:52:57 +02:00
antirez 28cf335ba8 LCS: output LCS len as well in IDX mode. 2020-04-07 16:52:57 +02:00
antirez a3690e8af7 LCS: MINMATCHLEN and WITHMATCHLEN options. 2020-04-07 16:52:57 +02:00
antirez 3c9778ce79 LCS: 7x speedup by accessing the array with better locality. 2020-04-07 16:52:57 +02:00
antirez 7ee6ee5982 LCS: implement KEYS option. 2020-04-07 16:52:57 +02:00
antirez c792f3e165 LCS: other fixes to range emission. 2020-04-07 16:52:57 +02:00
antirez cd2da01d40 LCS: fix emission of last range starting at index 0. 2020-04-07 16:52:57 +02:00
antirez a5fffca895 LCS: implement range indexes option. 2020-04-07 16:52:57 +02:00
antirez 087ed099d1 LCS: initial functionality implemented. 2020-04-07 16:52:57 +02:00
srzhao c5d805f877 Check OOM at script start to get stable lua OOM state.
Checking OOM by `getMaxMemoryState` inside script might get different result
with `freeMemoryIfNeededAndSafe` at script start, because lua stack and
arguments also consume memory.

This leads to memory `borderline` when memory grows near server.maxmemory:

- `freeMemoryIfNeededAndSafe` at script start detects no OOM, no memory freed
- `getMaxMemoryState` inside script detects OOM, script aborted

We solve this 'borderline' issue by saving OOM state at script start to get
stable lua OOM state.

related to issue #6565 and #5250.
2020-04-07 16:52:28 +02:00
Oran Agra dcd6726366 diffrent fix for runtest --host --port 2020-04-07 16:52:28 +02:00
Guy Benoish 728c620562 Try to fix time-sensitive tests in blockonkey.tcl
There is an inherent race between the deferring client and the
"main" client of the test: While the deferring client issues a blocking
command, we can't know for sure that by the time the "main" client
tries to issue another command (Usually one that unblocks the deferring
client) the deferring client is even blocked...
For lack of a better choice this commit uses TCL's 'after' in order
to give some time for the deferring client to issues its blocking
command before the "main" client does its thing.
This problem probably exists in many other tests but this commit
tries to fix blockonkeys.tcl
2020-04-07 16:52:28 +02:00
Guy Benoish 25875dddac Use __attribute__ only if __GNUC__ is defined 2020-04-07 16:52:28 +02:00
Guy Benoish 7cb94fd6cc Fix no-negative-zero test 2020-04-07 16:52:04 +02:00
Guy Benoish 71134e357f DEBUG OBJECT should pass keyname to module when loading 2020-04-07 16:52:04 +02:00
Guy Benoish 2535a172c1 streamReplyWithRange: Redundant XSETIDs to replica
propagate_last_id is declared outside of the loop but used
only from within the loop. Once it's '1' it will never go
back to '0' and will replicate XSETID even for IDs that
don't actually change the last_id.
While not a serious bug (XSETID always used group->last_id
so there's no risk), it does causes redundant traffic
between master and its replicas
2020-04-07 16:52:04 +02:00
Guy Benoish 9e4f7b426f Modules: Perform printf-like format checks in variadic API 2020-04-07 16:52:04 +02:00
Oran Agra 6f54629071 modules don't signalModifiedKey in setKey() since that's done (optionally) in RM_CloseKey 2020-04-07 16:52:04 +02:00
David Carlier e763a8debf debug, dump registers on arm too. 2020-04-07 16:52:04 +02:00
antirez 0f50c7c959 Simplify comment in moduleTryServeClientBlockedOnKey(). 2020-04-07 16:52:04 +02:00
Valentino Geron dc38619afb XREAD and XREADGROUP should not be allowed from scripts when BLOCK option is being used 2020-04-07 16:52:04 +02:00
Oran Agra b4966a914f change CI to build and run the module api tests 2020-04-07 16:52:04 +02:00
hwware 71f6e21cea fix spelling in cluster.c 2020-04-07 16:52:04 +02:00
Guy Benoish 115fd1136e Stale replica should allow MULTI/EXEC
Example: Client uses a pipe to send the following to a
stale replica:

MULTI
.. do something ...
DISCARD

The replica will reply the MUTLI with -MASTERDOWN and
execute the rest of the commands... A client using a
pipe might not be aware that MULTI failed until it's
too late.

I can't think of a reason why MULTI/EXEC/DISCARD should
not be executed on stale replicas...

Also, enable MULTI/EXEC/DISCARD during loading
2020-04-07 16:52:04 +02:00
Oran Agra ca5e8ac5b0 fix possible warning on incomplete struct init 2020-04-07 16:52:04 +02:00
Valentino Geron 1f6160ccb2 XACK should be executed in a "all or nothing" fashion.
First, we must parse the IDs, so that we abort ASAP.
The return value of this command cannot be an error if
the client successfully acknowledged some messages,
so it should be executed in a "all or nothing" fashion.
2020-04-07 16:52:04 +02:00
Xudong Zhang 67eca1bdde fix integer overflow 2020-04-07 16:52:04 +02:00
Guy Benoish 3a063f58c8 Make sure Redis does not reply with negative zero 2020-04-07 16:52:04 +02:00
hwware 74778c8a01 add check for not switching between optin optout mode directly 2020-04-07 16:52:04 +02:00
hwware 02cfb2cb1d add check for not providing both optin optout flag 2020-04-07 16:52:04 +02:00
Guy Benoish 6e5efbf918 PERSIST should notify a keyspace event 2020-04-07 16:52:04 +02:00
Guy Benoish f1ed8d93a0 Fix memory corruption in moduleHandleBlockedClients
By using a "circular BRPOPLPUSH"-like scenario it was
possible the get the same client on db->blocking_keys
twice (See comment in moduleTryServeClientBlockedOnKey)

The fix was actually already implememnted in
moduleTryServeClientBlockedOnKey but it had a bug:
the funxction should return 0 or 1 (not OK or ERR)

Other changes:
1. Added two commands to blockonkeys.c test module (To
   reproduce the case described above)
2. Simplify blockonkeys.c in order to make testing easier
3. cast raxSize() to avoid warning with format spec
2020-04-07 16:52:03 +02:00
John Sully 08c404120e Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 8d8115ff59f5838e13e911416eff7dfe2c0d92dc
2020-04-06 01:25:15 -04:00
John Sully a0447f23ac Fix failure to AUTH with master when masterauth is set last
Former-commit-id: 3fdc8608f3
2020-04-06 01:24:59 -04:00
John Sully 9b2392107c Add the ability to set a starting core # when setting thread affinity
Former-commit-id: 9e2e2067c6
2020-04-04 22:58:17 -04:00
John Sully a6444c8ce9 Fix issue #164
Former-commit-id: f112c77fcc
2020-04-04 22:45:12 -04:00
John Sully bf93e32e7e Role command protocol corruption with multiple masters
Former-commit-id: 888d69a87a
2020-04-04 22:32:15 -04:00
John Sully 2684a266c8 Fix subkey expires not replicating correctly, and AOF issues
Former-commit-id: bd183cdee1
2020-04-04 21:52:27 -04:00
antirez 5f98065e52 Redis 6.0-RC3. 2020-03-31 17:56:04 +02:00
antirez 81bf978d8c cast raxSize() to avoid warning with format spec. 2020-03-31 17:41:23 +02:00
antirez c202c54ff7 Minor changes to #7037. 2020-03-31 17:12:19 +02:00
Guy Benoish 5c23cd55d4 Modules: Test MULTI/EXEC replication of RM_Replicate
Makse sure call() doesn't wrap replicated commands with
a redundant MULTI/EXEC

Other, unrelated changes:
1. Formatting compiler warning in INFO CLIENTS
2. Use CLIENT_ID_AOF instead of UINT64_MAX
2020-03-31 17:12:19 +02:00
antirez 2a820251c8 timeout.c created: move client timeouts code there. 2020-03-31 16:57:20 +02:00
Oran Agra 454e12cb89 AOFRW on an empty stream created with MKSTREAM loads badkly
the AOF will be loaded successfully, but the stream will be missing,
i.e inconsistencies with the original db.

this was because XADD with id of 0-0 would error.

add a test to reproduce.
2020-03-31 16:57:20 +02:00
Guy Benoish 07acd86c7e RENAME can unblock XREADGROUP
Other changes:
Support stream in serverLogObjectDebugInfo
2020-03-31 16:57:20 +02:00
antirez a9706f96f4 Fix the propagate Tcl test after module changes. 2020-03-31 16:57:20 +02:00
antirez 6354b71663 Modify the propagate unit test to show more cases. 2020-03-31 16:57:20 +02:00
antirez 514ca204bb Fix module commands propagation double MULTI bug.
b512cb40 introduced automatic wrapping of MULTI/EXEC for the
alsoPropagate API. However this collides with the built-in mechanism
already present in module.c. To avoid complex changes near Redis 6 GA
this commit introduces the ability to exclude call() MUTLI/EXEC wrapping
for also propagate in order to continue to use the old code paths in
module.c.
2020-03-31 16:57:20 +02:00
antirez fde20b7967 Fix RM_Call() stale comment due to cut&paste. 2020-03-31 16:57:20 +02:00
OMG-By 99427a1183 fix: dict.c->dictResize()->minimal type 2020-03-31 16:57:20 +02:00
zhaozhao.zz a85d4dd136 PSYNC2: reset backlog_idx and master_repl_offset correctly 2020-03-31 16:57:20 +02:00
antirez b6e4291ce3 Precise timeouts: reference client pointer directly. 2020-03-31 16:57:20 +02:00
antirez c881ba1680 Precise timeouts: cleaup the table on unblock.
Now that this mechanism is the sole one used for blocked clients
timeouts, it is more wise to cleanup the table when the client unblocks
for any reason. We use a flag: CLIENT_IN_TO_TABLE, in order to avoid a
radix tree lookup when the client was already removed from the table
because we processed it by scanning the radix tree.
2020-03-31 16:56:46 +02:00
antirez 0e5723ff18 Precise timeouts: fix comments after functional change. 2020-03-31 16:56:46 +02:00
antirez 444089c55e Precise timeouts: use only radix tree for timeouts. 2020-03-31 16:56:46 +02:00
antirez c49ff92431 Precise timeouts: fast exit for clientsHandleShortTimeout(). 2020-03-31 16:56:46 +02:00
antirez e512707aed Precise timeouts: fix bugs in initial implementation. 2020-03-31 16:56:46 +02:00
antirez cedeec01f2 Precise timeouts: working initial implementation. 2020-03-31 16:56:46 +02:00
antirez b636856df0 Precise timeouts: refactor unblocking on timeout. 2020-03-31 16:56:46 +02:00
antirez 577656841f PSYNC2: fix backlog_idx when adjusting for meaningful offset
See #7002.
2020-03-31 16:56:46 +02:00
伯成 2a13f59a18 Boost up performance for redis PUB-SUB patterns matching
If lots of clients PSUBSCRIBE to same patterns, multiple pattens matching will take place. This commit change it into just one single pattern matching by using a `dict *` to store the unique pattern and which clients subscribe to it.
2020-03-31 12:47:14 +02:00
John Sully 6d084434fc Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: e6c8a157e136ac5e5b44b5ea60c619ad4e55942b
2020-03-30 00:58:38 -04:00
John Sully 8e0aa4ec72 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 86f7292ed375d509645458704828e72fdbfea936
2020-03-30 00:57:58 -04:00
John Sully 38d16ea581 Merge branch 'redis_6_merge' of https://github.com/JohnSully/KeyDB into redis_6_merge
Former-commit-id: 95b4f899c5
2020-03-30 00:52:43 -04:00
John Sully 549b15d5a2 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 2946155313
2020-03-30 00:52:12 -04:00
John Sully 12f76b2b95 Allow active replicas to connect to each other when replica-serve-stale-data is set
Former-commit-id: f2ca2aa1f7
2020-03-30 00:51:40 -04:00
John Sully 883de95712 Don't send build log to stderr
Former-commit-id: b20bf10fda
2020-03-28 23:36:57 -04:00
John Sully f8f752f2ab Merge branch 'unstable' into redis_6_merge
Former-commit-id: 208c15bc16
2020-03-27 14:50:37 -04:00
John Sully 4af17a23d8 Raspberry Pi fixes (compile and replication)
Former-commit-id: c3d3c82f3a
2020-03-27 12:46:25 -04:00
John Sully 8becc84c61 OS X Build break fix
Former-commit-id: 98da479d9241c077d3c11787800075dea91e989e
2020-03-26 15:20:55 -04:00
John Sully 366e00df79 bump version
Former-commit-id: 8e855c4568fd555f6df9a5b00bab2e42248127e3
2020-03-26 01:18:21 -04:00
John Sully 6742a6a70c Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: a5d8a93a476366ef2aa6fe9c248f33288b322ff6
2020-03-26 01:17:56 -04:00
John Sully bdcdd1396b merge
Former-commit-id: 187773190f153f8a7236bc2e4f42bffe6885f727
2020-03-26 01:16:36 -04:00
John Sully f4caa84987 Fix merge issues
Former-commit-id: b22d9cc27d
2020-03-25 22:26:27 -04:00
John Sully 9c4b66b9a4 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 908cf5042e
2020-03-25 22:12:22 -04:00
John Sully 71fe6f7ba9 Fix issue #143
Former-commit-id: 6ec1641294
2020-03-25 21:55:31 -04:00
John Sully b443553a3d Give a better error when handling std::terminate
Former-commit-id: 7b79ec360b
2020-03-25 16:27:24 -04:00
John Sully 6c04367c8d Fix breaks from merge
Former-commit-id: fa76d19bee9df21967c4d8554128eebdd19021fa
2020-03-25 16:22:32 -04:00
John Sully 1fc4cb38ce Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 44f1b065ed6d3b0ad2a62f093432743b98fad6be
2020-03-25 15:47:24 -04:00
John Sully b1c9dcaa05 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 718aee242d
2020-03-25 15:47:12 -04:00
John Sully 118bd49a4e Add roundtrip test for subkey expires
Former-commit-id: 56fc6b7deb
2020-03-25 15:34:30 -04:00
antirez 28d402d31b PSYNC2: meaningful offset test. 2020-03-25 15:55:24 +01:00
antirez ce73158a9c PSYNC2: meaningful offset implemented.
A very commonly signaled operational problem with Redis master-replicas
sets is that, once the master becomes unavailable for some reason,
especially because of network problems, many times it wont be able to
perform a partial resynchronization with the new master, once it rejoins
the partition, for the following reason:

1. The master becomes isolated, however it keeps sending PINGs to the
replicas. Such PINGs will never be received since the link connection is
actually already severed.
2. On the other side, one of the replicas will turn into the new master,
setting its secondary replication ID offset to the one of the last
command received from the old master: this offset will not include the
PINGs sent by the master once the link was already disconnected.
3. When the master rejoins the partion and is turned into a replica, its
offset will be too advanced because of the PINGs, so a PSYNC will fail,
and a full synchronization will be required.

Related to issue #7002 and other discussion we had in the past around
this problem.
2020-03-25 15:55:24 +01:00
antirez 45ba72ad01 Explain why we allow transactions in -BUSY state.
Related to #7022.
2020-03-25 15:55:24 +01:00
Oran Agra e1e2f91589 MULTI/EXEC during LUA script timeout are messed up
Redis refusing to run MULTI or EXEC during script timeout may cause partial
transactions to run.

1) if the client sends MULTI+commands+EXEC in pipeline without waiting for
response, but these arrive to the shards partially while there's a busy script,
and partially after it eventually finishes: we'll end up running only part of
the transaction (since multi was ignored, and exec would fail).

2) similar to the above if EXEC arrives during busy script, it'll be ignored and
the client state remains in a transaction.

the 3rd test which i added for a case where MULTI and EXEC are ok, and
only the body arrives during busy script was already handled correctly
since processCommand calls flagTransaction
2020-03-25 15:55:24 +01:00
antirez 484a14ebde Improve comments of replicationCacheMasterUsingMyself(). 2020-03-25 15:55:24 +01:00
antirez 4cfceac287 Fix BITFIELD_RO test. 2020-03-25 15:55:24 +01:00
antirez 6a1a5cb2a1 Abort transactions after -READONLY error. Fix #7014. 2020-03-25 15:55:24 +01:00
antirez 243b26d97d Minor changes to BITFIELD_RO PR #6951. 2020-03-25 15:55:24 +01:00
bodong.ybd 015d1cb2ff Added BITFIELD_RO variants for read-only operations. 2020-03-25 15:55:24 +01:00
antirez 5a13e0feb1 Modules: updated function doc after #7003. 2020-03-25 15:55:24 +01:00
Guy Benoish 6680c06705 Allow RM_GetContextFlags to work with ctx==NULL 2020-03-25 15:55:24 +01:00
hwware 2dcae61087 fix potentical memory leak in redis-cli 2020-03-25 15:55:24 +01:00
Yossi Gottlieb 700126e9cf Fix crashes related to failed/rejected accepts. 2020-03-25 15:55:24 +01:00
Yossi Gottlieb 1f1d642e01 Cluster: fix misleading accept errors. 2020-03-25 15:55:24 +01:00
Yossi Gottlieb 1a948d0c5b Conns: Fix connClose() / connAccept() behavior.
We assume accept handlers may choose to reject a connection and close
it, but connAccept() callers can't distinguish between this state and
other error states requiring connClose().

This makes it safe (and mandatory!) to always call connClose() if
connAccept() fails, and safe for accept handlers to close connections
(which will defer).
2020-03-25 15:55:24 +01:00
hwware 4a0249c0c8 remove redundant Semicolon 2020-03-25 15:55:24 +01:00
hwware 9c9ef6fb9b clean CLIENT_TRACKING_CACHING flag when disabled caching 2020-03-25 15:55:24 +01:00
hwware 04d838274f add missing commands in cluster help 2020-03-25 15:55:24 +01:00
artix 5ccdb7a5be Support Redis Cluster Proxy PROXY INFO command 2020-03-25 15:55:24 +01:00
zhaozhao.zz 714ae38ee1 Threaded IO: bugfix client kill may crash redis 2020-03-25 15:54:34 +01:00
zhaozhao.zz d3491c5182 Threaded IO: bugfix #6988 process events while blocked 2020-03-25 15:54:34 +01:00
antirez 07c75f60f3 Restore newline at the end of redis-cli.c 2020-03-25 15:54:34 +01:00
bodong.ybd c609bf3f2c Fix bug of tcl test using external server 2020-03-25 15:54:34 +01:00
박승현 799a7dd8ac Update redis.conf 2020-03-25 15:54:34 +01:00
zhaozhao.zz db4f03bc51 Threaded IO: handle pending reads clients ASAP after event loop 2020-03-25 15:54:34 +01:00
chendianqiang 1994eda07e use correct list for moduleUnregisterUsedAPI 2020-03-25 15:54:34 +01:00
fengpf e8c11fe29d fix comments in latency.c 2020-03-25 15:54:34 +01:00
WuYunlong 37c6571a6c Fix master replica inconsistency for upgrading scenario.
Before this commit, when upgrading a replica, expired keys will not
be loaded, thus causing replica having less keys in db. To this point,
master and replica's keys is logically consistent. However, before
the keys in master and replica are physically consistent, that is,
they have the same dbsize, if master got a problem and the replica
got promoted and becomes new master of that partition, and master
updates a key which does not exist on master, but physically exists
on the old master(new replica), the old master would refuse to update
the key, thus causing master and replica data inconsistent.

How could this happen?
That's all because of the wrong judgement of roles while starting up
the server. We can not use server.masterhost to judge if the server
is master or replica, since it fails in cluster mode.

When we start the server, we load rdb and do want to load expired keys,
and do not want to have the ability to active expire keys, if it is
a replica.
2020-03-25 15:54:34 +01:00
antirez 077165b6eb Example sentinel conf: document requirepass. 2020-03-25 15:54:34 +01:00
guodongxiaren 0fd48a7c53 string literal should be const char* 2020-03-25 15:54:34 +01:00
WuYunlong 23ccd476b7 Add 14-consistency-check.tcl to prove there is a data consistency issue. 2020-03-25 15:54:34 +01:00
antirez 352ea2365f Aesthetic changes in PR #6989. 2020-03-25 15:54:34 +01:00
Itamar Haber 2eec521f8c Adds keyspace notifications to migrate and restore 2020-03-25 15:54:34 +01:00
antirez 91af3f73e1 Regression test for #7011. 2020-03-25 15:54:34 +01:00
bodong.ybd a8f56fbfcd Remove duplicate obj files in Makefile 2020-03-25 15:54:34 +01:00
antirez 21c22bcd9a ACL: default user off should not allow automatic authentication.
This fixes issue #7011.
2020-03-25 15:54:34 +01:00
antirez 63e4a47010 Sentinel: document auth-user directive. 2020-03-25 15:54:34 +01:00
antirez d9f9a29afa ACL: Make Redis 6 more backward compatible with requirepass.
Note that this as a side effect fixes Sentinel "requirepass" mode.
2020-03-25 15:54:34 +01:00
antirez 31707f25c7 Sentinel: implement auth-user directive for ACLs. 2020-03-25 15:54:34 +01:00
John Sully 41dfd175a8 Fix failure to load subkey expires
Former-commit-id: 528a43bd6c
2020-03-25 01:38:58 -04:00
John Sully 9ff5d3f3c4 Expire entry needs to be resorted after a subkey expires
Former-commit-id: b357803362
2020-03-25 01:06:40 -04:00
John Sully 982175b584 Evict on load if we have a storage provider
Former-commit-id: bb091796c3da7282e040c7b72a28ec1c5f5ecfb7
2020-03-24 14:49:43 -04:00
John Sully aed3d33499 Prevent issue where count can be out of sync temporarily, causing crashes where we expect the count to be perfect
Former-commit-id: 77c9f36413c6f0cbb0b13a7ec746746c97faadcd
2020-03-24 00:21:12 -04:00
John Sully ad8a61697b Fix OOM errors during forkless bgsave
Former-commit-id: c31c64b13409c741e8d52ad06add78300c39fce2
2020-03-23 23:12:10 -04:00
John Sully f0e85993ad Fix incorrect prefix comparison
Former-commit-id: 1ef167546be0678edd457d65a5368e8706fde0a3
2020-03-23 22:51:46 -04:00
John Sully 28c632729e Fix incorrect count when loading FLASH
Former-commit-id: 38ee9c0df144621f7ca750527e9efb16e754ef40
2020-03-23 19:47:48 -04:00
John Sully b695c0279e Prevent bookkeeping keys from leaking through
Former-commit-id: 1a5af28e115fc123bf250b4a80ac69232bb3add0
2020-03-23 18:06:47 -04:00
John Sully 2b199b384d Unstable branch should always be version 0.0.0
Former-commit-id: 448808529a
2020-03-19 15:52:24 -04:00
John Sully 436ffa98de Merge branch 'RELEASE_5' into unstable
Former-commit-id: a0bc208412
2020-03-19 15:38:16 -04:00
John Sully 4f55afa948 Print stack traces of other threads in the deadlock detector
Former-commit-id: 6b0172b9bf
2020-03-19 15:37:49 -04:00
John Sully 833f5b39f4 Log which thread a message came from
Former-commit-id: bc1eccb66d
2020-03-19 15:37:24 -04:00
John Sully 1b9ef774da Fix lock inversion in processEventsWhileBlocked
Former-commit-id: a9249d4a82
2020-03-19 15:28:39 -04:00
John Sully 96be5f6a6c Prevent dangling lock when we can't free the client
Former-commit-id: 3c373494d6
2020-03-19 14:34:23 -04:00
John Sully 3b8f9b0d27 Merge branch 'PRO_RELEASE_6' of https://github.com/JohnSully/KeyDB-Pro into PRO_RELEASE_6
Former-commit-id: 1c1f3c920411ee94eb8b81922189b98c9631b3de
2020-03-17 17:48:27 -04:00
John Sully b0dceb9410 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 23c3316c10f2771bc26e50698b48934ec7549bcd
2020-03-17 17:47:55 -04:00
John Sully a767ba8447 Special case version 0.0.0 which is equal to any version
Former-commit-id: 869d037490b6905674f75a8552898aed72148558
2020-03-17 17:25:36 -04:00
John Sully b25ac5e6c1 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: dd8339da10c17f0e2f238310a10e97395f8f12ac
2020-03-17 17:11:51 -04:00
John Sully 9ae07e994d Cache count of keys in database
Former-commit-id: 7cd266030ad82b5fddd4668d666adc95e1bed475
2020-03-17 17:11:41 -04:00
John Sully 0249ff44a5 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: ff3190cac5c5d222904aa2d57d97c752c1b7e554
2020-03-17 00:10:09 -04:00
John Sully e800858c4c Merge branch 'unstable' into redis_6_merge
Former-commit-id: 40761e4031
2020-03-17 00:09:48 -04:00
John Sully 72f6847f95 Fix issue #153: Config get replicaof returns a corrupt response
Former-commit-id: 5aef606d3b
2020-03-16 20:43:46 -04:00
John Sully b1356bb175 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: aea8413a15001e2c27cf03dd41fa15151b0d3ccb
2020-03-15 18:48:45 -04:00
John Sully 61176a1a5e Merge branch 'unstable' into redis_6_merge
Former-commit-id: 4671cd6002
2020-03-15 18:47:27 -04:00
John Sully af3afa979a Handle HTTP error codes with MOTD
Former-commit-id: 2ec0b2cd20
2020-03-15 18:47:01 -04:00
John Sully 8061e3460d Update MOTD url for Pro
Former-commit-id: feed518042f3046016c26beda1c08cc721914943
2020-03-15 18:34:42 -04:00
John Sully 0e7552ff36 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 2765895981196adf6a8300eb4a704d60ec651f56
2020-03-15 18:34:15 -04:00
John Sully 97537d0525 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 07effa3925
2020-03-15 18:33:24 -04:00
John Sully 143ae07899 Update MOTD URL
Former-commit-id: cd76a71de3
2020-03-15 18:32:05 -04:00
John Sully 009dc09a56 Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: c70edb09d33b746fa6893488327f301aff455b58
2020-03-15 18:28:00 -04:00
John Sully 9a54e3f530 Add fallback if we fail to evict normally with FLASH (flush everything)
Former-commit-id: 66ee85a8d5e24514083aa3478dcf0cf3da86520e
2020-03-15 18:27:10 -04:00
John Sully 20c1b7eb63 Change the default for maxmemory samples to 10 to reduce issues with FLASH storage and eviction failure
Former-commit-id: 8571d8aca9b462d600b78854c0795c8b33520088
2020-03-15 18:26:46 -04:00
antirez 317496405a Update linenoise. 2020-03-12 15:53:47 +01:00
lifubang 8e3c92fff8 add askpass mode
Signed-off-by: lifubang <lifubang@acmcoder.com>
2020-03-12 15:53:47 +01:00
lifubang 109296b438 update linenoise to https://github.com/antirez/linenoise/tree/fc9667a81d43911a6690fb1e68c16e6e3bb8df05
Signed-off-by: lifubang <lifubang@acmcoder.com>
2020-03-12 15:53:47 +01:00
Jamie Scott 6e3f53a46f Remove default guidance in Redis.conf
Removing the default guidance in Redis.conf since this is not an available value.
2020-03-12 15:53:47 +01:00
Jamie Scott 2880ed0b90 Update Redis.conf to improve TLS usability
When using TLS with a Redis.conf file the line for TLS reading tls-cert-file redis.crt tls-key-file redis.key is interpreted as one complete directive. I am separating this on two separate lines to improve usability so users do not get the below error.

ubuntu@ip-172-31-29-250:~/redis-6.0-rc1$ ./src/redis-server redis.conf 

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 145
>>> 'tls-cert-file redis.crt tls-key-file redis.key'
wrong number of arguments
ubuntu@ip-172-31-29-250:~/redis-6.0-rc1$ vi redis.conf 
ubuntu@ip-172-31-29-250:~/redis-6.0-rc1$ ./src/redis-server redis.conf 
23085:C 04 Mar 2020 01:58:12.631 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23085:C 04 Mar 2020 01:58:12.631 # Redis version=5.9.101, bits=64, commit=00000000, modified=0, pid=23085, just started
23085:C 04 Mar 2020 01:58:12.631 # Configuration loaded
23085:M 04 Mar 2020 01:58:12.632 * Increased maximum number of open files to 10032 (it was originally set to 1024).
2020-03-12 15:53:47 +01:00
Johannes Truschnigg 9f1b635067 Signal systemd readiness atfer Partial Resync
"Partial Resynchronization" is a special variant of replication success
that we have to tell systemd about if it is managing redis-server via a
Type=Notify service unit.
2020-03-12 15:53:47 +01:00
Oran Agra cde46df309 fix for flaky psync2 test
*** [err]: PSYNC2: total sum of full synchronizations is exactly 4 in tests/integration/psync2.tcl
Expected 5 == 4 (context: type eval line 6 cmd {assert {$sum == 4}} proc ::test)

issue was that sometime the test got an unexpected full sync since it
tried to switch to the replica before it was in sync with it's master.
2020-03-12 15:53:47 +01:00
antirez 75d5ed8938 ae.c: fix crash when resizing the event loop.
See #6964. The root cause is that the event loop may be resized from an
event callback itself, causing the event pointer to be invalid.
2020-03-12 15:53:47 +01:00
antirez ac4e639df5 Fix release notes spelling mistake. 2020-03-06 11:09:52 +01:00
antirez c208956fbe Redis 6 RC2. 2020-03-05 16:00:17 +01:00
qetu3790 6bd9b67488 Fix not used constant in lru_test_mode.
LRU_CYCLE_PERIOD is defined,but not used.
2020-03-05 12:51:15 +01:00
hwware 92ebd0aff7 add missing file marco 2020-03-05 12:51:15 +01:00
ShooterIT 02d1a6091b Avoid compiler warnings 2020-03-05 12:51:15 +01:00
antirez 5b721f6abb RDB deletion: document it in example redis.conf. 2020-03-05 12:51:15 +01:00
antirez 749a4e962a Make sync RDB deletion configurable. Default to no. 2020-03-05 12:51:15 +01:00
antirez a0fec660f6 Check that the file exists in removeRDBUsedToSyncReplicas(). 2020-03-05 12:51:15 +01:00
antirez 00e53fb140 Introduce bg_unlink(). 2020-03-05 12:51:14 +01:00
antirez e91ca9fee9 Remove RDB files used for replication in persistence-less instances. 2020-03-05 12:51:14 +01:00
antirez 93328171ca Log RDB deletion in persistence-less instances. 2020-03-05 12:51:14 +01:00
antirez dcafd2d77e Use a smaller getkeys global buffer.
The idea is that very few commands have a lot of keys, and when this
happens the allocation time becomes neglegible.
2020-03-05 12:51:14 +01:00
Oran Agra 328b6e473c Optimize temporary memory allocations for getKeysFromCommand mechanism
now that we may use it more often (ACL), these excessive calls to malloc
and free can become an overhead.
2020-03-05 12:51:14 +01:00
antirez 8a7e1fe3b0 Modules: reformat RM_Scan() top comment a bit. 2020-03-05 12:51:14 +01:00
antirez 76cfe21ff7 Modules: more details in RM_Scan API top comment. 2020-03-05 12:51:14 +01:00
Oran Agra 0693ac1961 RM_Scan disable dict rehashing
The callback approach we took is very efficient, the module can do any
filtering of keys without building any list and cloning strings, it can
also read data from the key's value. but if the user tries to re-open
the key, or any other key, this can cause dict re-hashing (dictFind does
that), and that's very bad to do from inside dictScan.

this commit protects the dict from doing any rehashing during scan, but
also warns the user not to attempt any writes or command calls from
within the callback, for fear of unexpected side effects and crashes.
2020-03-05 12:51:14 +01:00
Guy Benoish 470de731e9 Add RM_CreateStringFromDouble 2020-03-05 12:51:14 +01:00
Oran Agra 4ca389bb60 add no_auth to COMMAND INFO 2020-03-05 12:51:14 +01:00
Oran Agra bec15e6534 module api docs for aux_save and aux_load 2020-03-05 12:51:14 +01:00
Guy Benoish f14bc2799e streamReplyWithRangeFromConsumerPEL: Redundant streamDecodeID 2020-03-05 12:51:14 +01:00
antirez c1951137bb Show Redis version when not understanding a config directive.
This makes simpler to give people help when posting such kind of errors
in the mailing list or other help forums, because sometimes the
directive looks well spelled, but the version of Redis they are using is
not able to support it.
2020-03-05 12:51:14 +01:00
John Sully 063d585555 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 1982bf26a5d24327389676031ecc599a5a6d88a7
2020-03-04 17:24:51 -05:00
John Sully 264895dcec Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: b0a3bb848937d24dd74de63032306fd92c61dd7b
2020-03-04 17:24:36 -05:00
John Sully 1187fb6afc Fix CLANG build break
Former-commit-id: 5e63c0955d
2020-03-04 17:24:17 -05:00
John Sully 591cc30206 Fix CLANG build break
Former-commit-id: e523afa741
2020-03-04 17:24:00 -05:00
John Sully 435bd4c2fb Fix CLANG build break
Former-commit-id: c2a98a60f9
2020-03-04 17:23:40 -05:00
John Sully 7033048f7a finish merge
Former-commit-id: 66063a19f6cdbc87ead8ecbd4887134438ee1ccd
2020-03-04 17:22:57 -05:00
John Sully 4ccd0c7a0f Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: bef19fefeb293e44e31dfefe383eef99e4cd7721
2020-03-04 17:15:54 -05:00
John Sully 958b0b110c Merge branch 'unstable' into redis_6_merge
Former-commit-id: 6bc92d6d31
2020-03-04 17:13:50 -05:00
John Sully 2105a6300c Merge branch 'unstable' into RELEASE_5
Former-commit-id: 13cf8bbeb7
2020-03-04 17:13:32 -05:00
John Sully 6a8fa9eeb1 Add missing files from last checkin
Former-commit-id: 60c0d4104d
2020-03-04 17:13:18 -05:00
John Sully e39dd04f6c Merge branch 'unstable' into redis_6_merge
Former-commit-id: 52fd4445a4
2020-03-04 17:13:01 -05:00
John Sully 0a67cb4c6a Merge branch 'unstable' into RELEASE_5
Former-commit-id: 693ba4ed4a
2020-03-04 17:09:29 -05:00
John Sully 01a85ba7fe Add extra logging when reporting errors from masters - especially in rreplay
Former-commit-id: 5397f0b033
2020-03-04 17:09:12 -05:00
John Sully 550413070c MOTD refactor
Former-commit-id: 6c78ec7c41
2020-03-04 16:22:55 -05:00
John Sully 864871b57b Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 5b89b51192154e66e8ad87ce342a9cd4ab7a0130
2020-03-04 15:34:27 -05:00
John Sully f9c70eff94 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: a14d1d5b55a507a83cf5b85920607a0d013e7037
2020-03-04 15:33:59 -05:00
John Sully bd0bfe4d05 min-clients-per-thread needs to use the new config code
Former-commit-id: fed4bd5269
2020-03-04 15:14:41 -05:00
John Sully 0f89436537 Update README.md
Former-commit-id: c0882864f2
2020-03-03 13:58:48 -08:00
John Sully 2e973febb5 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 51e889277c59adb25a8724b25706631e6adca366
2020-03-01 22:17:04 -05:00
John Sully 8366d765c0 Add option to build pro without license checks
Former-commit-id: 0713518d2f34559a06db31a9023228b91ce60af3
2020-03-01 22:16:25 -05:00
John Sully 5528c40348 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 656bacd614f359742f6bd2df3fd2009c44c3d788
2020-03-01 21:49:21 -05:00
John Sully 24ea373e68 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 1a7e2e663e
2020-03-01 21:48:51 -05:00
John Sully 9a0bb834e9 Merge branch 'unstable' into RELEASE_5
Former-commit-id: faa87ed839
2020-03-01 21:43:21 -05:00
John Sully aab740a2e3 Update tests to reflect new CRON name (keydb.cron)
Former-commit-id: 83f585e30a
2020-03-01 21:42:01 -05:00
benschermel 278916ca16 Merge branch 'unstable' into RELEASE_5
Former-commit-id: 7a244bb847
2020-03-01 19:53:32 -05:00
John Sully 556108ae22 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 197022aa76949664dfd866e0e71602bf23cbc3a0
2020-03-01 19:18:56 -05:00
John Sully 95b0448e4d Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 4e8000d43cd4e23c90bf7e262835fae5ae6da34d
2020-03-01 19:18:34 -05:00
John Sully 4ae77acde4 Rename cron command to KEYDB.CRON and add help
Former-commit-id: 1b925119b5
2020-03-01 19:18:21 -05:00
John Sully cb82710daf Rename cron command to KEYDB.CRON and add help
Former-commit-id: 3eb847e28f
2020-03-01 19:17:58 -05:00
John Sully b950b89326 Bump version
Former-commit-id: e5776fd1a05b329c3113b94d26fba9e39816644f
2020-02-29 00:04:24 -05:00
John Sully f7c93230d8 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: e559a947e6d233146416e68a7c69d4e9b2eadd6c
2020-02-29 00:03:55 -05:00
John Sully e9501f7e0c Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: a60d71e13335bdf231b5f1bec61b457056dc5e0a
2020-02-28 23:57:45 -05:00
John Sully 0af756d4d7 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 9dc8f30e47
2020-02-28 23:56:26 -05:00
John Sully b69a8826fa Bump version
Former-commit-id: 3ce6441a0c
2020-02-28 23:53:54 -05:00
John Sully c27596230d Merge branch 'unstable' into RELEASE_5
Former-commit-id: 6d00a1a5cf
2020-02-28 23:53:00 -05:00
John Sully 1d804ef499 Fix compile failure on raspberry pi machines, issue #141
Former-commit-id: aaca32a5cd
2020-02-28 23:49:17 -05:00
John Sully f2c68909dc Fix not respecting max clients config, issue #147
Former-commit-id: 54c96d1995
2020-02-28 22:04:42 -05:00
John Sully 67d78e7808 Fix issue #146
Former-commit-id: e5a2d59446
2020-02-28 21:21:05 -05:00
antirez 446618dd97 Changelog: explain Redis 6 SPOP change. 2020-02-27 18:04:34 +01:00
Hengjian Tang 6718d5d375 modify the read buf size according to the write buf size PROTO_IOBUF_LEN defined before 2020-02-27 18:02:30 +01:00
bodong.ybd 9fb8903adb Fix spop return nil #4709 2020-02-27 18:02:30 +01:00
Ariel 663d207da4 fix ThreadSafeContext lock/unlock function names 2020-02-27 18:02:30 +01:00
antirez b977f87438 Fix SDS misuse in enumConfigSet(). Related to #6778. 2020-02-27 18:02:30 +01:00
Guy Benoish 0f578ef183 XREADGROUP should propagate XCALIM/SETID in MULTI/EXEC
Use built-in alsoPropagate mechanism that wraps commands
in MULTI/EXEC before sending them to replica/AOF
2020-02-27 18:02:30 +01:00
antirez 310a80764d Remove useless comment from enumConfigSet(). 2020-02-27 18:02:30 +01:00
Oran Agra 5daed7baee fix race in module api test for fork
in some cases we were trying to kill the fork before it got created
2020-02-27 18:02:30 +01:00
Ponnuvel Palaniyappan 3af14cfa3d Fix a potential overflow with strncpy 2020-02-27 18:02:30 +01:00
Guy Benoish 9d5f9b3cb5 Modules: Do not auto-unblock clients if not blocked on keys 2020-02-27 18:02:30 +01:00
antirez ae97c31644 Improve aeDeleteEventLoop() top comment grammar. 2020-02-27 18:02:30 +01:00
Oran Agra 7390aa673f fix github actions failing latency test for active defrag - part 2
it seems that running two clients at a time is ok too, resuces action
time from 20 minutes to 10. we'll use this for now, and if one day it
won't be enough we'll have to run just the sensitive tests one by one
separately from the others.

this commit also fixes an issue with the defrag test that appears to be
very rare.
2020-02-27 18:02:30 +01:00
wangyuan21 64700cca61 free time event when delete eventloop 2020-02-27 18:02:30 +01:00
Oran Agra 7fec53a9af fix github actions failing latency test for active defrag
seems that github actions are slow, using just one client to reduce
false positives.

also adding verbose, testing only on latest ubuntu, and building on
older one.

when doing that, i can reduce the test threshold back to something saner
2020-02-27 18:02:30 +01:00
srzhao 3ab91ff206 fix impl of aof-child whitelist SIGUSR1 feature. 2020-02-27 18:02:30 +01:00
Oran Agra c44794bd3c Fix latency sensitivity of new defrag test
I saw that the new defag test for list was failing in CI recently, so i
reduce it's threshold from 12 to 60.

besides that, i add / improve the latency test for that other two defrag
tests (add a sensitive latency and digest / save checks)

and fix bad usage of debug populate (can't overrides existing keys).
this was the original intention, which creates higher fragmentation.
2020-02-27 18:02:30 +01:00
meir@redislabs.com 22c571795c Changed log level for module fork api from 'notice' to 'verbos'. 2020-02-27 18:02:30 +01:00
antirez 75a7615ce2 Tracking: optin/out implemented. 2020-02-27 18:02:30 +01:00
hwware 7e6b81527c format fix 2020-02-27 18:02:30 +01:00
antirez 2542ff9c25 Test engine: experimental change to avoid busy port problems. 2020-02-27 18:02:30 +01:00
hwware afe5179dd4 fix potentical memory leaks 2020-02-27 18:02:30 +01:00
antirez 22ad06eafd Test engine: detect timeout when checking for Redis startup. 2020-02-27 18:02:30 +01:00
Oran Agra 79e8b17d7b Defrag big lists in portions to avoid latency and freeze
When active defrag kicks in and finds a big list, it will create a bookmark to
a node so that it is able to resume iteration from that node later.

The quicklist manages that bookmark, and updates it in case that node is deleted.

This will increase memory usage only on lists of over 1000 (see
active-defrag-max-scan-fields) quicklist nodes (1000 ziplists, not 1000 items)
by 16 bytes.

In 32 bit build, this change reduces the maximum effective config of
list-compress-depth and list-max-ziplist-size (from 32767 to 8191)
2020-02-27 18:00:47 +01:00
antirez 2d9a144515 Test engine: better tracking of what workers are doing. 2020-02-27 18:00:47 +01:00
Guy Benoish d1be7aaa18 XGROUP DESTROY should unblock XREADGROUP with -NOGROUP 2020-02-27 18:00:47 +01:00
hwware b995612a78 add missing subcommand description for debug oom 2020-02-27 18:00:47 +01:00
hayashier 253fcf98f8 fix typo from fss to rss 2020-02-27 18:00:47 +01:00
Guy Benoish 5a15c0edf9 Fix memory leak in test_ld_conv 2020-02-27 18:00:47 +01:00
antirez 54237ff024 Test is more complex now, increase default timeout. 2020-02-27 18:00:47 +01:00
Madelyn Olson fa54ce9036 Give an error message if you specify redirect twice 2020-02-27 18:00:47 +01:00
Madelyn Olson 188f478f43 Minor CSC fixes and fixed documentation 2020-02-27 18:00:47 +01:00
antirez a227fd7cca Tracking: fix max-keys configuration directive. 2020-02-27 18:00:46 +01:00
Itamar Haber 3c2b67dc2a Fixes segfault on calling trackingGetTotalKeys
... with CSC disabled
2020-02-27 18:00:46 +01:00
antirez 1c2d250dd2 Signal key as modified when expired on-access.
This fixes WATCH and client side caching with keys expiring because of
a synchronous access and not because of background expiring.
2020-02-27 18:00:46 +01:00
antirez aa556cb7dd Tracking: first set of tests for the feature. 2020-02-27 18:00:46 +01:00
antirez 13fbdf9706 Rax.c: populate data field after random walk. 2020-02-27 17:59:57 +01:00
antirez 5173b1042e Tracking: fix operators precedence error in bcast check. 2020-02-27 17:59:57 +01:00
antirez e264fa8917 Tracking: rename INFO field with total items. 2020-02-27 17:59:57 +01:00
antirez 2fdce45e9d Tracking: fix behavior when switchinig from normal to BCAST. 2020-02-27 17:59:57 +01:00
antirez fce22c6a42 Tracking: first conversion from hashing to key names. 2020-02-27 17:59:57 +01:00
antirez d5517def76 Tracking: fix sending messages bug + tracking off bug. 2020-02-27 17:59:57 +01:00
Oran Agra d733b3ba17 add no-slowlog option to RM_CreateCommand 2020-02-27 17:59:57 +01:00
antirez 7841d0234f Tracking: BCAST: basic feature now works. 2020-02-27 17:59:57 +01:00
antirez 261fabeaa4 Tracking: BCAST: broadcasting of keys in prefixes implemented. 2020-02-27 17:59:57 +01:00
antirez abdaebc6c4 Tracking: BCAST: registration in the prefix table. 2020-02-27 17:59:57 +01:00
antirez ed36f3c76f Tracking: BCAST: parsing of the options + skeleton. 2020-02-27 17:59:57 +01:00
antirez a34422aee7 Tracking: always reply with an array of keys. 2020-02-27 17:59:57 +01:00
antirez ddc4965ac5 Tracking: minor change of names and new INFO field. 2020-02-27 17:59:57 +01:00
John Sully e8b9258890 Fix crash propogating stale keys
Former-commit-id: d95bead383
2020-02-26 21:49:40 -05:00
John Sully f45939f147 Change Redis to KeyDB
Former-commit-id: ee5f026eea133ad851bfb3e8788a15ac798ca7e6
2020-02-17 23:46:29 -05:00
John Sully 79f0c0c8d9 Change Redis to KeyDB
Former-commit-id: e6316c8106caa9103d2bef6af35721a0be87aae0
2020-02-17 23:46:17 -05:00
John Sully 014db04212 Change Redis to KeyDB
Former-commit-id: 51ea3cf30c
2020-02-17 23:46:01 -05:00
John Sully 67eccf74ba Change Redis to KeyDB
Former-commit-id: 6ad6c1d780
2020-02-17 23:45:40 -05:00
John Sully a711a040e4 C++14 build fix
Former-commit-id: b45f50efa2fb56aa995ee6ceb6bd91380c28187c
2020-02-17 23:29:23 -05:00
John Sully 31cfd1ad41 C++14 build fix
Former-commit-id: 5a3e3c9fe20dabe294c439cd2b22e929a228f596
2020-02-17 23:29:03 -05:00
John Sully fbf7074169 Bump version
Former-commit-id: 7f84d6d6301303a3277910bf93e5d8dc900908c1
2020-02-17 22:27:50 -05:00
John Sully 4dbdce7494 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 5db2ab0ef538391eb2e20cce6a6af6b750458db0
2020-02-17 22:27:11 -05:00
John Sully 2102880699 override eviction policy for flash
Former-commit-id: 48a4f967e66ba765be96c9f8e113f808a4390f88
2020-02-17 22:26:48 -05:00
John Sully 4777e98e92 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: ad5a015388a3180bcbfefebf106a1a56e304e380
2020-02-17 22:03:54 -05:00
John Sully c248e27638 We should give a nice error message when we can't init a storage provider
Former-commit-id: 6c5acd8fe926d9f66fa5b13a2b962e5632f148de
2020-02-17 22:03:35 -05:00
John Sully 848be11ba0 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 50127eec445cb8d7abceb683f2afbd7aad90a3ae
2020-02-17 21:51:02 -05:00
John Sully 48d95c8e76 Tune rocksdb
Former-commit-id: 95d91b1ff8c8080dfcbf59e51d3eff73d27dcfb5
2020-02-17 21:50:45 -05:00
John Sully a6bc30fc09 Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: bc4b0ff8c18410ae1d1b029410580c96c430510f
2020-02-17 19:56:38 -05:00
John Sully dfd7e80228 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 82b957be47c828238554ba8b365e2d0a45994bc2
2020-02-17 19:56:07 -05:00
John Sully 8d720e220d Merge branch 'unstable' into redis_6_merge
Former-commit-id: 32f34f63fd
2020-02-17 19:55:29 -05:00
John Sully 1d368edc10 Add double unlock detection and improve fastlock_unlock assmebly
Former-commit-id: 98aefac09b
2020-02-17 19:54:05 -05:00
John Sully 950cda8ea5 Incorrect use of std::atomic
Former-commit-id: 5dc84850ad
2020-02-17 19:07:13 -05:00
John Sully 2c28a3f3d7 processEventsWhileBlocked not exception safe
Former-commit-id: 45b711f9d1
2020-02-17 19:04:11 -05:00
John Sully c810823abe processEventsWhileBlocked not exception safe
Former-commit-id: 1ef187533c
2020-02-17 19:03:49 -05:00
John Sully 4b12a63b3a Fix race condition with IStorage batches
Former-commit-id: a2eabd044c9048662a63ff0f980ed947dc145912
2020-02-17 19:00:31 -05:00
John Sully 0adc93ab41 processEventsWhileBlocked not exception safe
Former-commit-id: 432543956c74351a12af2cb258a7a0ba5daa9b27
2020-02-17 18:57:13 -05:00
John Sully 8bd2b39367 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: b16090958d392a6de908562dee65a02c851f07ae
2020-02-16 20:07:03 -05:00
John Sully bd5ffe7069 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 6a71de7835
2020-02-16 19:14:51 -05:00
John Sully d229b03b2c Support C++14 and remove dependency on future standard 2a
Former-commit-id: 18496b6285
2020-02-16 19:04:56 -05:00
John Sully b6db2d32ad Graceful shutdown of server threads when quit is requested
Former-commit-id: b9db899f6c
2020-02-16 18:53:46 -05:00
John Sully 6011a072d1 Virtual dtor for DB base class
Former-commit-id: 953b1cb3a2fec808751d2e7507efe8896f671921
2020-02-16 18:43:36 -05:00
John Sully dde7fc4c18 Fix memory leak in RDB load
Former-commit-id: 4e9d2f08b1
2020-02-16 18:42:14 -05:00
John Sully d3a69998e4 Fix memory leak in RDB load
Former-commit-id: 06ad1c15d7
2020-02-16 18:41:50 -05:00
John Sully 0337da40da Fix memory leak in RDB load
Former-commit-id: a424194f42e61a324489464a0fed14837b8191e4
2020-02-16 18:41:29 -05:00
John Sully ccb4ce65c8 Fix leak deserializing expire
Former-commit-id: 1a7e14d8ef96f7849ecdb120f3339b2423ca25d8
2020-02-16 18:40:00 -05:00
John Sully f76e237d24 Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: 770941923d183c0dfed8d5bf8f2299fc4fadf9c6
2020-02-16 18:38:15 -05:00
John Sully 74c7901a5e Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 8456e92d6e446f1cc20d9cea2328998da0a4d7d5
2020-02-16 18:28:45 -05:00
John Sully 04d174ba1a Merge branch 'unstable' into redis_6_merge
Former-commit-id: 30a603ce05
2020-02-16 18:18:24 -05:00
John Sully fd375eb95c Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 63ae679fe1
2020-02-16 18:12:11 -05:00
John Sully 8f6f496c7e Memory leak fix on config, and redisDb dtor
Former-commit-id: b92bbf4de8
2020-02-16 17:08:00 -05:00
John Sully b1ccb096a4 Add GC shutdown command
Former-commit-id: 28e8f68016b554f3d410502c2af1641368c2bb92
2020-02-16 16:49:04 -05:00
John Sully 3fad87ca13 Merge branch 'unstable' into keydbpro
Former-commit-id: f3457e2a9a8464bac656b57256316bbddb65d9e9
2020-02-16 04:04:34 -05:00
John Sully 41c75234bd Fix memory leak of ReplicaNestState on shutdown
Former-commit-id: 4781eda722
2020-02-16 03:43:29 -05:00
John Sully 00f80cce27 Fix leak when tombstone exists
Former-commit-id: 3d0ccdf6d2ddc523a3532c46cf905023d207b8cb
2020-02-16 03:36:47 -05:00
John Sully 4bf9beb484 aeDeleteEventLoop use after free and leak fixes
Former-commit-id: 2fd93c5789
2020-02-16 03:34:25 -05:00
John Sully 3b496ea282 aeDeleteEventLoop use after free and leak fixes
Former-commit-id: 77820e5d50e0426570285a2c740c47b05a7c6c2f
2020-02-16 03:33:45 -05:00
Khem Raj 0545a70d52 Mark extern definition of SDS_NOINIT in sds.h
This helps in avoiding multiple definition of this variable, its also
defined globally in sds.c

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-02-12 14:17:54 +01:00
lifubang 5b3a6b5e80 correct help info for --user and --pass
Signed-off-by: lifubang <lifubang@acmcoder.com>
2020-02-12 14:17:54 +01:00
Seunghoon Woo 9edd6808c8 [FIX] revisit CVE-2015-8080 vulnerability 2020-02-12 14:17:54 +01:00
Guy Benoish 05b2e8c5c8 Diskless-load emptyDb-related fixes
1. Call emptyDb even in case of diskless-load: We want modules
   to get the same FLUSHDB event as disk-based replication.
2. Do not fire any module events when flushing the backups array.
3. Delete redundant call to signalFlushedDb (Called from emptyDb).
2020-02-12 14:17:54 +01:00
lifubang af3ff9d733 fix ssl flag check for redis-cli
Signed-off-by: lifubang <lifubang@acmcoder.com>
2020-02-12 14:17:54 +01:00
Guy Benoish 98a59c540d Exclude "keymiss" notification from NOTIFY_ALL
Because "keymiss" is "special" compared to the rest of
the notifications (Trying not to break existing apps
using the 'A' format for notifications)

Also updated redis.conf and module.c docs
2020-02-12 14:17:54 +01:00
Oran Agra a1a25bc7f1 update RM_SignalModifiedKey doc comment 2020-02-12 14:17:40 +01:00
Oran Agra 1f9520a75d Add handling of short read of module id in rdb 2020-02-12 14:17:40 +01:00
Yossi Gottlieb e7e595192a TLS: Update documentation. 2020-02-12 14:17:40 +01:00
Oran Agra ca22e14d8a A few non-data commands that should be allowed while loading or stale
SELECT, and HELLO are commands that may be executed by the client
as soon as it connects, there's no reason to block them, preventing the
client from doing the rest of his sequence (which might just be INFO or
CONFIG, etc).

MONITOR, DEBUG, SLOWLOG, TIME, LASTSAVE are all non-data accessing
commands, which there's no reason to block.
2020-02-12 14:17:40 +01:00
Oran Agra da8ec22fc6 Memory leak when bind config is provided twice 2020-02-12 14:17:40 +01:00
Oran Agra 600d02e1a7 fix maxmemory config warning
the warning condition was if usage > limit (saying it'll cause eviction
or oom), but in fact the eviction and oom depends on used minus slave
buffers.

other than fixing the condition, i add info about the current usage and
limit, which may be useful when looking at the log.
2020-02-12 14:17:40 +01:00
Oran Agra a98e5a1fc3 Fix client flags to be int64 in module.c
currently there's no bug since the flags these functions handle are
always lower than 32bit, but still better fix the type to prevent future
bugs.
2020-02-12 14:17:40 +01:00
Oran Agra e92983ed3f moduleRDBLoadError, add key name, and use panic rather than exit
using panic rather than exit means you get s stack trace of the code
path that experianced the error, and possibly other info.
2020-02-12 14:17:40 +01:00
Oran Agra a8e2bbe8f6 stopAppendOnly resets aof_rewrite_scheduled
althouh in theory, users can do BGREWRITEAOF even if aof is disabled, i
suppose it is more common that the scheduled flag is set by either
startAppendOnly, of a failed initial AOFRW fork (AOF_WAIT_REWRITE)
2020-02-12 14:15:56 +01:00
Oran Agra 2af4039b3e reduce repeated calls to use_diskless_load
this function possibly iterates on the module list
2020-02-12 14:15:56 +01:00
Oran Agra 23cbfea39b add SAVE subcommand to ACL HELP and top comment 2020-02-12 14:15:56 +01:00
Oran Agra 5e3b4c978b freeClientAsync don't lock mutex if there's just one thread 2020-02-12 14:15:56 +01:00
Oran Agra 3988bfff50 DEBUG HELP - add PROTOCOL 2020-02-12 14:15:56 +01:00
Oran Agra ad1c21283e move restartAOFAfterSYNC from replicaofCommand to replicationUnsetMaster
replicationUnsetMaster can be called from other places, not just
replicaofCOmmand, and all of these need to restart AOF
2020-02-12 14:15:56 +01:00
Guy Benoish 084dc68128 Some refactroing using getClientType instead of CLIENT_SLAVE 2020-02-12 14:15:56 +01:00
Guy Benoish f4c30fd74b Fix small bugs related to replica and monitor ambiguity
1. server.repl_no_slaves_since can be set when a MONITOR client disconnects
2. c->repl_ack_time can be set by a newline from a MONITOR client
3. Improved comments
2020-02-12 14:15:56 +01:00
Yossi Gottlieb 351529cc39 TLS: Some redis.conf clarifications. 2020-02-12 14:15:56 +01:00
Oran Agra 601d423498 config.c verbose error replies for CONFIG SET, like config file parsing
We noticed that the error replies for the generic mechanism for enums
are very verbose for config file parsing, but not for config set
command.

instead of replicating this code, i did a small refactoring to share
code between CONFIG SET and config file parsing.

and also renamed the enum group functions to be consistent with the
naming of other types.
2020-02-12 14:15:56 +01:00
Oran Agra 138252dc56 memoryGetKeys helper function so that ACL can limit access to keys for MEMORY command 2020-02-12 14:15:56 +01:00
antirez 491949ee5b ACL LOG: make max log entries configurable. 2020-02-12 14:15:35 +01:00
antirez c30fe3a93f ACL LOG: test for AUTH reason. 2020-02-12 14:15:35 +01:00
antirez c0de265bfa ACL LOG: log failed auth attempts. 2020-02-12 14:15:35 +01:00
antirez c60351e489 ACL LOG: implement a few basic tests. 2020-02-12 14:15:35 +01:00
antirez 74c4d2f158 ACL LOG: also log ACL errors in the scripting/MULTI ctx. 2020-02-12 14:15:35 +01:00
antirez 3853c71288 ACL LOG: implement LOG RESET. 2020-02-12 14:15:35 +01:00
antirez 7b53636462 ACL LOG: group similar entries in a given time delta. 2020-02-12 14:15:35 +01:00
antirez 9f5b64c4a6 ACL LOG: actually emit entries. 2020-02-12 14:15:35 +01:00
antirez e6eafd3e1f ACL LOG: implement ACL LOG subcommadn skeleton. 2020-02-12 14:15:35 +01:00
antirez 2d06604451 ACL LOG: data structures and initial functions. 2020-02-12 14:15:35 +01:00
John Sully e216a1f386 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 4bd4159e2d8a7cdd0af9719776dca3e7d161d166
2020-02-11 03:48:24 -05:00
John Sully 968e668245 Merge branch 'unstable' into redis_6_merge
Former-commit-id: 329519d4aa
2020-02-11 03:48:08 -05:00
John Sully 4748094356 Fix race condition in allocating connections to threads
Former-commit-id: 52434a583a
2020-02-11 03:44:28 -05:00
John Sully 23e7de94a8 Merge branch 'redis_6_merge' into keydbpro
Former-commit-id: 4091800e499cade8bc188c9e6f52f535c500f282
2020-02-11 02:54:24 -05:00
John Sully fbaa46505c Merge branch 'unstable' into redis_6_merge
Former-commit-id: 18a5f46b61
2020-02-11 02:39:08 -05:00
John Sully d4c1e98124 Implement an error handler so bug #125 can't happen
Former-commit-id: 16a019dba0
2020-02-11 01:41:00 -05:00
John Sully fef9925b7f Fix higher latency at low load by grouping clients to threads. This fixes slow perf in cluster benchmarks mentioned in issue #102
Former-commit-id: 1a4c3224c9
2020-02-11 01:00:21 -05:00
John Sully e4d74b993f Fix cases where duplicate RREPLAY is applied
Former-commit-id: c3317686f8
2020-02-11 00:59:07 -05:00
John Sully 30ece138d5 Fix issue #119
Former-commit-id: 4622472123
2020-02-10 19:52:57 -05:00
John Sully 68235881e9 Fix memory leak in cron
Former-commit-id: f1748f8c76
2020-02-10 18:26:04 -05:00
John Sully d346ad7734 Add missing test file
Former-commit-id: 0c101dccc8
2020-02-10 18:15:29 -05:00
John Sully eac3cffe41 CLANG build fix
Former-commit-id: dc78bf1ccb
2020-02-10 00:29:26 -05:00
John Sully 25ef65463e Ensure multi-master works for ring topologies
Former-commit-id: a7cc3aac28
2020-02-10 00:25:03 -05:00
John Sully d292477625 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 339631530a
2020-02-09 02:25:20 -05:00
John Sully 6c2cef7687 Addmissing test file
Former-commit-id: fb2bdf7d05
2020-02-08 16:49:41 -05:00
John Sully 3aa271fe38 Merge branch 'unstable' into keydbpro
Former-commit-id: fec8209c1996112976d927d65dbc2b4492131681
2020-02-07 16:46:13 -05:00
John Sully bf83742b4f merge 5.0 unstable
Former-commit-id: c45f1328ac
2020-02-07 16:45:59 -05:00
John Sully eabc436814 Fix issue #137 and #132
Former-commit-id: 050d58007f
2020-02-06 23:31:31 -05:00
John Sully 8800a516d1 Add test to detect issue #137 and #132
Former-commit-id: 49d86746ed
2020-02-06 23:31:12 -05:00
Guy Benoish 2ad427f862 ld2string should fail if string contains \0 in the middle
This bug affected RM_StringToLongDouble and HINCRBYFLOAT.
I added tests for both cases.

Main changes:
1. Fixed string2ld to fail if string contains \0 in the middle
2. Use string2ld in getLongDoubleFromObject - No point of
   having duplicated code here

The two changes above broke RM_SaveLongDouble/RM_LoadLongDouble
because the long double string was saved with length+1 (An innocent
mistake, but it's actually a bug - The length passed to
RM_SaveLongDouble should not include the last \0).
2020-02-04 10:23:48 +01:00
Leo Murillo 5b2c6c5efa Set ZSKIPLIST_MAXLEVEL to optimal value given 2^64 elements and p=0.25 2020-02-04 10:23:48 +01:00
antirez 229229eb55 Add more info in the unblockClientFromModule() function. 2020-02-04 10:23:48 +01:00
WuYunlong 294b194ad4 Fix lua related memory leak. 2020-02-04 10:23:48 +01:00
Guy Benoish d9f508d527 Modules: Fix blocked-client-related memory leak
If a blocked module client times-out (or disconnects, unblocked
by CLIENT command, etc.) we need to call moduleUnblockClient
in order to free memory allocated by the module sub-system
and blocked-client private data

Other changes:
Made blockedonkeys.tcl tests a bit more aggressive in order
to smoke-out potential memory leaks
2020-02-04 10:23:48 +01:00
WuYunlong 7d63a7d128 Add tcl regression test in scripting.tcl to reproduce memory leak. 2020-02-04 10:23:48 +01:00
Yossi Gottlieb a27a4b82f4 TLS: Fix missing initialization in redis-cli. 2020-02-04 10:23:48 +01:00
Oran Agra 2ffb9a3682 fix uninitialized info_cb var in module.c 2020-02-04 10:23:48 +01:00
John Sully 6bb1429a46 module fixes
Former-commit-id: ef4e11ecb8
2020-02-04 01:22:25 -05:00
John Sully 41f26be34a rename to pro binary
Former-commit-id: a8854bfd83de72d6aa418ee6d9b44fae1f622787
2020-02-04 00:30:13 -05:00
John Sully 5a1d83abec Merge branch 'keydbpro' into PRO_RELEASE_6
Former-commit-id: 055eaa99ab918609f4ac6b533da3067e5e32a170
2020-02-03 20:16:20 -05:00
John Sully 8001e2a6a5 Ensure create-cluster launches pro
Former-commit-id: 8b3773805d2208070e807ede219821c524495c34
2020-02-03 20:15:59 -05:00
John Sully 42b3e32c8d Bump version
Former-commit-id: ac84153f61b213d42ad503ac38948f9740a5f923
2020-02-03 20:01:53 -05:00
John Sully 78810588e1 Merge branch 'unstable' into keydbpro
Former-commit-id: 0db79c793e30ab268cb0f771928468e477e3b8da
2020-02-03 20:00:16 -05:00
John Sully 771787273a Fix cluster test failures from Redis 6 merge
Former-commit-id: fd702e43f1
2020-02-03 20:00:09 -05:00
John Sully 590b3de028 Build portable rocksdb binaries
Former-commit-id: e94db969f8ac584b75b2ad015b65c1d0d73d0776
2020-02-03 17:33:15 -05:00
John Sully 316ac20087 Fix failure to save RDB on shutdown
Former-commit-id: 1a8331c88a17deaa5faf34c7ea65957c57530546
2020-02-03 16:00:01 -05:00
John Sully 3610783851 Optimize bgsave snapshotting
Former-commit-id: 15b4bf003537fe6fd926146f46d38203683846be
2020-02-02 23:42:44 -05:00
John Sully 6ead122691 3 fixes, 0 array access on boot, getAsync is useless on single theaded, and don't print COW info for BG thread work since it will be inaccurate
Former-commit-id: 09362ff44afed8525816437aead84f215eb59c36
2020-02-02 23:30:42 -05:00
John Sully 88a148d86e RDB thread cleanup fixes
Former-commit-id: 3e30cf6de930c40c3a1c63a761b2018836d4ae52
2020-02-02 23:29:20 -05:00
John Sully 424981309d Handle case where src dict is larger in dictMerge
Former-commit-id: c750fdb381f5dd3e92d251a82bd86533eb2cadf5
2020-02-02 23:27:25 -05:00
John Sully 78da9b3af1 endSnapshotAsync implementation (fails tests w/ multithreading)
Former-commit-id: b401e9fcae40cf1d4e4c1584f57e760d9adf36a9
2020-02-01 22:28:24 -05:00
John Sully cb9c7d3a80 Merge branch 'unstable' into keydbpro
Former-commit-id: 53b36801cede2dbebbf33ec665af69f810b438d5
2020-02-01 21:52:26 -05:00
John Sully ae0a3e9f65 addRef memory model too restrictive
Former-commit-id: 249e0fdd36
2020-02-01 21:52:17 -05:00
John Sully 40fc4eefbb use dictMerge() in endSnapshot for speed and cleaner code
Former-commit-id: ed8e10234e4499506f2557b0858dba86c30c9dc0
2020-02-01 21:08:26 -05:00
John Sully 2b86140abb Allow rehashing if RDB thread is active, it doesn't suffer from COW madness
Former-commit-id: 2f1f2eaa9d160701f45eed52fc7903fcccd7656b
2020-02-01 20:28:17 -05:00
John Sully 82cb879485 Fix spurious error messages trying to join the RDB save thread
Former-commit-id: 775f3477655207a4df2b0b3609f3ee83d41098af
2020-02-01 20:26:09 -05:00
John Sully d715bc15e1 Add new faster dictionary merging for use by snapshotting code
Former-commit-id: b6f120b3d401c92ef5cf1cc6f5e77da139e33a97
2020-02-01 20:17:40 -05:00
John Sully 1e50be75f9 Increase trial timeout to 2 hours
Former-commit-id: 2614f902e4292c84b9bc473c8d3a5bba9dfdbc2d
2020-01-31 23:35:13 -05:00
John Sully e3e64034e2 snapshot optimizations
Former-commit-id: 642f67376a480497554f2891ebfbe7639583c6f1
2020-01-31 17:32:48 -05:00
John Sully 9adc302858 Initialize the storage provider after daemonize
Former-commit-id: 5910af623b024b087c69b17ec32ce351fc4d00c2
2020-01-30 22:26:44 -05:00
John Sully 5321e425a0 build break non-TLS
Former-commit-id: 72e455b94739625a217a664b61f4a4b7ae98f7f1
2020-01-30 21:19:08 -05:00
John Sully 5f061c9178 Merge branch 'unstable' into keydbpro
Former-commit-id: aca1a6605685811833729d746df85781177d5a78
2020-01-30 21:15:42 -05:00
John Sully 8ea5d731ad RDB memory leaks
Former-commit-id: 6208118b13
2020-01-30 17:57:10 -05:00
John Sully 24c9edd93b replication memory leaks
Former-commit-id: 73020b6a93
2020-01-30 17:56:24 -05:00
John Sully 1cfc7071f5 Fix memory leak in cron
Former-commit-id: a9667e84ad
2020-01-30 17:55:48 -05:00
John Sully 8f9fc831a6 Merge branch 'redis_merge' into unstable
Former-commit-id: ab1524ff1a
2020-01-30 16:05:40 -05:00
John Sully b5911e82cd Merge branch 'redis_merge' into keydb_pro_merge
Former-commit-id: 2a760ac3b2cf12e45a9db9d0c2efe6efc4dc2aed
2020-01-29 21:30:20 -05:00
John Sully f5b08185b1 TLS Thread Safety fixes
Former-commit-id: e98a5fc108c5448307a8cc38182c79263f01102a
2020-01-29 21:21:47 -05:00
John Sully 978e1fdda5 fix leak in cron
Former-commit-id: c1f4e344bdaf21bc74fae6e1b0cb7fc1ce687e62
2020-01-29 19:03:18 -05:00
John Sully 1b44a0d391 Merge branch 'redis_merge' into keydb_pro_merge
Former-commit-id: e4f455a991b468a7abea169e5672d3039a8645f9
2020-01-29 15:57:43 -05:00
John Sully 8090e2866f TLS compile fixes
Former-commit-id: 0516809832cf22557592d15f39d64162fcd5083d
2020-01-29 15:57:25 -05:00
John Sully 40a893026a Merge branch 'redis_merge' into keydb_pro_merge
Former-commit-id: e10d9de29059f42193560712991df0950eeef679
2020-01-29 13:43:45 -05:00
John Sully 2e84764f1b Fix active rep not merging on sync and add tests
Former-commit-id: fcb77d0431b195553eb1cd563286e5441f0c94cd
2020-01-29 13:26:04 -05:00
John Sully 3186cb683f Merge KeyDB 6
Former-commit-id: 9129b98c12b0da856bbda3eb68b4ddc7530693c9
2020-01-29 12:55:23 -05:00
John Sully dc4d3a607f Yet more multithreading fixes
Former-commit-id: 9f23062ebdf389f0c95e1f4ab22c36ca96060e1f
2020-01-28 21:42:55 -05:00
John Sully 363212f39b failure to post a function is not fatal unless we wrote part of a command (should be impossible)
Former-commit-id: e1c642a033ab0157a66571189e81817cb84fd421
2020-01-28 21:41:56 -05:00
John Sully ae344960f1 CRON jobs were running half as often as required
Former-commit-id: 1069d0b4bf
2020-01-28 21:40:40 -05:00
John Sully b0c68c94bb CRON jobs were running half as often as required
Former-commit-id: a8f758144b8d79f9816ede3ae86c5c2d5d7d10dd
2020-01-28 21:39:56 -05:00
John Sully 854859dc97 Support C++14 and remove dependency on future standard 2a
Former-commit-id: 7ba1920069821bf369cae40926e0ac82923ad784
2020-01-28 19:06:33 -05:00
John Sully 1adc5e9832 More threading fixes from merge
Former-commit-id: 4a980f4ddb
2020-01-28 17:54:00 -05:00
John Sully d9c070408b reenable multithreading after merge
Former-commit-id: 9fbb9a551e
2020-01-27 19:59:04 -05:00
John Sully 527aeda2db cron reliability
Former-commit-id: c24a7c03c2
2020-01-27 18:31:02 -05:00
John Sully d57e98ac5e fix expire test failures during overwrite
Former-commit-id: 5a8280d577
2020-01-27 18:26:23 -05:00
John Sully 14188ef92d Fix most tests (still some failures)
Former-commit-id: da83e84125
2020-01-27 18:16:19 -05:00
John Sully 6193e9ad4f Merge remote-tracking branch 'redis/6.0' into redis_merge
Former-commit-id: ef9a3cadcf
2020-01-27 02:55:48 -05:00
John Sully 3be0eac7b6 Missing cron files
Former-commit-id: c983d57f73
2020-01-21 19:51:16 -05:00
John Sully 1116b63a0e Initial implementation of the CRON command
Former-commit-id: 3204a39ada
2020-01-21 19:50:28 -05:00
John Sully 5f3fde673b Bump version
Former-commit-id: f4319c1280
2020-01-20 19:20:50 -05:00
antirez 9a39a227ff Document I/O threads in redis.conf. 2020-01-17 10:47:38 +01:00
antirez dff5370c8b Simplify #6379 changes. 2020-01-17 10:47:38 +01:00
antirez 87d059a745 Jump to right label on AOF parsing error.
Related to #6054.
2020-01-17 10:47:38 +01:00
antirez 4048cf6125 Change error message for #6775. 2020-01-17 10:47:38 +01:00
antirez 598c324bc1 Setting N I/O threads should mean N-1 additional + 1 main thread. 2020-01-17 10:47:38 +01:00
WuYunlong e67a3a377f Free allocated sds in pfdebugCommand() to avoid memory leak. 2020-01-17 10:47:38 +01:00
antirez 0b02b27705 Port PR #6110 to new connection object code. 2020-01-17 10:47:38 +01:00
Vasyl Melnychuk 037755edd4 Make error when submitting command in incorrect context more explicit
So error message `ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context` will become
`ERR 'get' command submitted, but only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context`
2020-01-17 10:47:38 +01:00
WuYunlong 1588f30ae2 Fix potential memory leak of clusterLoadConfig(). 2020-01-17 10:47:38 +01:00
antirez a6eb3f8bfb A few comments about main thread serving I/O as well.
Related to #6110.
2020-01-17 10:47:38 +01:00
WuYunlong 2a3a035b64 Fix potential memory leak of rioWriteBulkStreamID(). 2020-01-17 10:47:38 +01:00
zhaozhao.zz 1f76ff2fb9 Threaded IO: use main thread to handle read work 2020-01-17 10:47:38 +01:00
zhaozhao.zz 0a3410db70 Threaded IO: use main thread to handle write work 2020-01-17 10:47:38 +01:00
John Sully 9a16678a7d Fix build break for X64
Former-commit-id: 76590fdce3ccf7bf3124832f6034c31caf7a8269
2020-01-12 01:28:30 -05:00
John Sully 7f74e0409f Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: 4f39ca139f15a5f585f829937a46a56f20644db0
2020-01-12 01:27:22 -05:00
John Sully 49c2b7b77f Fix snapshot consolidation bugs and reduce log noise
Former-commit-id: 7f3cb2981529277d3f02dceb2f60e7aa8385847d
2020-01-12 01:22:44 -05:00
John Sully 46d5a1977e remove debug printfs
Former-commit-id: 3dbd455321e4a2ee47a24662e164eac0e5614965
2020-01-12 01:20:52 -05:00
John Sully f40359cde6 Merge branch 'moar_perf' into keydbpro_moarperf
Former-commit-id: d0990a465c3c5c29b71f239d84a875af40699281
2020-01-11 22:06:20 -05:00
John Sully 793f0bf274 Avoid locking as late as possible
Former-commit-id: acc894fe41
2020-01-11 19:28:13 -05:00
John Sully 9af43f254d Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 762396d997
2020-01-11 16:35:06 -05:00
John Sully 6e096ca33e Avoid crash due to excessive posted functions for AOF rewrite
Former-commit-id: c575e7df94
2020-01-11 16:34:30 -05:00
John Sully b9b8272724 Avoid crash due to excessive posted functions for AOF rewrite
Former-commit-id: aa6409f2e8
2020-01-11 16:34:09 -05:00
John Sully 18df86fcde Merge branch 'unstable' into RELEASE_5
Former-commit-id: e603e57588
2020-01-10 17:46:23 -05:00
John Sully 18cc4b3ebe Ignore other flags after pro is enabled since we won't understand them
Former-commit-id: 049b48ef79
2020-01-10 17:46:02 -05:00
John Sully 900e596440 Update README.md
Former-commit-id: 0ba0a6ab0a
2020-01-10 14:21:11 -05:00
John Sully 09ff507ee9 Update graphs
Former-commit-id: 7475ea1b0b
2020-01-10 14:19:44 -05:00
ShooterIT 4e0c2ff1d8 Rename rdb asynchronously 2020-01-10 13:16:25 +01:00
Leo Murillo b6caf319e5 Fix bug on KEYS command where pattern starts with * followed by \x00 (null char). 2020-01-10 13:16:25 +01:00
Jamie Scott 0b36c7eb26 Update to directive in redis.conf (missing s)
The directive tls-prefer-server-cipher is actually tls-prefer-server-ciphers in config.c. This results in a failed directive call shown below. This pull request adds the "s" in ciphers so that the directive is able to be properly called in config.c

ubuntu@ip-172-31-16-31:~/redis$ src/redis-server ./redis.conf 

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 200
>>> 'tls-prefer-server-cipher yes'
Bad directive or wrong number of arguments
2020-01-10 13:16:25 +01:00
antirez a4f462bebb Free fakeclient argv on AOF error.
We exit later, so no bug fixed, but it is more correct.

See #6054, thanks to @ShooterIT for finding the issue.
2020-01-10 13:16:25 +01:00
antirez d08b8b92fc Git ignore: ignore more files. 2020-01-10 13:16:14 +01:00
Guy Benoish 3913ffd5bc Blocking XREAD[GROUP] should always reply with valid data (or timeout)
This commit solves the following bug:
127.0.0.1:6379> XGROUP CREATE x grp $ MKSTREAM
OK
127.0.0.1:6379> XADD x 666 f v
"666-0"
127.0.0.1:6379> XREADGROUP GROUP grp Alice BLOCK 0 STREAMS x >
1) 1) "x"
   2) 1) 1) "666-0"
         2) 1) "f"
            2) "v"
127.0.0.1:6379> XADD x 667 f v
"667-0"
127.0.0.1:6379> XDEL x 667
(integer) 1
127.0.0.1:6379> XREADGROUP GROUP grp Alice BLOCK 0 STREAMS x >
1) 1) "x"
   2) (empty array)

The root cause is that we use s->last_id in streamCompareID
while we should use the last *valid* ID
2020-01-10 13:16:14 +01:00
John Sully 2539a8a3ce Add support for incremental build with header files 2020-01-10 13:16:14 +01:00
WuYunlong 7030e66807 Fix petential cluster link error.
Funcion adjustOpenFilesLimit() has an implicit parameter, which is server.maxclients.
This function aims to ajust maximum file descriptor number according to server.maxclients
by best effort, which is "bestlimit" could be lower than "maxfiles" but greater than "oldlimit".
When we try to increase "maxclients" using CONFIG SET command, we could increase maximum
file descriptor number to a bigger value without calling aeResizeSetSize the same time.
When later more and more clients connect to server, the allocated fd could be bigger and bigger,
and eventually exceeds events size of aeEventLoop.events. When new nodes joins the cluster,
new link is created, together with new fd, but when calling aeCreateFileEvent, we did not
check the return value. In this case, we have a non-null "link" but the associated fd is not
registered.

So when we dynamically set "maxclients" we could reach an inconsistency between maximum file
descriptor number of the process and server.maxclients. And later could cause cluster link and link
fd inconsistency.

While setting "maxclients" dynamically, we consider it as failed when resulting "maxclients" is not
the same as expected. We try to restore back the maximum file descriptor number when we failed to set
"maxclients" to the specified value, so that server.maxclients could act as a guard as before.
2020-01-10 13:16:14 +01:00
Yossi Gottlieb 3f8a690161 Add REDISMODULE_CTX_FLAGS_MULTI_DIRTY. 2020-01-10 13:16:03 +01:00
hwware 86fd8f0e3f typo fix in acl.c 2020-01-10 13:16:03 +01:00
Itamar Haber d6a6b6f40c Adjusts 'io_threads_num' max to 128
Instead of 512, use the defined max from networking.c
2020-01-10 13:16:03 +01:00
antirez 4a63d5d881 XCLAIM: Create the consumer only on successful claims.
Fixes #6744.
2020-01-08 12:31:39 +01:00
yz1509 28622cc532 avoid sentinel changes promoted_slave to be its own replica. 2020-01-08 12:31:25 +01:00
John Sully c6cda62f04 Merge branch 'unstable' into RELEASE_5
Former-commit-id: d0654af74f
2020-01-06 14:24:49 -05:00
John Sully 174a8b886d pro launch should respect KEYDB_PRO_DIRECTORY
Former-commit-id: d5f8df5997
2020-01-06 14:24:37 -05:00
John Sully 7f6389a9d0 Add license key lib for aarch64
Former-commit-id: 8b804d91e3dc810b6d8cc585dd3747ba962ead18
2020-01-06 19:16:48 +00:00
John Sully 2d5197d30e Bump version
Former-commit-id: 39acb312ef
2020-01-06 12:07:57 -05:00
John Sully 0bc26f88bb Merge branch 'unstable' into RELEASE_5
Former-commit-id: b643c38204
2020-01-06 12:07:11 -05:00
John Sully 4a6748d29f Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: dd70f5efd7
2020-01-06 12:04:00 -05:00
John Sully 64c07168d7 Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: 3d63d38aae762c60a22154109827ebfd46aae2a5
2020-01-05 20:19:55 -05:00
John Sully 5907dccdae Add new flags to example configuration file
Former-commit-id: bb38628f0e
2020-01-05 20:19:28 -05:00
John Sully 78924a295e Enforce seperate license keys for connected replicas
Former-commit-id: bc005cb50b1010a2bc9170e261cd93dba849c35f
2020-01-04 17:15:06 -05:00
John Sully 2109d8972e Additional flash tests
Former-commit-id: 3f9b1a35821cb3a3bf82aabb180c13a9eddf4e93
2020-01-03 17:11:23 -05:00
John Sully efdf09be36 Fix crash with subkey expire
Former-commit-id: 8e1d416714484ff6ff4242c5d9a24b1458bbfb7b
2020-01-03 17:06:07 -05:00
John Sully 4301cfb8e9 Merge branch 'unstable' into keydbpro
Former-commit-id: 76ddbed0708277443660ffab2a2289e120fe87cd
2020-01-03 16:53:40 -05:00
John Sully e49ec97f98 subkey expire testes
Former-commit-id: 0cf3af6857
2020-01-03 16:50:13 -05:00
John Sully ce0fde973a Add support for storing expirations in FLASH
Former-commit-id: 1dca07bd564042fce1b01d275641f35b918ae557
2020-01-03 15:53:36 -05:00
John Sully 6ab3e82e45 Drop severity of master disconnect log when multimaster is enabled
Former-commit-id: edb993d52b
2020-01-02 15:36:02 -05:00
John Sully 85c8fc72b7 Fix issue where expire is lost when performing a defrag
Former-commit-id: aea333bb78
2020-01-01 20:41:17 -05:00
John Sully 2e50d383a6 C++ wrapper classes for SDS
Former-commit-id: 45817db8c3
2020-01-01 19:13:48 -05:00
antirez d22d40a2eb Fix active expire division by zero.
Likely fix #6723.

This is what happens AFAIK: we enter the main loop where we expire stuff
until a given percentage of keys is still found to be logically expired.
There are however other potential exit conditions.

However the "sampled" variable is not always incremented inside the
loop, because we may found no valid slot as we scan the hash table, but
just NULLs ad dict entries. So when the do/while loop condition is
triggered at the end, we do (expired*100/sampled), dividing by zero if
we sampled 0 keys.
2020-01-01 18:10:39 +01:00
John Sully ad0cb8da40 Fix issue #130 due to fastlock timeout reduction
Former-commit-id: dbef17c2e1
2020-01-01 11:52:00 -05:00
antirez c2461ba531 Fix duplicated CLIENT SETNAME reply.
Happened when we set the name to "" to cancel the name.
Was introduced during the RESP3 refactoring.

See #6036.
2019-12-29 15:46:31 +01:00
Guy Benoish 444dd1075c Stream: Handle streamID-related edge cases
This commit solves several edge cases that are related to
exhausting the streamID limits: We should correctly calculate
the succeeding streamID instead of blindly incrementing 'seq'
This affects both XREAD and XADD.

Other (unrelated) changes:
Reply with a better error message when trying to add an entry
to a stream that has exhausted last_id
2019-12-29 15:46:31 +01:00
Oran Agra f866b31a74 config.c adjust config limits and mutable
- make lua-replicate-commands mutable (it never was, but i don't see why)
- make tcp-backlog immutable (fix a recent refactory mistake)
- increase the max limit of a few configs to match what they were before
the recent refactory
2019-12-29 15:46:31 +01:00
antirez 1b56a873d5 Inline protocol: handle empty strings well.
This bug is from the first version of Redis. Probably the problem here
is that before we used an SDS split function that created empty strings
for additional spaces, like in "SET    foo          bar".
AFAIK later we replaced it with the curretn sdssplitarg() API that has
no such a problem. As a result, we introduced a bug, where it is no
longer possible to do something like:

    SET foo ""

Using the inline protocol. Now it is fixed.
2019-12-29 15:46:31 +01:00
antirez a640d1bb5c Fix ip and missing mode in RM_GetClusterNodeInfo(). 2019-12-29 15:46:31 +01:00
John Sully bbbe030e78 Merge branch 'unstable' into keydbpro
Former-commit-id: 7ddcbb8ec0c842bd4a79b6e14ebd33616174e793
2019-12-27 18:17:36 -05:00
John Sully 55cddbe82f Fix some static analysis warnings
Former-commit-id: 42a8f22c21
2019-12-27 18:17:22 -05:00
John Sully 55361c65d8 Merge branch 'keydbpro' of https://github.com/JohnSully/KeyDB-Pro into keydbpro
Former-commit-id: b52725163ec6ea128102880be33c43437693cc9e
2019-12-27 17:46:51 -05:00
John Sully df3b99bf62 Ignore dependency files
Former-commit-id: f18d973adcf38483400edac85e9258c37aa4e8e5
2019-12-27 17:46:16 -05:00
John Sully 8f20fc7f33 Ignore dependency files
Former-commit-id: 6e06e0dfc7
2019-12-27 17:45:56 -05:00
John Sully 0fd9a4c67a Merge keydb community
Former-commit-id: b9dcd0997c3dfd3cd2a5908ba540bc4d389104a0
2019-12-27 17:44:48 -05:00
John Sully 082e493d32 Make incremental building work with header files
Former-commit-id: bf500ab44b
2019-12-27 17:34:41 -05:00
John Sully bb6aa59883 recommended rocksdb tuning
Former-commit-id: 2a634365f901968f9758d2d362f211b8e0fddc2a
2019-12-24 02:22:47 -05:00
John Sully 098684bf8e Track key count accurately before we've committed to the database. Also use this to optimize DB lookups when all keys are in memory
Former-commit-id: 78c07f0276109a085761b7044d4edc63af26d3da
2019-12-24 00:03:38 -05:00
John Sully 7da74195a8 Perf remove extra lookup in rocksdb
Former-commit-id: 8074472c7a25572a53f1166911920c2cb168c141
2019-12-23 23:32:04 -05:00
John Sully cded9874a0 More testing
Former-commit-id: 564d94f0653315ce05495a8d83ff8577a365c11b
2019-12-23 22:14:43 -05:00
John Sully 054bbe9baa Fix issue where database size is off when setting key with expire
Former-commit-id: 7796918bfb4a98bc056b3b8f4065f1416da8d89a
2019-12-23 22:07:33 -05:00
John Sully ef62b9b14c Add missing files
Former-commit-id: 4eadf8f0923ee70ffa3af329a4d636d508bfad8d
2019-12-23 19:07:53 -05:00
John Sully 4fd552d8b6 Add more test code, and fix bugs uncovered
Former-commit-id: 5362fa4b62f89cbc1e92e01c73a45c4e3718708b
2019-12-23 17:17:41 -05:00
John Sully bd4d372d45 Key count is innacurate after overwrite
Former-commit-id: 180c5a8e401415cede36548ab8d01f3e4ff8fb7f
2019-12-22 19:41:36 -05:00
John Sully 59f7bd49c9 Add additional tests
Former-commit-id: e7d2c78e776b8262fd54caeb7b6bd210182e9bdb
2019-12-22 19:16:30 -05:00
John Sully ca3c4474c2 Fix FLASH eviction issue, the algo relies on correct key count
Former-commit-id: dc260a7f44fe197b9b0022d044d559be88bf91be
2019-12-22 18:38:10 -05:00
John Sully 1e49dfe8e7 Optimization fails because dbAdd() will ensure the key
Former-commit-id: 1448b555c49fb5ba4a573a97681f7843ba02141f
2019-12-22 17:49:54 -05:00
John Sully 8ef2ec84de Merge remote-tracking branch 'nonfree/tests' into keydbpro
Former-commit-id: 180b059c05290aa403197bca819ec092c5ab326d
2019-12-22 17:31:05 -05:00
John Sully 7c8dda47cb Fix issue where DELETE always returns 1 when using FLASH
Former-commit-id: 0574db59fdc740255388ae77d2ece8622898bb49
2019-12-22 17:30:15 -05:00
John Sully e530793e82 Multimaster requires Active Replication
Former-commit-id: 4d4eca5433
2019-12-21 18:24:02 -05:00
Petr Vaněk 8146f24391 Rename redis.conf to keydb.conf
Former-commit-id: 4b01ad1e30
2019-12-21 15:00:24 -05:00
Petr Vaněk 8c7a04d747 Rename default pid file
Former-commit-id: 3b60929bdc
2019-12-21 15:00:24 -05:00
John Sully afce86838e Only override maxmemory settings if everything is default
Former-commit-id: 9fb240d49c61f5a69124a17cfc769095cadd3d98
2019-12-20 18:19:24 -05:00
John Sully 448b1093cd Evicted flash no longer keeps the key around
Former-commit-id: 908b303d1a8dd032c092f0bc035361a09c0291a5
2019-12-20 17:45:07 -05:00
John Sully 439362992f FLASH storage no longer keeps evicted keys in memory
Former-commit-id: 65c2b47c895d57231bbd3f451ecf1f6d9871f5f7
2019-12-19 17:30:31 -05:00
John Sully a0a33f7607 tests should use the new binary name
Former-commit-id: b4ee3c4ea57041d7c87ec228994ff5397bb6139f
2019-12-19 17:13:51 -05:00
John Sully 9f37260413 Fix crash when using rocksdb and jemalloc but scope it to just jemalloc
Former-commit-id: 6fa0cfd35fd1158f190db27bfb734ea2f763cb20
2019-12-19 15:44:09 -05:00
antirez 2df099e36b Redis 6.0 RC1. 2019-12-19 17:27:29 +01:00
John Sully b24479051d add missing file
Former-commit-id: 24e85bc84f58bbfbef973eab64017a08e3f34d7d
2019-12-18 13:38:59 -05:00
benschermel 4129ed553c adding flash test
Former-commit-id: 879b17c053695ee09562e2ec320e269141e31fdb
2019-12-18 00:47:08 -05:00
benschermel 27b8e8cdd8 adding flash test
Former-commit-id: 8c0f0bd1b5c83027e64765f9942f284bdb8ebcb4
2019-12-18 00:24:07 -05:00
John Sully 9f5d7d44c7 Implement subkey expires for sorted sets
Former-commit-id: a45d141597
2019-12-18 00:10:05 -05:00
John Sully a9967659cd Implement subkey expire for hashes
Former-commit-id: 8cbe254491
2019-12-18 00:04:48 -05:00
John Sully 643a0e730f Launch the pro binary with --enable-pro
Former-commit-id: ab365ce3da
2019-12-17 23:52:19 -05:00
John Sully d64b9c6bc3 rename binary to keydb-pro-server
Former-commit-id: 717dd64fe33b997e8d05ca9ebfb598dbe1605990
2019-12-17 23:43:14 -05:00
John Sully 186189ecae Ignore enable-pro with no license key. makes it easier to launch a demo from the open source version
Former-commit-id: 31ab6bcd6f39f0a4a9e50a5af613b293eecfb4c2
2019-12-17 23:40:59 -05:00
John Sully 103fbf663e Implement license key checks
Former-commit-id: 62ed5b2956aebe70ef8cf758888098e1f4bb530b
2019-12-17 23:35:14 -05:00
John Sully d50da19fb4 Implement pro badge and trial timeout
Former-commit-id: 9d6a284eb45c8a137c7f59645294b4fa4be389e5
2019-12-17 20:32:53 -05:00
John Sully a0d8d52ef3 Merge branch 'unstable' into advanced_db
Former-commit-id: 1f9cb22fd370741c2f60517376af5008c25704f5
2019-12-17 19:00:02 -05:00
John Sully 8844174763 Fix type in makefile
Former-commit-id: aa3e70f9a0
2019-12-17 18:23:19 -05:00
John Sully ca6a26f115 Enusre CXXFLAGS has the same settings as CFLAGS
Former-commit-id: cda8d42a76
2019-12-17 17:49:51 -05:00
Petr Vaněk c8ca8b2ab8 Correct C++ related makefile variables
FINAL_CXXFLAGS should not inherit CFLAGS because they can contain C
specific options unsupported by C++.

REDIS_CXX should point to the C++ compiler rather than C.


Former-commit-id: 67f32bf1b1
2019-12-17 17:43:15 -05:00
John Sully 5449859ede Perf fixes for expire snapshots
Former-commit-id: da805e4442815c89e85ca7b9fc855dd11ef2a6c8
2019-12-17 17:39:04 -05:00
John Sully 67e429e898 Threading fixes
Former-commit-id: 4f1cec6abd72d6e215880f2ce7812e88509cd218
2019-12-16 22:08:18 -05:00
John Sully b8015a4c2f complete snapshot handling of expires, may still be perf issues
Former-commit-id: 7c6cf4ba4696ba8a7b4069491e8ad0a583958bdc
2019-12-16 22:07:53 -05:00
John Sully 2e05aa89d0 snapshots no longer have dangling keys in the expire set
Former-commit-id: 939b6b61084fbec7b7bd0ada49f6853e334f87dd
2019-12-16 21:14:16 -05:00
John Sully 4d7b05baf3 SDS refcounted type
Former-commit-id: 361d0308febd5da0c7291469ea7e922e7147c1d6
2019-12-16 20:16:51 -05:00
John Sully 7cc892284f Extra expire validation on save
Former-commit-id: 037290cd2ec1b237df5236a86915d63d53fb48ce
2019-12-16 20:16:07 -05:00
John Sully 0b24112fe2 Merge the expire datastructs on endsnapshot
Former-commit-id: 968681ac37d1505a7b38628425f60e08b2cd41c4
2019-12-16 20:13:19 -05:00
John Sully 7900642444 We shouldn't define libc functions...
Former-commit-id: 9da8b7e25b8f423dc0efa54f49307c425eeabc55
2019-12-16 20:11:01 -05:00
John Sully c4b9d485a1 Expireset should do a deep hash
Former-commit-id: cdcdf57dd1419ec09eab6579caf5e5ff9a5a242c
2019-12-16 19:06:07 -05:00
John Sully 9c5400a223 The mitigation was bogus, fix it so it works
Former-commit-id: c7f1e069bf7e7b6f5321f920af9a0ed80f3853b0
2019-12-16 18:40:55 -05:00
John Sully e9bf0c0271 IStorage related build issues
Former-commit-id: 45bc344bfe678a633a005506a690e86ddf2efd5f
2019-12-16 18:32:30 -05:00
Petr Vaněk a319e8a4f4 readme: fix typo
Former-commit-id: 7a3f363f34
2019-12-16 15:40:09 -05:00
John Sully 31d42faf27 Try harder to free memory
Former-commit-id: 48f7c34c91c51ef06d9a1f4e8bc5f1f5cd88cfaa
2019-12-14 19:46:39 -05:00
John Sully fce67c145f A bunch of bug fixes
Former-commit-id: 228339586a19874f869cf45dc3834a270f99768a
2019-12-10 01:01:45 -05:00
John Sully 74cbadb753 Make the storage provider configurable, and show it in the info command
Former-commit-id: e201ce622ff3c7832d03c6b5759386f0efc23cdf
2019-12-09 21:07:37 -05:00
John Sully 38f7cca61a Add support for multiple databases with rocksdb
Former-commit-id: cfa3b760b00776876134692d42e25a60fcd8dea9
2019-12-09 20:45:58 -05:00
Tais P. Hansen 56a28a7c1e Fix keydb-cli crashing on read-only filesystem
Former-commit-id: 91eac2cdb3
2019-12-09 14:23:10 -05:00
John Sully cb136d2ac5 Flash running well
Former-commit-id: 9cf393eb9fb69bcc7550cd8b83e1568b3f360310
2019-12-08 20:06:22 -05:00
John Sully 992784c21d modify how the database array is stored so swaps are easier
Former-commit-id: 48fd6ec5ca69dd505d0e757862c09a898c19cf22
2019-12-08 16:49:59 -05:00
John Sully 86cd47fe80 Prevent extra copy of key
Former-commit-id: 9c3ef97039e59c6b820f71a90f8a9fb4eae8a7b1
2019-12-08 16:02:24 -05:00
John Sully 1e92c7b117 Optimize remote storage by bulk saving keys after processing operations but before sending responses to clients
Former-commit-id: 63a6dc2a29680d5d3f3f245168ca7de5d6bee1eb
2019-12-08 10:56:05 -05:00
John Sully 130589d8d1 Initial RocksDB integration
Former-commit-id: 0de9e5b692c02e779e538ddd0a56d10215e501bb
2019-12-06 20:39:32 -05:00
John Sully 11f710c5fc Fixup IStorage uses
Former-commit-id: 5ea0ce143a79365fb3903c6fc7caeb1c9760b0cc
2019-12-06 17:43:28 -05:00
John Sully e61aa0261b Initial standup of RocksDB dependency
Former-commit-id: 19bb40ffdc794cf9cafa9f4132a0facf1e074101
2019-12-06 17:33:18 -05:00
John Sully ec853485da Fix warning
Former-commit-id: 1d5ae423e039de437e8e48b5d15eb9908846bf04
2019-12-01 20:28:21 -05:00
John Sully b06901a295 Fix Issue #107
Former-commit-id: 98a928147f
2019-12-01 18:17:33 -05:00
John Sully 729825f359 Merge branch 'unstable' into advanced_db
Former-commit-id: d1ae8f2d1b03c0a79a36d710e4bb6594c37028b4
2019-11-30 00:52:33 -05:00
John Sully e16deddd05 Fix deadlock in spinlock (mfence) also spin for less time before sleeping
Former-commit-id: 8a9045c028
2019-11-30 00:51:58 -05:00
John Sully 5f1331cc3c It is permissible to call dictFind() while iterating
Former-commit-id: 43a598c145d5ea9f2c0b2a16f93f5a8cbb724e7e
2019-11-30 00:03:34 -05:00
John Sully 6533428887 Reduce snapshot window to 1 second instead of 10
Former-commit-id: 4f91f0503fe4eea1c20b977a5858ac345c3e7b9b
2019-11-29 22:21:49 -05:00
John Sully b0e6cc85ef Bug: only update global flags for sync save
Former-commit-id: f01a7cf59bf965b35e5bb23e3ecbb7265ef8942a
2019-11-29 22:21:17 -05:00
John Sully fd7a278eea rehash MS does too little work before checking the time
Former-commit-id: 3e57b5c961f7dd91ddb24331eba9a3fa39b08fdd
2019-11-29 15:18:37 -05:00
John Sully 5fd848eedc Nested snapshot garbage collection. Works but huge fragmentation
Former-commit-id: 82b2a3f3dbf8f864d9157655b5422c69845c4019
2019-11-28 19:00:51 -05:00
John Sully b8cf7ef35c Fastlock should yield in ARM
Former-commit-id: 6c65a11b8d
2019-11-28 14:26:43 -05:00
John Sully 65a3485dfb Ensure size() count is accurate, and fix find_threadsafe which didn't check children
Former-commit-id: ffa44b636afd4fe907c79fe7deebac3d1e091ee9
2019-11-25 17:50:40 -05:00
John Sully 6ae66162c5 Move snapshot code into its own file
Former-commit-id: 4afd0a6ce650cc93a73ea3e4bb632226087dde37
2019-11-24 17:59:02 -05:00
John Sully 551b30fb77 Restrict the snapshot API
Former-commit-id: cbafb88f267a9480cdbde6a88e9e1992e8a85971
2019-11-24 17:53:06 -05:00
John Sully 9a75557651 Get rid of key only iterate, the threadsafe is just as fast and key only users can ignore the robj
Former-commit-id: 29689a5ed6141c5b2019d41ccd4036e6ddd1a121
2019-11-24 15:45:17 -05:00
John Sully 0a123e145e Fix crash on shutdown
Former-commit-id: 6dc55cc0f838b3c82afb233985429b4e7fc5dfb1
2019-11-24 14:24:41 -05:00
John Sully da4adb261b Fix multithreading data races
Former-commit-id: 80f6e5818fd575cb08a5f620c35eed1cd862eb57
2019-11-24 13:44:43 -05:00
John Sully 5f64e227a4 Fix warning
Former-commit-id: 1318b87013c61f7149127eae8e30caf887a6db7b
2019-11-23 19:19:54 -05:00
John Sully 57595d8e47 Add support for nesting snapshots
Former-commit-id: 5e6c37f388233cc3f2d204ad17ac2897d3333a21
2019-11-23 19:02:50 -05:00
John Sully 30d85b35e2 Remove pending async writes if we're freeing the client
Former-commit-id: 8b5caad51136f1ed29a9e4c01ed984f6e7ff9c4c
2019-11-23 19:01:40 -05:00
John Sully 87ca381ea2 Add support for removing pending writes for clients we're about to free
Former-commit-id: 67c1fd322e1a12b1b22707d67713d60c97c34cef
2019-11-23 19:00:27 -05:00
John Sully fda0f82d64 Add support for nested snapshots
Former-commit-id: 43456c7807152062d59b2a90597b6204f637f5cd
2019-11-22 20:53:36 -05:00
John Sully 219cd22fd6 Fix crash when client running async keys disconnects before keys finishes
Former-commit-id: dd9233c49d82c89a9d92b7251a56f91c2ee98e77
2019-11-21 20:40:58 -05:00
John Sully b057c1f8fb Merge branch 'unstable' into advanced_db
Former-commit-id: 00ad497fb3f409dbfcaa62fa9ea5d793263eb13d
2019-11-21 20:21:48 -05:00
John Sully 032e5e4dc5 Bump version
Former-commit-id: 7dd53182e0
2019-11-21 20:16:42 -05:00
John Sully c078c89db4 Merge branch 'unstable' into RELEASE_5
Former-commit-id: 53b95d830a
2019-11-21 20:16:23 -05:00
John Sully 27c23b0c9b Fix issue #83
Former-commit-id: 3028a890ef
2019-11-21 20:05:16 -05:00
John Sully 04f3a60032 Add missing dependency to dockerfile
Former-commit-id: 39c6fbddb1
2019-11-20 20:35:14 -05:00
John Sully 9ad2ebabd1 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 704cb4e929
2019-11-20 19:44:43 -05:00
John Sully 051bde5d3d Fix issue #107, active replicas do their own expires
Former-commit-id: 8e4f323439
2019-11-20 19:44:31 -05:00
John Sully b3dd59db5c Additional asserts ensuring the client is creating on the correct thread
Former-commit-id: 937702ea1d
2019-11-20 17:00:40 -05:00
John Sully 75fe5ea8e8 Update issue templates
Former-commit-id: 3ea56ffb38
2019-11-20 16:25:33 -05:00
John Sully 773ecdcdd4 Update issue templates
Former-commit-id: becd3fc5a3
2019-11-20 16:24:23 -05:00
John Sully 8ce03ed34a Add missing files
Former-commit-id: 8fa2951e21c5c75a0bb4dc3ef50891123166b76a
2019-11-19 23:03:20 -05:00
John Sully 93dae1f03f Clarify license
Former-commit-id: d0a7f219cd56edbe70bd8e93f21b39e6cd4836e2
2019-11-19 22:22:16 -05:00
John Sully 065ee57c8d Run KEYS async
Former-commit-id: 214a54a815ff66ef4a1526da90296787240ecdf9
2019-11-19 22:12:52 -05:00
John Sully 408a28bd64 Multiple threads should be able to get the same snapshot provided its not too old
Former-commit-id: 054331098ee18dfb1887fd2b0a67688ef894823e
2019-11-19 17:40:35 -05:00
John Sully 80f9b812ca Ensure iterating the keyspace still works during background save
Former-commit-id: 23d7a8a293f253262801bc6ce88ad85e4e38f59a
2019-11-19 15:47:06 -05:00
John Sully a60925c949 Final design of forkless background save. expires NYI
Former-commit-id: e2dc24b441bf52b181c820c853e0bc7524254f3f
2019-11-18 19:47:12 -05:00
John Sully a9f20f0a38 Merge branch 'unstable' into advanced_db
Former-commit-id: 7530d93cd5c4a9fc4e6466abcf96edbdd8daea9e
2019-11-18 15:22:17 -05:00
John Sully d46d4cd9ef Fix failure to wakeup from futex sleep due to fastlock_unlock reading the wrong offset in the asm version. Also fix false sharing in spinlock
Former-commit-id: 4c8603815c
2019-11-17 16:06:49 -05:00
John Sully 831fa24a18 Revert "Debug sleep should apply to all threads"
This reverts commit a2d4f4969f [formerly 41b678814b].


Former-commit-id: 3ae75c2d2b
2019-11-17 15:39:47 -05:00
John Sully 22253da5c9 Improve perf of reading cluster bitfield
Former-commit-id: 9371c005aa
2019-11-17 14:52:12 -05:00
John Sully 29b52ca5ce Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 16bd6b3f5d
2019-11-14 21:21:46 -05:00
John Sully 8c6f775cf7 Cluster multithreading fixes
Former-commit-id: 3dd78a6101
2019-11-14 20:14:24 -05:00
John Sully a2d4f4969f Debug sleep should apply to all threads
Former-commit-id: 41b678814b
2019-11-14 19:57:29 -05:00
John Sully 7dac41ed72 killing clients should take effect ASAP
Former-commit-id: d0ccb074d5
2019-11-14 19:49:32 -05:00
John Sully b5ba20fe1b Improve AE Assert message
Former-commit-id: cb0fc7cca2
2019-11-14 19:34:13 -05:00
John Sully 21bffec0d7 Fix test failure with tcl8.5 (test only issue)
Former-commit-id: 5e40ea6ee7
2019-11-04 17:31:29 -08:00
John Sully a55fe8a3ba Fix potential race in pubsub
Former-commit-id: 427c5999f1
2019-10-25 02:50:30 -04:00
John Sully 1b3cbd056f Fix potential race in pubsub
Former-commit-id: a91f58b8fd
2019-10-25 02:44:14 -04:00
John Sully c276b86fea bump version
Former-commit-id: 3013799664
2019-10-25 01:00:28 -04:00
John Sully 2ad519d115 Merge branch 'unstable' into RELEASE_5
Former-commit-id: f8220a658e
2019-10-24 23:39:18 -04:00
John Sully 949270801e Signals can happen on any thread, so look for the signal handler not the command on the callstack
Former-commit-id: f1d2b29450
2019-10-24 23:30:08 -04:00
John Sully 70fba8e707 Two fixes: 1) Remove race conditions by not locking clients when async writing. 2) Don't derefence dangling pointers in lambda
Former-commit-id: cb93752aff
2019-10-24 23:07:02 -04:00
John Sully c8f1efddaa Sanitizers work with GCC too
Former-commit-id: 549cad378d
2019-10-24 23:05:39 -04:00
John Sully 7bdc24a86d Remove the DB lock, its unnecessary
Former-commit-id: 631f863dd8
2019-10-24 20:18:48 -04:00
John Sully b39e6c9497 Remove unlocked KEYS command support, we will do this with snapshotting
Former-commit-id: 4396682c07
2019-10-24 20:18:11 -04:00
John Sully 8d2dc7ab52 Build break, ensure C99 compatibility
Former-commit-id: ca4ee4e3e4
2019-10-23 13:38:07 -04:00
John Sully 391b2f311e Fix build break in TravisCI
Former-commit-id: 2da09e0732
2019-10-23 13:31:39 -04:00
John Sully 8d0b21c403 If a replica is about to be closed, don't wait on its lock (potential deadlock)
Former-commit-id: 4986dc6da9
2019-10-23 13:20:23 -04:00
John Sully 8b44d86c7c processEventsWhileBlocked needs to release the lock in a safe way
Former-commit-id: 1a70af2ae1
2019-10-23 13:19:57 -04:00
John Sully 60c35d6ea7 Remove race conditions
Former-commit-id: 5a8cb77d0d
2019-10-22 23:26:37 -04:00
John Sully b1190c24a8 Optimize deadlock detection, fix callstack for ASM, and annotate locks
Note: This change moves our assembly code to use the GNU Assembler because NASM seems to be incapable of emitting the necessary debug information for callstack unwinding to work.

Former-commit-id: 600fc241cf
2019-10-22 21:34:51 -04:00
John Sully 8aea7f8586 Implement deadlock detection
Former-commit-id: fa797408d9
2019-10-22 00:43:32 -04:00
John Sully 6de2f0779a Disable multithreaded KEYS due to bugs
Former-commit-id: 3fac516950
2019-10-21 12:21:46 -04:00
John Sully 1336f4c80f Remove performance zapping test code
Former-commit-id: c50a3d0bbd
2019-10-21 01:48:58 -04:00
John Sully 8e6c6403e1 reenable optimized string dup code
Former-commit-id: 5eb84db03a
2019-10-21 00:08:38 -04:00
John Sully 0e0e9e73f9 Forkless background save. NOT OPTIMIZED
Former-commit-id: bd9d8e05b0
2019-10-20 23:54:05 -04:00
John Sully 0c7f279b2c Factor out dependencies on rdb_child_pid which will be going away
Former-commit-id: 2ab4c6b99e
2019-10-17 23:10:45 -04:00
John Sully 48787c8a03 Dependencies for forkless RDB saving
Former-commit-id: c12be59475
2019-10-17 22:53:50 -04:00
John Sully 6ee58a3b21 Ensure RDB saving only uses data from the persistent data struct, and cleanup inheritance
Former-commit-id: fcdda67d87
2019-10-17 17:20:47 -04:00
John Sully c2b5a8802e Support serializing all types
Former-commit-id: dfdd41f15c
2019-10-16 14:23:28 -04:00
John Sully cec6f0e934 Cleanup inheritance
Former-commit-id: e8debc83e8
2019-10-16 13:45:36 -04:00
John Sully afa487ca54 Merge branch 'unstable' into advanced_db
Former-commit-id: 88152a8f4f
2019-10-16 13:23:19 -04:00
John Sully 5eded25f33 Merge branch 'unstable' into RELEASE_5
Former-commit-id: 2f65aa2337
2019-10-16 12:47:06 -04:00
john@csquare.ca d4bb51d52c Fix: ExpireMember does not update MVCC timestamp
Former-commit-id: f5210a8fb0
2019-10-16 12:38:15 -04:00
John Sully d8a02c8a65 expiremember should return the same results as expire
Former-commit-id: 8f1295c00f
2019-10-16 12:27:04 -04:00
John Sully 4dc728c1ce Fix crash adding expire to key with a subkey expire already set
Former-commit-id: 18a3768e07
2019-10-16 12:26:48 -04:00
John Sully 2e0a7b7821 Fix clang warnings
Former-commit-id: c4f086ae93
2019-10-13 15:48:55 -04:00
John Sully 20a5b1bc15 Fix failing travis CI build
Former-commit-id: 3f0c1f94eb
2019-10-13 15:41:53 -04:00
John Sully 021d287c6a Merge branch 'advanced_db' of https://github.com/JohnSully/redis2 into advanced_db
Former-commit-id: f6855bc34d
2019-10-13 15:35:30 -04:00
eric-weaver 2a472c06f3 add missing dependency
Former-commit-id: 95e3dbc104
2019-10-13 21:30:06 +02:00
Segmond c1e0188e53 Update README.md
Typo, focuses spelled as focusses

Former-commit-id: 40355eac3e
2019-10-13 21:29:15 +02:00
John Sully a2bd45dbd3 Add the IStorage interface and wire it up
Former-commit-id: 898efbfc0c
2019-10-13 15:24:08 -04:00
John Sully f9f4c719d4 Isolate the persistent parts of the database from the runtime parts
Former-commit-id: 8d63f5b560
2019-10-13 15:24:08 -04:00
John Sully b4a34cd600 Hide the database dict
Former-commit-id: 024365521c
2019-10-13 15:13:01 -04:00
John Sully 2980e06c9f Implement the lastmodified query for the OBJECT command
Former-commit-id: 3a3b59a054
2019-10-13 14:12:09 -04:00
John Sully 2fc9bb0c8d You are not allowed to set a subkey expire if the subkey does not exist
Former-commit-id: 12e17cfd6e
2019-10-13 14:11:43 -04:00
John Sully ac243ae4bf Implement the EXPIREMEMBERAT command
Former-commit-id: 203e341bf4
2019-10-13 13:15:13 -04:00
John Sully 650085d61a Add millisecond support for EXPIREMEMBER command
Former-commit-id: 6e6cd84ad7
2019-10-13 12:57:50 -04:00
John Sully e57d2e24c9 Update more slave instances to use replica (Issue #75)
Former-commit-id: 252725d50f
2019-10-13 12:29:20 -04:00
John Sully 05d7536b02 Update a few uses of slave to use the new replica terminology (Issue #75)
Former-commit-id: c15633ea9e
2019-10-13 12:12:05 -04:00
John Sully 6080010db0 Fix an intermittent crash when replicationCron happens before slavesdb is update
Former-commit-id: 27c9ae667e
2019-10-13 12:04:54 -04:00
John Sully 0a00341a80 Implement TTL and PERSIST commands for subkeys. Also ensure expiremember replaces any old subkey expiries
Former-commit-id: 16f96efbe7
2019-10-13 12:03:25 -04:00
John Sully 3670376457 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 5787e7adc7
2019-10-13 10:03:01 -04:00
John Sully dba52de8ca Fix issue #88 - don't let seperate KeyDB processes listen on the same port
Former-commit-id: 4631119179
2019-10-13 10:02:21 -04:00
John Sully acab05cf08 Bump version
Former-commit-id: 0a0c2146c8
2019-10-01 17:53:48 -04:00
Edgard Lorraine Messias d34f7746ed Fixed "Provides" name in chkconfig info
Former-commit-id: cedea7e400
2019-10-01 13:44:58 -04:00
John Sully aab2aa5590 Merge branch 'unstable' into RELEASE_5
Former-commit-id: 66cef6646c
2019-09-30 00:28:12 -04:00
John Sully b11d3c4b82 Expire DEL command place holder
Former-commit-id: 64aa4b80e6
2019-09-30 00:01:23 -04:00
John Sully c18bba8535 Fuzz mode is now an argument not based on the exe name
Former-commit-id: 551a3cb1aa
2019-09-30 00:00:29 -04:00
John Sully 311b3502ae finish up the RDB fuzz
Former-commit-id: 0942188b0a
2019-09-28 17:38:46 -04:00
John Sully 3a8d13760a Fix double free in RDB load
Former-commit-id: 070c481871
2019-09-28 17:38:26 -04:00
John Sully b01cf73999 RDB fuzz test cases
Former-commit-id: 6df4d29422
2019-09-28 17:04:08 -04:00
John Sully 4db6193052 RREPLAY command now takes a DB argument
Former-commit-id: 6e1e5bd08b
2019-09-28 14:59:44 -04:00
John Sully 4cac0ca35a Implement left and right shift BITOP operators
Former-commit-id: ba365298ed
2019-09-28 00:10:46 -04:00
John Sully cdfcc42b6d Fix leaking stale RDBs during multimaster sync
Former-commit-id: e1c9620951
2019-09-27 13:17:29 -04:00
John Sully 4f19c5de9f Fix multi master bugs: 1. we fail to create the temp file. 2. We use a master RDB as our backup even though we merged databases (and therefore it is not representitive)
Former-commit-id: e776474f68
2019-09-26 20:35:51 -04:00
John Sully 16a88d1244 Add the IStorage interface and wire it up
Former-commit-id: cbd4b4df19
2019-09-20 14:52:22 -04:00
John Sully 5e4d3ed36d Isolate the persistent parts of the database from the runtime parts
Former-commit-id: 08995b065c
2019-09-19 22:36:29 -04:00
John Sully 9da6b795c6 Hide the database dict
Former-commit-id: 065846a9c3
2019-09-19 17:44:42 -04:00
John Sully e62e4ed6c3 Fix issue where AOF events are posted to the wrong event loop and not properly cleaned up
Former-commit-id: 4589e861ab
2019-09-19 15:40:09 -04:00
John Sully c75e700a86 Fix issue where AOF events are posted to the wrong event loop and not properly cleaned up
Former-commit-id: 55324aa56a
2019-09-19 15:39:52 -04:00
John Sully bd4ed482c4 KEYS now only blocks one database
Former-commit-id: 18d42a5c35
2019-09-12 18:51:10 -04:00
John Sully 26c02f47fb bump version
Former-commit-id: 71d5a10621
2019-09-06 13:31:40 -04:00
John Sully e45268930a Fix issue where Active Replicas were commiting data to the wrong database under load
Former-commit-id: ac595ebe37
2019-09-06 13:30:28 -04:00
John Sully 216636c134 Fix issue where Active Replicas were commiting data to the wrong database under load
Former-commit-id: 50a6a3ca38
2019-09-06 13:30:15 -04:00
John Sully afa69ddcbf Acquire the lock for modules that don't acquire it before calling like they are supposed to
Former-commit-id: f83a89f82a
2019-08-29 15:41:03 -04:00
John Sully a610218535 Bump version
Former-commit-id: bf905a78f0
2019-08-27 15:32:24 -04:00
John Sully cb6abcf3fa Fix race condition in PUB/SUB and other async reply commands where the client can be freed before our handler is executed on the client thread. When this occurs the client pointer is dangling
Former-commit-id: fad9483fc9
2019-08-27 15:31:47 -04:00
John Sully a21a7a8ee9 Fix race condition in PUB/SUB and other async reply commands where the client can be freed before our handler is executed on the client thread. When this occurs the client pointer is dangling
Former-commit-id: 46a78c69e7
2019-08-26 20:18:52 -04:00
John Sully 862a87a8ae Fix warnings on newer compilers
Former-commit-id: 33e0b3e1c0
2019-08-14 01:03:24 -04:00
benschermel 4c3ecad178 update readme (#71)
* update readme

* KeyDB must acknowledge its Redis origin and that while we have different opinions we are greatful to Antirez and Redis for the work they've done in this space.

* Update README.md


Former-commit-id: 4e9bfcf84b
2019-08-06 19:25:13 -04:00
John Sully b3de6fcf26 Optimize the new expire code
Former-commit-id: 75c6b4c64a
2019-08-02 21:31:05 -04:00
John Sully ef6d9c6e1f Fix test failures: Non active replicas are allowed to use shared int values
Former-commit-id: 8536854266
2019-07-30 17:11:15 -04:00
John Sully 5525de6148 Acquire the lock for modules that don't acquire it before calling like they are supposed to
Former-commit-id: 6016dd0f8b
2019-07-30 16:54:25 -04:00
John Sully 89b8ba8d9d Fix HLL corruption
Former-commit-id: 47ef9e5cbd
2019-07-29 18:08:45 -04:00
John Sully f8884fed3a Fix crash setting expire on a key with an existing subkey expiration
Former-commit-id: 4858fd893c
2019-07-29 17:09:51 -04:00
John Sully 8d36bab0e1 Fix crash in RediSearch
Former-commit-id: 6b6e6f6c1e
2019-07-29 15:08:57 -04:00
John Sully 945a7b69f1 Fix crash in RediSearch
Former-commit-id: cbe5c04a0f
2019-07-29 15:08:41 -04:00
John Sully ce96c69719 RREPLAY failures should be logged
Former-commit-id: b0a0f03b96
2019-07-24 22:49:55 -04:00
John Sully e3b97286ca RREPLAY failures should be logged
Former-commit-id: 08b6a04055
2019-07-24 22:49:30 -04:00
John Sully 17e6131ca5 Issue #64 RREPLAY isn't binary safe. Add fix and test.
Former-commit-id: f1982ca63d
2019-07-24 22:31:44 -04:00
John Sully 4c49370efe Issue #64 RREPLAY isn't binary safe. Add fix and test.
Former-commit-id: afe66288fe
2019-07-24 22:31:02 -04:00
John Sully a0d7eb5a19 We can't set FExpire() on shared objects, issue #66
Former-commit-id: 2794cfced4
2019-07-23 23:39:47 -04:00
John Sully 8c46a1fba2 Merge pull request #65 from JohnSully/subexpire
EXPIREMEMBER Command Implementation

Former-commit-id: d6b45a56e7
2019-07-23 19:06:57 -04:00
John Sully 9ba5270bda Subexpire entries should load/save
Former-commit-id: a55d980436
2019-07-23 18:53:59 -04:00
John Sully 9f42bb5d91 Fix buggy rebase
Former-commit-id: 6037d1f326
2019-07-23 18:53:59 -04:00
John Sully 4ec97fdb46 Fix merge conflict
Former-commit-id: 0b43b51a2e
2019-07-23 18:53:59 -04:00
John Sully e06c38f1d3 Plumb support for sub expires to all expire related code
Former-commit-id: 184abac694
2019-07-23 18:53:59 -04:00
John Sully 95371d60fe Fix crash with traditional expiration
Former-commit-id: 0ba5b2c3d6
2019-07-23 18:53:58 -04:00
John Sully 94645b33dd Initial prototype of EXPIREMEMBER command
Former-commit-id: 0b3d74ea67
2019-07-23 18:53:58 -04:00
John Sully 82a3e942bf New expire datastructure and algorithm. Allows us to expire in sublinear time
Former-commit-id: ea3bd614b8
2019-07-23 18:49:31 -04:00
John Sully a3dbe03a66 Merge pull request #50 from JohnSully/expire
New Expire Datastructure which is faster and more memory efficient.  This allows us to process expiries in sublinear time.

Former-commit-id: d45edc493d
2019-07-23 18:40:48 -04:00
John Sully e04cff2cfe Support TTL stats with the new expire datastructure
Former-commit-id: 271df3dad4
2019-07-23 18:30:10 -04:00
John Sully 8b3d250d8f Implement hash table stats and fixup the hash function based on the results
Former-commit-id: 5a193872f8
2019-07-23 18:30:10 -04:00
John Sully e8709ee6b0 Add back missing file lost in rebase
Former-commit-id: b5512d77a1
2019-07-23 18:30:10 -04:00
John Sully 3ffdccad86 Add back file erroniously deleted in rebase
Former-commit-id: 42bda8eaba
2019-07-23 18:30:10 -04:00
John Sully fc54e0970f never make last minute changes before commiting
Former-commit-id: 7e5d3f4f16
2019-07-23 18:30:10 -04:00
John Sully 23c1e89190 Fix a few potential assert crashes
Former-commit-id: 5f3920e491
2019-07-23 18:30:10 -04:00
John Sully a060bc7942 New expire datastructure and algorithm. Allows us to expire in sublinear time
Former-commit-id: 3880d2616c
2019-07-23 18:30:10 -04:00
John Sully f094402c33 Any +x bit is acceptable
Former-commit-id: 156e596f9c
2019-07-19 15:26:17 -04:00
John Sully 8d526d9354 Any +x bit is acceptable
Former-commit-id: fc58516cca
2019-07-19 01:42:05 -04:00
John Sully 5404d6f6bb Modules must have execute permissions to load
Former-commit-id: a4efcd35af
2019-07-19 01:31:10 -04:00
antirez ebc50797a0 RDB: make sure to abort on LZF encoding error.
Former-commit-id: 27fe1658a2
2019-07-19 01:03:16 -04:00
antirez 867070eb99 RDB: handle encoding errors with rdbExitReportCorruptRDB().
Without such change, the diskless replicas, when loading RDB files from
the socket will not abort when a broken RDB file gets loaded. This is
potentially unsafe, because right now Redis is not able to guarantee
that encoding errors are safe from the POV of memory corruptions (for
instance the LZF library may not be safe against untrusted data?) so
better to abort when the RDB file we are going to load is corrupted.

Instead I/O errors are still returned to the caller without aborting,
so that in case of short read the diskless replica can try again.


Former-commit-id: 47feb2719c
2019-07-19 01:02:49 -04:00
John Sully 1c8c4a5db2 Fix bad merge in SCAN KEYS command
Former-commit-id: c21af6b351
2019-07-19 00:43:23 -04:00
John Sully c178b67ded Merge commit '9c1932beeb6e307c2fbeadcfff8954e517189ae8' into unstable
Former-commit-id: 821c12c482
2019-07-19 00:32:43 -04:00
John Sully 33acb40633 Merge commit '985e5b2c608eade2a60e50a6a177f13381c9c8d8' into unstable
Former-commit-id: 4602f8c391
2019-07-19 00:01:56 -04:00
John Sully 6e461c3cc3 Fix compile errors from merges
Former-commit-id: 27a927fe00
2019-07-18 23:35:51 -04:00
Angus Pearson 12c8823c93 Add char* typeNameCanonicalize(robj*) to remove duplicate code between SCAN and TYPE commands,
and to keep OBJ_* enum to string canonicalization in one place.


Former-commit-id: 3cdc6e8d84
2019-07-18 23:31:31 -04:00
John Sully 1e066d266e Merge commit '2af8ebe14743ad88fd15af2ea91862b0667e94ce' into unstable
Former-commit-id: 89b52da387
2019-07-18 23:28:56 -04:00
Madelyn Olson a25866ad35 Fixed some spelling issues in ACL codepath including user facing error
Former-commit-id: 50ad880ad5
2019-07-18 23:28:36 -04:00
John Sully 11b12219eb Merge commit '214555b02ea448c444fb6a32ecfc5f312fc052b8' into unstable
Former-commit-id: 15bed4bbcc
2019-07-18 23:26:46 -04:00
John Sully 13fa9bb2be Merge commit '4bbaf621a12f6ec22ec7dad6a2282b7908660497' into unstable
Former-commit-id: 10986ae3a8
2019-07-18 23:22:36 -04:00
John Sully c90c269df3 Merge commit '525fc336ef5172f1eddbf18cbbfc1a32b054c9e2' into unstable
Former-commit-id: 2baa76b2ee
2019-07-18 23:21:13 -04:00
John Sully 6f3eda55d9 Merge commit '9eea57cc311e62a49358e09af7baebce9da9053f' into unstable
Former-commit-id: ee460301fd
2019-07-18 23:20:46 -04:00
John Sully 79b33481ae Merge commit '3f4f7aff1aa6abf8cad1726941d4c33b3bfbc9b8' into unstable
Former-commit-id: 8ebe2fce3d
2019-07-18 23:18:42 -04:00
antirez 12325871b4 Test: fix slowlog test false positive.
In fast systems "SLOWLOG RESET" is fast enough to don't be logged even
when the time limit is "1" sometimes. Leading to false positives such
as:

[err]: SLOWLOG - can be disabled in tests/unit/slowlog.tcl
Expected '1' to be equal to '0'


Former-commit-id: 8198a697fd
2019-07-18 23:12:52 -04:00
antirez b2d03d4221 Make comment in getClientOutputBufferMemoryUsage() describing the present.
Former-commit-id: 35acae360a
2019-07-18 23:12:39 -04:00
antirez 271db42742 Fix test false positive introduced by threaded I/O.
Now clients that are ready to be terminated asynchronously are processed
more often in beforeSleep() instead of being processed in serverCron().
This means that the test will not be able to catch the moment the client
was terminated, also note that the 'omem' figure now changes in big
steps, because of the new client output buffers layout.

So we have to change the test range in order to accomodate for that.
Yet the test is useful enough to be worth taking, even if its precision
is reduced by this commit. Probably if we get more problems, a thing
that makes sense is just to check that the limit is < 200k. That's more
than enough actually.


Former-commit-id: 8aaa8b0b11
2019-07-18 23:12:05 -04:00
John Sully 40eefe7da7 Release version 5
Former-commit-id: 25e18a7de9
2019-07-18 20:50:40 -04:00
John Sully cfee6376d2 Active Replicas should always use their own slaveseldb variable when sending/saving rdbs - never those of their masters. This is because the Active Replica is also simultaneously a master
Former-commit-id: bb090b6d20
2019-07-18 20:50:20 -04:00
John Sully 133650ac7d remove unnecessary variables
Former-commit-id: a9c4e3970f
2019-07-18 19:37:49 -04:00
John Sully 594559b45e Fix issue #59 - Test replicaof config variable
Former-commit-id: d5ecc2347a
2019-07-18 19:22:49 -04:00
John Sully 5cb7ec841a Add support for sanitizers and fix issues they have found
Former-commit-id: 58971a430d
2019-07-18 18:39:42 -04:00
John Sully bd3cc0bb95 Resolve race on neterr variable
Former-commit-id: 1512274f4c
2019-07-18 17:11:28 -04:00
John Sully 857f778b38 Make object refcounts atomic, technically it doesn't need to be currently but the semantics are complicated and error prone. This is much safer with little performance impact
Former-commit-id: e310d33c12
2019-07-18 15:49:12 -04:00
John Sully ce595a9287 Suppress initialized data sanitizer warnings
Former-commit-id: ad32ba0343
2019-07-18 15:49:03 -04:00
John Sully 48e44624c3 Another RESP3 regression
Former-commit-id: 4e30a5b4e5
2019-07-17 22:57:52 -04:00
John Sully f71f79af8e Fix Issue #58
Former-commit-id: c8516f3dc4
2019-07-17 02:34:02 -04:00
John Sully 5cbb1ed5f9 Shared objects should be marked as such
Former-commit-id: aae0fdc114
2019-07-16 18:32:01 -04:00
John Sully 20cfb91f3f Crash when aborting SYNC with a master on a thread other than main
Former-commit-id: a19d0f67b9
2019-07-15 14:55:41 -04:00
John Sully add714913b Implement test mode to make finding bugs easier
Former-commit-id: 971f69fe1f
2019-07-15 14:55:18 -04:00
John Sully b82cf7f034 Blocked clients can stall when under low load
Former-commit-id: 7468c691ad
2019-07-13 16:44:11 -04:00
John Sully 0f5b59241f Give the active-rep more time to sync for test reliability
Former-commit-id: 620c2ec141
2019-07-12 23:52:07 -04:00
John Sully ff0065df91 Fix more locking deadlocks
Former-commit-id: 3081b6f98b
2019-07-12 23:51:45 -04:00
John Sully 8cd37fae2c Fix deadlock with client and ae locks
Former-commit-id: 8630339e43
2019-07-12 20:46:50 -04:00
John Sully 3ffe5b5dde Add Active Replication tests
Former-commit-id: 528d10091f
2019-07-12 03:54:41 -04:00
John Sully e29c6d0ac9 FIX: The dabase count configuration is not respected
Former-commit-id: 149c3cf3dd
2019-07-12 02:13:37 -04:00
John Sully 0da2d91659 Update README.md
Former-commit-id: f12c3cf9dd
2019-07-11 20:29:47 -04:00
John Sully 35e23ca988 Fix compile errors on GCC v5
Former-commit-id: 1f08a0efb3
2019-07-11 20:20:01 -04:00
John Sully f0e17a7d04 Fix more accounting errors with active replication and the replication offset. Specifically we don't update repl_ack_off as frequently as we do reploff_skipped
Former-commit-id: 6cf85d1d01
2019-07-11 19:20:12 -04:00
John Sully 2bccf7adbf Active Replicas are not slaves
Former-commit-id: b5101a460d
2019-07-11 18:51:20 -04:00
John Sully 8ba25371a5 Fix active replication offset synchronization accounting, and enable the wait command
Former-commit-id: a5784ef09e
2019-07-11 17:00:23 -04:00
John Sully 0c611d8347 lazyfree needs to consume more memory to be detectable
Former-commit-id: 122ec25bf0
2019-07-06 00:53:40 -04:00
John Sully 514640f314 Redis only does this in beforeSleep function - doing extra calls like we do causes test issues
Former-commit-id: d013ad9eba
2019-07-06 00:53:20 -04:00
John Sully 725dd6539f Add back user space buffering of RDB save
Former-commit-id: d918ca6fa5
2019-07-06 00:36:23 -04:00
John Sully 33f32477da We can use less memory in the client output buffers. Its OK
Former-commit-id: 852819180f
2019-07-05 23:43:01 -04:00
John Sully 95f0357746 Fix additional warning related to new() overloads
Former-commit-id: 218111eb72
2019-07-05 23:42:39 -04:00
John Sully 9983a59895 Fix additional warnings
Former-commit-id: 1531cfb7ee
2019-06-27 16:29:36 -04:00
John Sully f5f4815041 Fix mac build breaks
Former-commit-id: 16a89f21dc
2019-06-27 15:04:09 -04:00
John Sully dbc8272acf Fix libcxxabi clang compile failure in travis, as well as bool issue due to old clang
Former-commit-id: 79e5160e37
2019-06-18 00:42:01 -04:00
John Sully 61015908ab Bump travis compiler version
Former-commit-id: 510e966dc0
2019-06-18 00:42:01 -04:00
John Sully d4d6e7756d Fix Travis CI issue
Former-commit-id: 8238d3207e
2019-06-17 23:56:23 -04:00
John Sully d65ce6fbbc Fix issues with relaxed memory model architectures
Former-commit-id: e37bc4ad40
2019-06-17 23:00:12 -04:00
John Sully db5af7990d Remove unnecessary recursive lock
Former-commit-id: 0f78b8b917
2019-06-17 23:00:12 -04:00
John Sully a849655efd missing file :)
Former-commit-id: 19061fe04f
2019-06-17 23:00:12 -04:00
John Sully d5b47e6997 Fix test failures due to assert
Former-commit-id: 9c901eb65f
2019-06-17 23:00:12 -04:00
John Sully 9725fadaba convert the pending write list to a vector for better performance and less cache thrashing
Former-commit-id: ae33ff3a6e
2019-06-17 23:00:12 -04:00
John Sully 924509f52f Move more code out of the GIL
Former-commit-id: 59dbd625c1
2019-06-17 23:00:12 -04:00
John Sully 9a050ffb42 Remove an unnecessary lock that eats performance
Former-commit-id: 8eb4e355b9
2019-06-17 23:00:12 -04:00
John Sully 049ca9bf58 Even the next up thread should sleep in the futex
Former-commit-id: 8b76b01bfe
2019-06-17 23:00:12 -04:00
John Sully dd7cbbe730 Fallback to a futex if we spin for a long time
Former-commit-id: ec57b4b024
2019-06-17 23:00:12 -04:00
John Sully 7fc6f7f607 Enable load balancing of UNIX sockets across threads
Former-commit-id: 46d6caa47c
2019-06-11 01:34:36 -04:00
John Sully 193522b54e Fix crash adding duplicate replica. Just send an error instead
Former-commit-id: 97b65ce19c
2019-06-02 15:50:50 -04:00
John Sully 460e36a6e7 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 55d0ef40b0
2019-06-01 03:23:21 -04:00
John Sully 2679450489 Implement MOTD feature in keydb-cli
Former-commit-id: a6c56416fc
2019-05-21 15:12:12 -04:00
John Sully b35e5f3cd0 Update README.md
Former-commit-id: cd3c482d5e
2019-05-21 00:04:12 -04:00
John Sully dd5152f836 Fix regressions from RESP3 changes in commit c8304b099d
Former-commit-id: c5cbb77fc7
2019-05-20 23:39:44 -04:00
John Sully b7fff89e3e The unstable branch doesn't have a version #
Former-commit-id: d7f21f02b3
2019-05-20 16:12:26 -04:00
John Sully 7d40b9b7d5 Fix double unlock
Former-commit-id: 87dc8ce9b3
2019-05-20 15:52:04 -04:00
John Sully fa828d8c92 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 2e22aa1a9c
2019-05-20 10:57:59 -04:00
John Sully a3706352d0 Protocol regression from RESP3 work
Former-commit-id: 8c56dbf971
2019-05-20 10:57:37 -04:00
Qix 36ad4c5907 cast void data pointer to const char * to fix gcc
Former-commit-id: a78169e9e0
2019-05-19 16:24:39 -04:00
John Sully 2783649378 Fix build breaks on some older compilers
Former-commit-id: 39a60c8120
2019-05-18 20:58:48 -04:00
John Sully 7074a7615e Fix build break on some compilers
Former-commit-id: c57d8760bd
2019-05-18 20:41:05 -04:00
John Sully a3556e7cef Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 3eed2a8780
2019-05-18 20:25:23 -04:00
John Sully 7ccf4f2dcf Print nicer error messages for uncaught exceptions
Former-commit-id: 23b0268a7f
2019-05-18 20:24:29 -04:00
John Sully 2dccb832bf Fix: Active replication falls behind under high load
Former-commit-id: 3d0de946bb
2019-05-18 20:23:20 -04:00
John Sully f240fb7803 Update Active Replication wiki links
Former-commit-id: 866b8ead91
2019-05-11 21:53:30 -04:00
John Sully 6371f6e3e4 Fix a few issues from the merge
Former-commit-id: aa274960ff
2019-05-11 19:26:59 -04:00
John Sully e601bc1169 Make lazy free test more reliable
Former-commit-id: 54d6eb851b
2019-05-11 17:57:35 -04:00
John Sully 397e85befb Merge branch 'unstable' of https://github.com/antirez/redis into MergeRedis
Note: some tests failing

Former-commit-id: 86d7276f24
2019-05-11 02:20:34 -04:00
John Sully 35a4c694e6 Add byline to logo
Former-commit-id: 0918651438
2019-05-10 23:48:14 -04:00
John Sully 1efbf15086 Fix CentOS build failure
Former-commit-id: 272d9297b6
2019-05-09 19:54:34 -04:00
John Sully 8c6e5aae98 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: f5bfc71899
2019-05-09 19:16:50 -04:00
John Sully 3f9b9fd718 build break fix
Former-commit-id: 42e1ded55f
2019-05-09 19:16:31 -04:00
John Sully b57a72fa2c Fix issue #11
Former-commit-id: 6c410af5a8
2019-05-09 19:14:10 -04:00
John Sully 302e35de6b Fix typo
Former-commit-id: 57ae676181
2019-05-09 19:06:58 -04:00
John Sully 57539d2ce4 Add missing file
Former-commit-id: 7896ca6e52
2019-05-09 19:05:09 -04:00
John Sully 58b4650c5a Change debug messages to reference KeyDB
Former-commit-id: c4a315dd5e
2019-05-09 19:03:50 -04:00
John Sully 3d2b9e3ab8 Fix module locking issues
Former-commit-id: bf26959b72
2019-05-09 19:00:27 -04:00
John Sully 6ae796cb91 refactor server global into a pointer (so that threadsafe commands can set this to NULL to prove they don't rely on it
Former-commit-id: 37b2d046be
2019-04-21 14:01:10 -04:00
John Sully 83adc0eabb Factor out some normally const globals
Former-commit-id: fa2e407873
2019-04-21 13:20:45 -04:00
John Sully a3228b0875 additional fix to rreplay forward compat
Former-commit-id: c61cf57db5
2019-04-20 01:36:23 -04:00
John Sully ea83004d18 Make rreplay forward compatible with extra future args
Former-commit-id: ef3690f2db
2019-04-20 01:15:01 -04:00
John Sully fd65ef689a Tweak mvcc time format so rollovers are not an issue
Former-commit-id: 14d01ec7bd
2019-04-20 01:03:08 -04:00
John Sully d6be236697 Timestamp writes to objects so we can be smarter about merging databases
Former-commit-id: 5dc9f70386
2019-04-20 00:52:07 -04:00
John Sully 3b09f197d5 Fix use uninitialized
Former-commit-id: 88e593bf96
2019-04-19 23:41:40 -04:00
John Sully c07aa5f3fe Additional MVCC work and fix memory leak loading objects from rdb
Former-commit-id: efde2e6be6
2019-04-19 22:54:42 -04:00
John Sully 676334758d Add version override command for users that need compatibility with Redis
Former-commit-id: 5a78a3bc46
2019-04-19 19:57:11 -04:00
John Sully 7933223b2a RREPLAY PERF: The UUID stack is unnecessary, RREPLAY itself can detect the cycle and call cancel()
Former-commit-id: b276d803d4
2019-04-19 19:36:47 -04:00
John Sully daed37e6c4 Detect cycles in mesh networks with multi master
Former-commit-id: da51ac430b
2019-04-19 19:31:11 -04:00
John Sully a8d89641cf Fix crash near boot when adding replicas and dumping database
Former-commit-id: 01eb0a3c7f
2019-04-19 17:08:54 -04:00
John Sully bb07727a0d Replication fake connection should inhereit the user and permission of the real connection
Former-commit-id: dc2b3cf4f8
2019-04-18 22:07:35 -04:00
John Sully 0e10e4f6f5 Start of MVCC support (and more C++)
Former-commit-id: c4621a5ed2
2019-04-16 23:16:03 -04:00
John Sully 98c30dfac1 Fix module linking and crashing issues
Former-commit-id: 1c953a4d5b
2019-04-16 13:34:22 -04:00
John Sully e79d075076 Fix replica authentication failure when masterauth is below replicaof in the config file
Former-commit-id: c64ce7aa9c
2019-04-15 22:31:02 -04:00
John Sully 89e09dd609 Fix memory leak unsetting master
Former-commit-id: acdc4fdfec
2019-04-11 19:55:44 -04:00
John Sully 92feaf280f Fix compile errors when MALLOC=memkind
Former-commit-id: 7ef9c18b72
2019-04-11 19:40:45 -04:00
John Sully cf40edb1e0 Fix failure to respect masterauth issue #26
Former-commit-id: a69b4e79db
2019-04-11 19:08:12 -04:00
John Sully 5b8893ef84 Fix addition RESP3 regressions (return empty set)
Former-commit-id: 740fc6c2b8
2019-04-08 16:52:57 -04:00
John Sully 90f6b22128 Fix protocol break with hgetall and family
Former-commit-id: 42202c868d
2019-04-08 13:52:02 -04:00
John Sully 68bec6f239 Move remaning files dependent on server.h over to C++
Former-commit-id: 8c133b605c
2019-04-08 01:00:48 -04:00
John Sully f469e28797 Move dict to C++
Former-commit-id: b50acd7238
2019-04-07 17:23:59 -04:00
John Sully 149415cd20 Port db to C++
Former-commit-id: 54db278695
2019-04-07 17:13:14 -04:00
John Sully 836e0aa80b Move a bunch of files to C++
Former-commit-id: 011948bcef
2019-04-07 16:54:56 -04:00
John Sully e8baaae47e Make t_string C++
Former-commit-id: 9f95d8b38f
2019-04-07 15:24:23 -04:00
John Sully 8ae135c9c9 Fix clang compile error
Former-commit-id: 3d394a6fa2
2019-04-06 00:20:17 -04:00
John Sully 15caa9f10b Add RREPLAY command and put the issue of packet storms to rest. Fixes issue #24
Former-commit-id: 68d2b648e0
2019-04-06 00:14:27 -04:00
John Sully ed808fe721 Fix regression in active replication caused by multimaster PR
Former-commit-id: 283998404f
2019-04-04 16:50:40 -04:00
John Sully aeddf60858 Merge pull request #23 from JohnSully/wip-multimaster
Wip multimaster

Former-commit-id: a7b4d0fea6
2019-04-04 11:40:58 -07:00
John Sully cddcd632ca All tests runs pass! YAYgit add src/cluster.c src/config.c !
Former-commit-id: 59051dd59d
2019-04-04 01:02:19 -04:00
John Sully 0e47f7dd52 Fix some more failing tests
Former-commit-id: cd836a37e7
2019-04-04 00:25:30 -04:00
John Sully 846cad0637 Merge branch 'unstable' into wip-multimaster
Former-commit-id: 4326d22380
2019-04-03 00:12:13 -04:00
John Sully 529a517740 Fix cluster test failure (not real issue)
Former-commit-id: 161d3a35ff
2019-04-03 00:11:34 -04:00
John Sully 16759f534d Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 20a9d21dfb
2019-04-03 00:09:51 -04:00
John Sully 9d23d50830 Fix failing tests due to build issue inhereted from Redis
Former-commit-id: e902789aa7
2019-04-03 00:09:26 -04:00
John Sully 22c8d9f70b Merge branch 'unstable' of https://github.com/antirez/redis into unstable
Former-commit-id: 3745bbd95b
2019-04-03 00:00:38 -04:00
John Sully 249ac16a6a Cluster tests shouldn't crash (note: still not passing either)
Former-commit-id: e63b2880b0
2019-04-02 22:32:10 -04:00
John Sully 702a1646f3 Multiple masters is no good if we keep dropping the database
Former-commit-id: a9b70e1ef7
2019-04-02 21:47:21 -04:00
John Sully 6d05a34ddd Tests are passing! YAY!
Former-commit-id: e300f753c5
2019-04-02 21:36:04 -04:00
John Sully 5d3c28a902 It compiles and doesn't crash immediately!
Former-commit-id: efaeca5887
2019-04-02 16:47:05 -04:00
John Sully 6cda4853d8 Link to GUI
Former-commit-id: 4d67305661
2019-03-31 14:37:54 -04:00
John Sully ff9d1d20e6 Commit missing file
Former-commit-id: 853bb6ca3e
2019-03-28 17:56:14 -04:00
John Sully ffe8a08c6c Travis needs to install uuid-dev
Former-commit-id: b16f23ae8e
2019-03-28 16:18:26 -04:00
John Sully 9c27743340 Implement database merging for Active Replicas
Former-commit-id: 91e6368de0
2019-03-28 15:12:43 -04:00
John Sully 60d22e0225 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: e4451b9628
2019-03-27 22:59:38 -04:00
John Sully eccb4c6d34 If no rdb file is specified and no s3 file is specified use the default RDB filename. If only S3 is specified use diskless sync
Former-commit-id: 770bb8ef5f
2019-03-27 22:59:12 -04:00
John Sully e076764a2a Update README.md
Former-commit-id: 87b958a210
2019-03-27 21:52:08 -04:00
John Sully d0256b50d8 Update README.md
Former-commit-id: 314ac90ba9
2019-03-27 15:39:25 -04:00
John Sully 83fc032d06 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 9f33822083
2019-03-26 20:39:56 -04:00
John Sully 714bad8d63 SIGALRM should happen on a worker thread to make our tests happy
Former-commit-id: 10a4b35bc5
2019-03-26 20:39:30 -04:00
John Sully 3e591fe487 Make PSYNC2 tests more reliable on slower hardware
Former-commit-id: 7b1dd0b60d
2019-03-26 18:59:31 -04:00
John Sully 35d3d7c961 Merge pull request #18 from DevopsDood/unstable
Update Readme for missing docker flag

Former-commit-id: 7a650741f7
2019-03-26 09:49:53 -04:00
Richard Silver bc9aaa4abe Update Readme for missing docker flag
Former-commit-id: 2ce5f1b944
2019-03-25 15:55:23 -07:00
John Sully cbd5a844f2 Give information on dependencies that need installation.
Former-commit-id: 063a14372d
2019-03-25 16:22:10 -04:00
John Sully 2ab9e6a4c1 Add depenednecy on uuid-dev to dockerfile
Former-commit-id: dd70e1b571
2019-03-25 02:09:53 -04:00
John Sully e22c496cc2 Talk about active replica
Former-commit-id: 1840b893c2
2019-03-25 00:12:04 -04:00
John Sully b817346d6e We don't corretly terminate our varargs
Former-commit-id: 8bcde757ce
2019-03-24 18:57:25 -04:00
John Sully ff470686df OS X build fixes
Former-commit-id: 1dff223c71
2019-03-24 18:06:57 -04:00
John Sully ccb9cb8b01 Active Replica Support
Former-commit-id: a7aa2b0740
2019-03-24 15:39:10 -04:00
John Sully d18905fd26 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: fb45fefbca
2019-03-21 23:11:55 -04:00
John Sully 6efdc5e923 Fix kqueue build error
Former-commit-id: 7b914c2531
2019-03-21 23:11:19 -04:00
John Sully 8c2aa3cf8c Merge pull request #16 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md

Former-commit-id: 75d517a27f
2019-03-21 21:57:25 -04:00
John Sully a17044b7b1 Update README.md
Former-commit-id: 4c98bc690e
2019-03-21 21:26:00 -04:00
John Sully 76dd5fe7fc Update README.md
Former-commit-id: 550b3a3a99
2019-03-21 21:25:49 -04:00
The Gitter Badger 8e5a2b4218 Add Gitter badge
Former-commit-id: ef7e89352d
2019-03-22 01:24:32 +00:00
John Sully f11840f6b2 Merge branch 'unstable' of https://github.com/antirez/redis into unstable
Former-commit-id: 9322d604ee
2019-03-21 20:15:59 -04:00
John Sully 67e646fe16 Merge pull request #15 from DevopsDood/unstable
Added docker builder for those that want it

Former-commit-id: 5d92110630
2019-03-21 19:54:00 -04:00
Richard Silver 764ecec65b Merge branch 'unstable' of github.com:JohnSully/KeyDB into unstable
Former-commit-id: 4056037cc2
2019-03-21 16:19:45 -07:00
Richard Silver 3c739e8b19 updated readme and Dockerfile to allow for tests to be run in container
Former-commit-id: 677ae5487f
2019-03-21 16:18:37 -07:00
John Sully 4c82a94f3a comment issue
Former-commit-id: 19956b3807
2019-03-21 22:18:48 +00:00
John Sully c1f7c0bcd5 Polarity of the weak flag was wrong. We want to use the strong variant of atomic_compare_exchange always
Former-commit-id: ab9122f2cb
2019-03-21 22:17:04 +00:00
Richard Silver df0af10250 Added build Dockerfile
Former-commit-id: e62c6b0ed0
2019-03-21 15:15:11 -07:00
John Sully c04002975d Compile issues at O0 optimization
Former-commit-id: 27a420fbc2
2019-03-21 21:57:18 +00:00
John Sully 9d76178296 ARM build fix: Don't use X64 asm here
Former-commit-id: b775ebb382
2019-03-20 04:14:33 +00:00
John Sully fbe1a6c52a Add debugging stats to the INFO command
Former-commit-id: ac80a5c6a6
2019-03-19 22:04:33 -04:00
John Sully 6cdb35815d Add release badge
Former-commit-id: c74100a552
2019-03-19 20:54:36 -04:00
John Sully 3b6b85c986 Add CI badge
Former-commit-id: 03379106d6
2019-03-19 20:46:25 -04:00
John Sully c278e61f95 Getting close! Maybe there was a better way to do this than checking in travis.yml files repeatedly but alas it works and doesn't affect people building locally
Former-commit-id: 9ad229f663
2019-03-19 20:40:17 -04:00
John Sully 003e64ec42 Clang build with libc malloc
Former-commit-id: 0900edf776
2019-03-19 20:34:09 -04:00
John Sully b4abddc275 more clang travis fixes
Former-commit-id: ea520027b9
2019-03-19 20:26:35 -04:00
John Sully 9c5fcadc5f Fix race condition building dependencies with multithreaded builds
Former-commit-id: 04679b3b3b
2019-03-19 20:25:30 -04:00
John Sully d80f576f77 Will clang build now with travis?
Former-commit-id: 2bf5c1324a
2019-03-19 20:00:52 -04:00
John Sully c0fbc6d2d9 clang build failure
Former-commit-id: 3d93ca1bf6
2019-03-19 19:55:03 -04:00
John Sully 5a72c7e227 Travis clang dependencies
Former-commit-id: c548431611
2019-03-19 19:50:28 -04:00
John Sully ac7d52cc7a Makefile ignores env CXXFLAGS
Former-commit-id: 0ab29f7394
2019-03-19 19:29:14 -04:00
John Sully c6646d729b No underscore
Former-commit-id: 30dab7ad14
2019-03-19 19:22:27 -04:00
John Sully 1a5ec3b15b Maybe this will make travis-ci stop using GCC headers when compiling with clang
Former-commit-id: 0c5fa59221
2019-03-19 19:12:15 -04:00
John Sully 1508a46c3b Feature gate SO_INCOMING_CPU so we compile on older kernels
Former-commit-id: 267e84f97d
2019-03-19 18:55:42 -04:00
John Sully 25a69f235d typo
Former-commit-id: 344cca75c6
2019-03-19 18:40:50 -04:00
John Sully 3874f86a65 It would be nice if our CI actually called make...
Former-commit-id: 0dd8e682f4
2019-03-19 18:37:53 -04:00
John Sully b846324019 Fix issues with travis config
Former-commit-id: da7e54819a
2019-03-19 18:31:45 -04:00
John Sully 431667dd08 Let's try travis-ci
Former-commit-id: 4e70215307
2019-03-19 18:27:54 -04:00
John 9066cfd682 Fix linker errors on some compilers due to sdslen()
Former-commit-id: 6aa162f6ff
2019-03-19 22:08:20 +00:00
John Sully b195ff4977 KeyDB has different aims than the Redis project.
We believe software is for the user.  If a feature requires complicating the codebase
but simplifies our user's lives we will do it any time.  This should not be taken
as an outright rejection of the manifesto, as we agree on many points.


Former-commit-id: d380074569
2019-03-19 01:36:03 -04:00
John Sully 571b2ab9de Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: c406e7ff51
2019-03-19 01:26:22 -04:00
John Sully b0387a5c93 Merge branch 'unstable' of https://github.com/antirez/redis into unstable
Former-commit-id: 31ff6cffee
2019-03-19 01:26:10 -04:00
John Sully 92dc1bed13 Hack to prevent build errors on some machines due to missing throw()
Former-commit-id: a9e525c81e
2019-03-15 05:28:20 +00:00
John Sully f25d4bf94e Merge /home/john/repos/redis_clean into unstable
Former-commit-id: 6157a5fc1b
2019-03-14 14:22:41 -04:00
John Sully aa76a89a9a Merge branch 'unstable' of https://github.com/antirez/redis into unstable
Former-commit-id: be3cb1ad33
2019-03-14 14:22:27 -04:00
John Sully cb365ece10 Fix hyperloglog corruption 2019-03-14 14:02:16 -04:00
John Sully 0c7bb3d208 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 966f4a8144
2019-03-13 18:08:59 -04:00
John Sully 6702b89166 Merge branch 'unstable' of https://github.com/antirez/redis into unstable
Lots of fixes and improvements from upstream.


Former-commit-id: 261cf24efc
2019-03-13 18:08:22 -04:00
JohnSully 7703340a65 Update README.md
Former-commit-id: a3da10f4eb
2019-03-13 16:57:40 -04:00
John Sully 06f8eb0571 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 6cb8063497
2019-03-13 16:53:55 -04:00
John Sully d0de467103 Implement load database dumps from S3. We already save.
Former-commit-id: a45f212693
2019-03-13 16:53:37 -04:00
JohnSully 4e584a1c60 Merge pull request #9 from 0xflotus/patch-1
fixed guarantees

Former-commit-id: 7c72cd5471
2019-03-13 12:22:29 -04:00
0xflotus 8fdb99a23e fixed guarantees
Former-commit-id: 66f2032708
2019-03-13 15:14:34 +01:00
JohnSully be0a6672e4 Update README.md
Former-commit-id: 7546c7d8b4
2019-03-12 14:38:03 -04:00
JohnSully 89f9a9fea6 formatting fixes
Former-commit-id: 703e4ad2fe
2019-03-12 00:59:28 -04:00
JohnSully aab69c02cb Add charts to readme
Hotlink from medium, hope they don't mind.

Former-commit-id: 0b98280a1f
2019-03-12 00:55:03 -04:00
John Sully 1d96e74069 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into RELEASE_0_9
Former-commit-id: 4609bed6a4
2019-03-11 20:54:14 -04:00
John Sully c56b68f9a5 Werror is good for me, but not for people compiling on other compilers
Former-commit-id: 99ccb11d89
2019-03-11 20:53:57 -04:00
JohnSully ff4d105d55 Explain how multithreading works
Former-commit-id: 8a5a513662
2019-03-11 20:37:57 -04:00
JohnSully e59b6b5469 Update README.md
Former-commit-id: bf0fd22309
2019-03-11 19:38:20 -04:00
John Sully 94319db950 Make storage.h C++ safe
Former-commit-id: cc98d10fc6
2019-03-09 13:42:08 -05:00
John Sully 02b23107cc sizeof is too big
Former-commit-id: a6a022faa2
2019-03-09 13:41:49 -05:00
John Sully 778a48b574 bump version
Former-commit-id: a864ad1c9c
2019-03-07 19:13:59 -05:00
John Sully 38fd0476d5 Merge branch 'unstable' into RELEASE_0_9
Former-commit-id: 0bc586933f
2019-03-07 19:13:33 -05:00
John Sully 25c2050c3a Module threading fixes
Former-commit-id: 2785a8b4d4
2019-03-07 19:13:01 -05:00
John Sully 13de2e2e8b Merge branch 'unstable' into RELEASE_0_9
Former-commit-id: d5d5f6ae06
2019-03-06 16:39:15 -05:00
John Sully 2d19319915 Limit server-threads to cores in the machine
Former-commit-id: be3ba1d53e
2019-03-06 16:39:02 -05:00
John Sully d1c93ee8e1 port server.c to server.cpp
Former-commit-id: 09e6a4fee0
2019-03-06 16:29:30 -05:00
John Sully 698c085f82 Set version
Former-commit-id: efc60dd8c5
2019-03-06 15:25:28 -05:00
John Sully 809cbfd495 Don't send replies to slaves after we've queued them to be closed
Former-commit-id: a52cd974b9
2019-03-06 15:21:05 -05:00
John Sully 9a615a4850 defer free
Former-commit-id: de4217489c
2019-03-05 15:46:19 -05:00
John Sully 459e6adb83 Fix crash with paused clients (accessed when global lock is not acquired)
Former-commit-id: 3c658b5012
2019-03-03 22:24:12 -05:00
John Sully 93ac479418 Crash in Memory Doctor when all clients are slaves
Former-commit-id: f6814aa825
2019-03-03 13:56:47 -05:00
John Sully fbf4e190ce Fix issue #2, check posix return values
Former-commit-id: 01a529cbda
2019-03-02 20:43:03 -05:00
John Sully 5ee7a6b8f1 sds copies uninitialized data wasting time for everyone
Former-commit-id: a1475af1e4
2019-03-02 19:27:52 -05:00
John Sully a8dacb0046 Merge branch 'unstable' of https://github.com/antirez/redis into unstable
We want that awesome multithreaded benchmark


Former-commit-id: 07594d4f95
2019-03-02 18:07:18 -05:00
John Sully 8f452efca3 write fastlock_unlock in ASM... because its faster
Former-commit-id: bad73faf28
2019-03-02 16:47:27 -05:00
John Sully 9fe635fc3c Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 8d3704d93b
2019-03-01 16:40:20 -05:00
John Sully e868502b16 tighten up the spinlock loop, and some other bikeshedding
Former-commit-id: 8bd56fadd6
2019-03-01 13:29:21 -05:00
John Sully fe6fe08ad1 remove unnecessary logs
Former-commit-id: 23f9b584a8
2019-02-28 13:57:58 -05:00
JohnSully e77fdf5ea0 Update README.md
Former-commit-id: 141557963e
2019-02-26 15:16:46 -05:00
John Sully 5c64ba23ca Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: ffabf3c5b7
2019-02-26 15:14:50 -05:00
John Sully 8db15e9666 Thread affinity feature (default disabled)
Former-commit-id: 9b1e95809c
2019-02-26 15:14:35 -05:00
JohnSully 85a8158ae8 Link to detailed benchmarking results and methodology.
Former-commit-id: b8776bb001
2019-02-26 15:11:25 -05:00
JohnSully b7dcd0b567 More fine tuning help. Hopefully we can automate this.
Former-commit-id: 84c20e8337
2019-02-26 03:30:37 -05:00
JohnSully f1b8f76167 Update benchmarking notes.
Former-commit-id: bae2409cce
2019-02-26 02:30:03 -05:00
John Sully f474419764 test code shouldn't be commited
Former-commit-id: 8f7c44257b
2019-02-26 00:21:37 -05:00
John Sully 16f5a47c5f Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 2772ce249c
2019-02-26 00:20:11 -05:00
John Sully be82e98799 writes shouldn't be under the global lock
Former-commit-id: bcfd9327cb
2019-02-26 00:19:38 -05:00
John Sully f019a3b69e Option to disable ASM spinlock
Former-commit-id: 01ff36fc28
2019-02-26 00:00:04 -05:00
John Sully 3ca6b6f9a2 Fix build break
Former-commit-id: 6466b09fdc
2019-02-26 01:10:07 +00:00
John Sully f446785084 Rewrite our spinlock in assembly, pretty big performance improvement
Former-commit-id: 40d7a701fe
2019-02-25 18:21:27 -05:00
JohnSully 9b186a5895 Formatting (more)
Former-commit-id: 78b9d303d3
2019-02-23 03:08:24 -05:00
John Sully 34e7dcd9a5 Update copyright to include additional authorship
Former-commit-id: d912013d1b
2019-02-23 02:27:19 -05:00
John Sully a3c3773e68 Merge branch 'unstable' of https://github.com/JohnSully/redis2 into unstable
Former-commit-id: 898e6519d1
2019-02-23 02:25:00 -05:00
John Sully 677391bd77 Merge branch 'Multithread' into unstable
Former-commit-id: 8c074a7d01
2019-02-23 02:24:23 -05:00
John Sully f97f602f77 Support configurable number of threads 2019-02-23 01:51:04 -05:00
John Sully 84f38452e5 Support a non-spinlock mutex if compiled in 2019-02-23 01:50:02 -05:00
JohnSully 8f32bbfa13 More edits
Former-commit-id: 6e69b4a795
2019-02-23 01:48:05 -05:00
JohnSully 5f27820d5d type
Former-commit-id: 1c36b46cb4
2019-02-23 01:33:27 -05:00
JohnSully 88fe444538 Formatting
Former-commit-id: 73abd04b95
2019-02-23 01:32:50 -05:00
JohnSully 0e4d1d8462 Initial rewrite of Readme
Former-commit-id: 29d6845d1f
2019-02-23 01:28:44 -05:00
John Sully 554012085c All tests pass single thread 2019-02-23 00:09:34 -05:00
John Sully cfabd4f666 Fix failure to trim querybuf (and memory tests that fail because of it) 2019-02-22 22:09:25 -05:00
John Sully 906308d728 Fix EMBSTR corruption 2019-02-22 21:32:43 -05:00
John Sully 131518da62 Missing file from merge 2019-02-22 21:16:50 -05:00
John Sully 08723fc9d4 Disable RTTI, we don't need it 2019-02-22 21:16:27 -05:00
John Sully 5539e7522a Merge branch 'unstable' of https://github.com/antirez/redis into Multithread 2019-02-22 21:16:10 -05:00
John Sully dbd82f6bfc Lock use after free 2019-02-22 21:00:14 -05:00
John Sully 174e9fe809 fix corruption in object size optimization 2019-02-22 17:45:50 -05:00
John Sully 6c6d913a86 Remove unnecessary mfences 2019-02-22 15:49:22 -05:00
John Sully 30e8a859c0 Prevent mixed up client replies, and deadlocks 2019-02-22 01:24:16 -05:00
John Sully 2788cf57b0 Implement try_lock 2019-02-22 01:23:31 -05:00
John Sully 8cd2cdca3d Merge branch 'unstable' of https://github.com/antirez/redis into Multithread 2019-02-21 18:17:12 -05:00
John Sully d1c3ee3891 Change default back to jemalloc (until defrag is implemented) and fix compile errors 2019-02-21 01:36:38 -05:00
John Sully cd0ccdde8e Don't commit core dumps 2019-02-21 00:43:09 -05:00
John Sully 05e421b23b Rebrand more strings visible on console, we're not allowed to call ourselves Redis 2019-02-21 00:24:03 -05:00
John Sully 722e46d8a8 Update copyright notice on files heavily changed 2019-02-21 00:17:07 -05:00
John Sully d48cf2494d Change fastlock implementation from naive spinlock to a ticket lock for better fairness and lower peak latency 2019-02-21 00:16:47 -05:00
John Sully 8e8abb2ff9 Cleanup lock contention, and ensure clients are written to in an unsafe way when the global lock is released 2019-02-20 23:30:21 -05:00
John Sully 627c19e02f Multithreading works! 2019-02-20 01:20:26 -05:00
John Sully c1031e5f98 Prevent erroneously setting CLIENT_PENDING_WRITE when we have async writes 2019-02-19 01:37:16 -05:00
John Sully 3f4315125c Most tests failing, except some memory and number of PSYNC syncs 2019-02-19 01:11:00 -05:00
John Sully e9a2b6f561 deadlock fixes 2019-02-18 23:52:21 -05:00
John Sully 0914b52ffa Thread safety fixes 2019-02-18 22:25:35 -05:00
John Sully e9c1d30749 Extra AE functionality 2019-02-18 18:56:45 -05:00
John Sully 65e48b868e Load balance connections across threads (config NYI and hardcoded) 2019-02-16 14:26:19 -05:00
John Sully c0eb2e5193 Fix recursive fastlock... 2019-02-16 14:25:14 -05:00
John Sully 90c6c37628 make headers C++ safe 2019-02-15 16:55:40 -05:00
John Sully 05685ed792 mitigate race condition in test 2019-02-15 16:55:19 -05:00
John Sully aed915cebc make networking.c a C++ file 2019-02-15 14:11:34 -05:00
John Sully 8b7e441997 Make the lock recursive, this is because processEventsWhileBlocked may cause us to lock multiple times 2019-02-15 14:11:05 -05:00
John Sully 0f293d4fb0 Fix most failing tests 2019-02-15 10:53:32 -05:00
John Sully 6059bc7e67 Initial work of multithreaded key-db. Note: Fails tests 2019-02-11 03:36:18 -05:00
John Sully 3751d2b737 Fastlock fixes
Former-commit-id: da84b26785
2019-02-10 22:00:19 -05:00
John Sully eefa3e9168 Fastlock fixes 2019-02-10 22:00:19 -05:00
John Sully ffad5f32bc move ae to C++
Former-commit-id: eb9070c833
2019-02-10 20:24:11 -05:00
John Sully bd46c2041e move ae to C++ 2019-02-10 20:24:11 -05:00
John Sully e86543a00e Keep pool allocator up to date (even though we aren't enabling it)
Former-commit-id: b7b503d3ce
2019-02-10 19:33:07 -05:00
John Sully 32d0b3141a Keep pool allocator up to date (even though we aren't enabling it) 2019-02-10 19:33:07 -05:00
John Sully 6914dafd6c Prevent so many copies of sdslen getting added
Former-commit-id: 327bbec981
2019-02-10 19:31:46 -05:00
John Sully adabbca14b Prevent so many copies of sdslen getting added 2019-02-10 19:31:46 -05:00
John Sully f1fc8edb77 Performance enhancements!
Former-commit-id: 7175a8e4eb
2019-02-09 13:05:06 -05:00
John Sully 5be3566838 Performance enhancements! 2019-02-09 13:05:06 -05:00
John Sully 4059814245 Reduce memory usage for in place strings by 8 bytes
Former-commit-id: 9aefc183c6
2019-02-09 13:04:18 -05:00
John Sully f6736cd713 Reduce memory usage for in place strings by 8 bytes 2019-02-09 13:04:18 -05:00
John Sully 219b0f7441 complete rebranding with tests passing
Former-commit-id: 3e9b867709
2019-02-09 10:11:46 -05:00
John Sully dac1213462 complete rebranding with tests passing 2019-02-09 10:11:46 -05:00
John Sully 3f9736a654 Fix bug where we try to load a database with no name
Former-commit-id: e8b5bbf7a1
2019-02-09 07:56:45 -05:00
John Sully 5420f93de9 Fix bug where we try to load a database with no name 2019-02-09 07:56:45 -05:00
John Sully 8e0450c32e remove Redis branding
Former-commit-id: 79ef18e885
2019-02-08 17:56:32 -05:00
John Sully cedd67eaff remove Redis branding 2019-02-08 17:56:32 -05:00
John Sully 2fc7811a28 Support AWS S3 saving via the s3 cli tools
Former-commit-id: 23a91df9f6
2019-02-06 01:06:48 -05:00
John Sully 564dabd0a2 Support AWS S3 saving via the s3 cli tools 2019-02-06 01:06:48 -05:00
John Sully d2aa6471e5 Merge branch 'unstable' of https://github.com/antirez/redis into unstable
Former-commit-id: d8741595ae
2019-02-06 00:09:39 -05:00
John Sully ef310bc7f8 Merge branch 'unstable' of https://github.com/antirez/redis into unstable 2019-02-06 00:09:39 -05:00
John Sully b660bfb6dd Make main headers C++ safe, and change rdb to use file descriptor instead of FILE pointer
Former-commit-id: 3c9dd6ffc2
2019-02-05 23:36:40 -05:00
John Sully cd8145e314 Make main headers C++ safe, and change rdb to use file descriptor instead of FILE pointer 2019-02-05 23:36:40 -05:00
John Sully 979eb00220 complete malloc memory class work, and pass tests
Former-commit-id: 42d28c9ff6
2019-02-04 16:56:13 -05:00
John Sully 3e61388df3 complete malloc memory class work, and pass tests 2019-02-04 16:56:13 -05:00
John Sully bb9f3eeb13 Properly integrate memkind
Former-commit-id: 82372cbce8
2019-02-01 15:21:00 -05:00
John Sully e28d9adeee Properly integrate memkind 2019-02-01 15:21:00 -05:00
John Sully 833006226d Merge commit '09a263e6076b3fd0fe3b094a2bfad7f93fc997d6' as 'deps/memkind/src'
Former-commit-id: 69b07c5cc2
2019-02-01 14:45:39 -05:00
John Sully b80f8ec79b Merge commit '09a263e6076b3fd0fe3b094a2bfad7f93fc997d6' as 'deps/memkind/src' 2019-02-01 14:45:39 -05:00
John Sully 09a263e607 Squashed 'deps/memkind/src/' content from commit bb9f19dd1
git-subtree-dir: deps/memkind/src
git-subtree-split: bb9f19dd1b3ed6cc5e1b35919564ccf6f4b32f69
2019-02-01 14:45:39 -05:00
John Sully d5b4f7e2b8 template config
Former-commit-id: a6d27dc02c
2019-02-01 14:01:35 -05:00
John Sully 0a443027b8 template config 2019-02-01 14:01:35 -05:00
John Sully f243e3cc33 Support configurable file backed scratch
Former-commit-id: bbcaf48cb0
2019-02-01 13:54:59 -05:00
John Sully 4a84628bf0 Support configurable file backed scratch 2019-02-01 13:54:59 -05:00
John Sully c469d43d2b crash fixes
Former-commit-id: 85194d99da
2019-01-30 01:15:10 -05:00
John Sully eeca73efc5 crash fixes 2019-01-30 01:15:10 -05:00
John Sully 9b94405241 Custom flash heap
Former-commit-id: 5c86d2faa2
2019-01-29 18:10:46 -05:00
John Sully bac51d5ac4 Custom flash heap 2019-01-29 18:10:46 -05:00
1055 changed files with 193343 additions and 19405 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
---
name: Bug report
about: Help us improve Redis by reporting a bug
about: Help us improve KeyDB by reporting a bug
title: '[BUG]'
labels: ''
assignees: ''
+1 -1
View File
@@ -1,6 +1,6 @@
---
name: Feature request
about: Suggest a feature for Redis
about: Suggest a feature for KeyDB
title: '[NEW]'
labels: ''
assignees: ''
-21
View File
@@ -1,21 +0,0 @@
---
name: Question
about: Ask the Redis developers
title: '[QUESTION]'
labels: ''
assignees: ''
---
Please keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server.
Generally, questions about using Redis should be directed to the [community](https://redis.io/community):
* [the mailing list](https://groups.google.com/forum/#!forum/redis-db)
* [the `redis` tag at StackOverflow](http://stackoverflow.com/questions/tagged/redis)
* [/r/redis subreddit](http://www.reddit.com/r/redis)
* [the irc channel #redis](http://webchat.freenode.net/?channels=redis) on freenode
It is also possible that your question was already asked here, so please do a quick issues search before submitting. Lastly, if your question is about one of Redis' [clients](https://redis.io/clients), you may to contact your client's developers for help.
That said, please feel free to replace all this with your question :)
+36 -30
View File
@@ -9,52 +9,58 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: make
# Fail build if there are warnings
# build with TLS just for compilation coverage
run: make REDIS_CFLAGS='-Werror' BUILD_TLS=yes
- name: test
run: |
sudo apt-get install tcl8.6
./runtest --verbose
- name: module api test
run: ./runtest-moduleapi --verbose
sudo apt-get update
sudo apt-get -y install uuid-dev libcurl4-openssl-dev
make KEYDB_CFLAGS='-Werror' KEYDB_CXXFLAGS='-Werror' BUILD_TLS=yes -j2
- name: gen-cert
run: ./utils/gen-test-certs.sh
- name: test-tls
run: |
sudo apt-get -y install tcl tcl-tls
./runtest --clients 2 --verbose --tls
- name: cluster-test
run: |
./runtest-cluster --tls
- name: sentinel test
run: |
./runtest-sentinel
- name: module tests
run: |
./runtest-moduleapi
build-ubuntu-old:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: make
run: make REDIS_CFLAGS='-Werror'
- uses: actions/checkout@v1
- name: make -j2
run: |
sudo apt-get update
sudo apt-get -y install uuid-dev libcurl4-openssl-dev
make -j2
build-macos-latest:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: make
run: make REDIS_CFLAGS='-Werror'
build-32bit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: make
run: |
sudo apt-get update && sudo apt-get install libc6-dev-i386
make REDIS_CFLAGS='-Werror' 32bit
run: make KEYDB_CFLAGS='-Werror' KEYDB_CXXFLAGS='-Werror' -j2
build-libc-malloc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: make
run: make REDIS_CFLAGS='-Werror' MALLOC=libc
build-centos7-jemalloc:
run: |
sudo apt-get update
sudo apt-get -y install uuid-dev libcurl4-openssl-dev
make KEYDB_CFLAGS='-Werror' KEYDB_CXXFLAGS='-Werror' MALLOC=libc -j2
build-ubuntu-32bit:
runs-on: ubuntu-latest
container: centos:7
steps:
- uses: actions/checkout@v2
- name: make
run: |
yum -y install gcc make
make REDIS_CFLAGS='-Werror'
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get -y install gcc-multilib g++-multilib libc6-dev-i386 lib32z1 uuid-dev:i386 libcurl4-openssl-dev:i386
make KEYDB_CFLAGS='-Werror' KEYDB_CXXFLAGS='-Werror' 32bit -j2
-308
View File
@@ -1,308 +0,0 @@
name: Daily
on:
pull_request:
branches:
# any PR to a release branch.
- '[0-9].[0-9]'
schedule:
- cron: '0 0 * * *'
jobs:
test-ubuntu-jemalloc:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: make REDIS_CFLAGS='-Werror -DREDIS_TEST'
- name: test
run: |
sudo apt-get install tcl8.6
./runtest --accurate --verbose --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
- name: unittest
run: ./src/redis-server test all
test-ubuntu-libc-malloc:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: make MALLOC=libc
- name: test
run: |
sudo apt-get install tcl8.6
./runtest --accurate --verbose --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
test-ubuntu-no-malloc-usable-size:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: make MALLOC=libc CFLAGS=-DNO_MALLOC_USABLE_SIZE
- name: test
run: |
sudo apt-get install tcl8.6
./runtest --accurate --verbose --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
test-ubuntu-32bit:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: |
sudo apt-get update && sudo apt-get install libc6-dev-i386
make 32bit REDIS_CFLAGS='-Werror -DREDIS_TEST'
- name: test
run: |
sudo apt-get install tcl8.6
./runtest --accurate --verbose --dump-logs
- name: module api test
run: |
make -C tests/modules 32bit # the script below doesn't have an argument, we must build manually ahead of time
./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
- name: unittest
run: ./src/redis-server test all
test-ubuntu-tls:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: |
make BUILD_TLS=yes
- name: test
run: |
sudo apt-get install tcl8.6 tcl-tls
./utils/gen-test-certs.sh
./runtest --accurate --verbose --tls --dump-logs
./runtest --accurate --verbose --dump-logs
- name: module api test
run: |
./runtest-moduleapi --verbose --tls
./runtest-moduleapi --verbose
- name: sentinel tests
run: |
./runtest-sentinel --tls
./runtest-sentinel
- name: cluster tests
run: |
./runtest-cluster --tls
./runtest-cluster
test-ubuntu-io-threads:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: |
make
- name: test
run: |
sudo apt-get install tcl8.6 tcl-tls
./runtest --config io-threads 4 --config io-threads-do-reads yes --accurate --verbose --tags network --dump-logs
- name: cluster tests
run: |
./runtest-cluster --config io-threads 4 --config io-threads-do-reads yes
test-valgrind:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: make valgrind REDIS_CFLAGS='-Werror -DREDIS_TEST'
- name: test
run: |
sudo apt-get update
sudo apt-get install tcl8.6 valgrind -y
./runtest --valgrind --verbose --clients 1 --tags -large-memory --dump-logs
- name: module api test
run: ./runtest-moduleapi --valgrind --no-latency --verbose --clients 1
- name: unittest
run: |
valgrind --track-origins=yes --suppressions=./src/valgrind.sup --show-reachable=no --show-possibly-lost=no --leak-check=full --log-file=err.txt ./src/redis-server test all
if grep -q 0x err.txt; then cat err.txt; exit 1; fi
test-valgrind-no-malloc-usable-size:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: make valgrind CFLAGS="-DNO_MALLOC_USABLE_SIZE"
- name: test
run: |
sudo apt-get update
sudo apt-get install tcl8.6 valgrind -y
./runtest --valgrind --verbose --clients 1 --tags -large-memory --dump-logs
- name: module api test
run: ./runtest-moduleapi --valgrind --no-latency --verbose --clients 1
test-centos7-jemalloc:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
container: centos:7
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: |
yum -y install gcc make
make
- name: test
run: |
yum -y install which tcl
./runtest --accurate --verbose --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
test-centos7-tls:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
container: centos:7
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: |
yum -y install centos-release-scl epel-release
yum -y install devtoolset-7 openssl-devel openssl
scl enable devtoolset-7 "make BUILD_TLS=yes"
- name: test
run: |
yum -y install tcl tcltls
./utils/gen-test-certs.sh
./runtest --accurate --verbose --tls --dump-logs
./runtest --accurate --verbose --dump-logs
- name: module api test
run: |
./runtest-moduleapi --verbose --tls
./runtest-moduleapi --verbose
- name: sentinel tests
run: |
./runtest-sentinel --tls
./runtest-sentinel
- name: cluster tests
run: |
./runtest-cluster --tls
./runtest-cluster
test-macos-latest:
runs-on: macos-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: make
run: make
- name: test
run: |
./runtest --accurate --verbose --no-latency --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
test-freebsd:
runs-on: macos-latest
if: github.repository == 'redis/redis'
timeout-minutes: 14400
steps:
- uses: actions/checkout@v2
- name: test
uses: vmactions/freebsd-vm@v0.1.4
with:
usesh: true
sync: rsync
prepare: pkg install -y bash gmake lang/tcl86
run: >
gmake &&
./runtest --accurate --verbose --no-latency --tags -large-memory --dump-logs &&
MAKE=gmake ./runtest-moduleapi --verbose &&
./runtest-sentinel &&
./runtest-cluster
test-alpine-jemalloc:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
container: alpine:latest
steps:
- uses: actions/checkout@v2
- name: make
run: |
apk add build-base
make REDIS_CFLAGS='-Werror'
- name: test
run: |
apk add tcl procps
./runtest --accurate --verbose --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
test-alpine-libc-malloc:
runs-on: ubuntu-latest
if: github.repository == 'redis/redis'
container: alpine:latest
steps:
- uses: actions/checkout@v2
- name: make
run: |
apk add build-base
make REDIS_CFLAGS='-Werror' USE_JEMALLOC=no CFLAGS=-DUSE_MALLOC_USABLE_SIZE
- name: test
run: |
apk add tcl procps
./runtest --accurate --verbose --dump-logs
- name: module api test
run: ./runtest-moduleapi --verbose
- name: sentinel tests
run: ./runtest-sentinel
- name: cluster tests
run: ./runtest-cluster
+24 -3
View File
@@ -1,14 +1,35 @@
.*.swp
core
*.o
*.xo
*.so
*.d
!**/bash_completion.d
!**/logrotate.d
!**/keydb.service.d
!**/keydb-sentinel.service.d
*.log
dump.rdb
src/keydb-server
**/bin/keydb-server
**/app/keydb-server
*.deb
*.rpm
src/keydb-cli
**/bin/keydb-cli
**/app/keydb-cli
src/keydb-sentinel
**/bin/keydb-sentinel
**/app/keydb-sentinel
redis-benchmark
keydb-benchmark
redis-check-aof
keydb-check-aof
redis-check-rdb
keydb-check-rdb
redis-check-dump
keydb-check-dump
keydb-diagnostic-tool
redis-cli
redis-sentinel
redis-server
@@ -22,12 +43,12 @@ release.h
src/transfer.sh
src/configs
redis.ds
src/redis.conf
src/keydb.conf
src/nodes.conf
deps/lua/src/lua
deps/lua/src/luac
deps/lua/src/liblua.a
tests/tls/*
tests/tls*/*
.make-*
.prerequisites
*.dSYM
@@ -37,4 +58,4 @@ Makefile.dep
.ccls
.ccls-cache/*
compile_commands.json
redis.code-workspace
keydb.code-workspace
+164
View File
@@ -0,0 +1,164 @@
.standard-pipeline:
rules:
- if: '$COVERAGE'
when: never
- if: '$ENDURANCE'
when: never
- if: '$CI_PIPELINE_SOURCE == "push"'
build:
extends: .standard-pipeline
tags:
- docker
stage: build
script:
- git submodule update --init
- make distclean
- make -j
artifacts:
paths:
- src/
runtest:
extends: .standard-pipeline
dependencies:
- build
tags:
- docker
stage: test
script:
- ./runtest --config server-threads 3
runtest-cluster:
extends: .standard-pipeline
dependencies:
- build
tags:
- docker
stage: test
script:
- ./runtest-cluster
runtest-moduleapi:
extends: .standard-pipeline
dependencies:
- build
tags:
- docker
stage: test
script:
- ./runtest-moduleapi
runtest-sentinel:
extends: .standard-pipeline
dependencies:
- build
tags:
- docker
stage: test
script:
- ./runtest-sentinel
node-redis-test:
extends: .standard-pipeline
dependencies:
- build
rules:
- when: never
tags:
- docker
- ipv6
stage: test
script:
- cp -pf src/keydb-server /usr/local/bin
- cp -pf src/keydb-cli /usr/local/bin
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.eqalpha.com/keydb-dev/node-redis.git
- cd node-redis
- npm install
- npm run test
jedis-test:
extends: .standard-pipeline
dependencies:
- build
tags:
- docker
- ipv4
stage: test
script:
- cp -pf src/keydb-server /usr/local/bin
- cp -pf src/keydb-cli /usr/local/bin
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.eqalpha.com/keydb-dev/jedis.git
- cd jedis
- make test
redis-rs-test:
extends: .standard-pipeline
dependencies:
- build
tags:
- docker
stage: test
script:
- cp -pf src/keydb-server /usr/local/bin
- cp -pf src/keydb-cli /usr/local/bin
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.eqalpha.com/keydb-dev/redis-rs.git
- cd redis-rs
- make test
endurance-test:
rules:
- if: '$ENDURANCE'
tags:
- docker
stage: test
script:
- git submodule update --init
- make distclean
- make -j
- ./runtest --config server-threads 3 --loop --stop
coverage-test:
rules:
- if: '$COVERAGE'
tags:
- docker
stage: test
script:
- git submodule update --init
- make distclean
- make gcov -j
- make install
- ./runtest || true
- pkill keydb-server || true
- pkill stunnel || true
- ./runtest-cluster || true
- pkill keydb-server || true
- pkill stunnel || true
- ./runtest-sentinel || true
- pkill keydb-server || true
- pkill stunnel || true
- ./runtest-moduleapi || true
- pkill keydb-server || true
- pkill stunnel || true
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.eqalpha.com/keydb-dev/redis-rs.git
- cd redis-rs
- make test || true
- pkill keydb-server || true
- pkill stunnel || true
- cd ..
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.eqalpha.com/keydb-dev/jedis.git
- cd jedis
- make test || true
- pkill keydb-server || true
- pkill stunnel || true
- cd ..
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.eqalpha.com/keydb-dev/node-redis.git
- cd node-redis
- npm install
- npm run test || true
- pkill keydb-server || true
- pkill stunnel || true
- cd ..
- geninfo -o KeyDB.info --no-external .
- genhtml --legend -o lcov-html KeyDB.info
+6
View File
@@ -0,0 +1,6 @@
[submodule "deps/rocksdb"]
path = deps/rocksdb
url = https://github.com/facebook/rocksdb.git
[submodule "deps/depot_tools"]
path = deps/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
-74
View File
@@ -1,74 +0,0 @@
Note: by contributing code to the Redis project in any form, including sending
a pull request via Github, a code fragment or patch via private email or
public discussion groups, you agree to release your code under the terms
of the BSD license that you can find in the COPYING file included in the Redis
source distribution. You will include BSD license in the COPYING file within
each source file that you contribute.
# IMPORTANT: HOW TO USE REDIS GITHUB ISSUES
Github issues SHOULD ONLY BE USED to report bugs, and for DETAILED feature
requests. Everything else belongs to the Redis Google Group:
https://groups.google.com/forum/m/#!forum/Redis-db
PLEASE DO NOT POST GENERAL QUESTIONS that are not about bugs or suspected
bugs in the Github issues system. We'll be very happy to help you and provide
all the support in the mailing list.
There is also an active community of Redis users at Stack Overflow:
http://stackoverflow.com/questions/tagged/redis
# Reporting Security Bugs
*If you are reporting a security bug*, please contact the core team privately
by emailing redis@redis.io. Your report will be acknowledged by a core team
member and once the report has been reviewed you will receive a more detailed
response including next steps.
If you do not receive a reply you can escalate to the Redis Google Group,
linked above. Because this group is a public space please do not disclose the
issue in detail, only say that you are trying to reach the core team for a
security issue.
Redis follows a responsible disclosure process:
1. Reports are reviewed and analyzed privately
2. Patches are prepared for supported versions of Redis
3. Vendor lists are notified with an embargo date to reduce the public impact
4. We push a fix release and your bug can be posted publicly with credit in
release notes and the version history (and our thanks!)
Issues and pull requests for documentation belong on the redis-doc repo:
https://github.com/redis/redis-doc
# How to provide a patch for a new feature
1. If it is a major feature or a semantical change, please don't start coding
straight away: if your feature is not a conceptual fit you'll lose a lot of
time writing the code without any reason. Start by posting in the mailing list
and creating an issue at Github with the description of, exactly, what you want
to accomplish and why. Use cases are important for features to be accepted.
Here you'll see if there is consensus about your idea.
2. If in step 1 you get an acknowledgment from the project leaders, use the
following procedure to submit a patch:
a. Fork Redis on github ( http://help.github.com/fork-a-repo/ )
b. Create a topic branch (git checkout -b my_branch)
c. Push to your branch (git push origin my_branch)
d. Initiate a pull request on github ( https://help.github.com/articles/creating-a-pull-request/ )
e. Done :)
3. Keep in mind that we are very overloaded, so issues and PRs sometimes wait
for a *very* long time. However this is not lack of interest, as the project
gets more and more users, we find ourselves in a constant need to prioritize
certain issues/PRs over others. If you think your issue/PR is very important
try to popularize it, have other users commenting and sharing their point of
view and so forth. This helps.
4. For minor fixes just open a pull request on Github.
Thanks!
+3
View File
@@ -1,4 +1,7 @@
Copyright (c) 2006-2020, Salvatore Sanfilippo
Copyright (C) 2019-2021, John Sully
Copyright (C) 2020-2021, EQ Alpha Technology Ltd.
Copyright (C) 2022 Snap Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-106
View File
@@ -1,106 +0,0 @@
[Note: this is the Redis manifesto, for general information about
installing and running Redis read the README file instead.]
Redis Manifesto
===============
1 - A DSL for Abstract Data Types. Redis is a DSL (Domain Specific Language)
that manipulates abstract data types and implemented as a TCP daemon.
Commands manipulate a key space where keys are binary-safe strings and
values are different kinds of abstract data types. Every data type
represents an abstract version of a fundamental data structure. For instance
Redis Lists are an abstract representation of linked lists. In Redis, the
essence of a data type isn't just the kind of operations that the data types
support, but also the space and time complexity of the data type and the
operations performed upon it.
2 - Memory storage is #1. The Redis data set, composed of defined key-value
pairs, is primarily stored in the computer's memory. The amount of memory in
all kinds of computers, including entry-level servers, is increasing
significantly each year. Memory is fast, and allows Redis to have very
predictable performance. Datasets composed of 10k or 40 millions keys will
perform similarly. Complex data types like Redis Sorted Sets are easy to
implement and manipulate in memory with good performance, making Redis very
simple. Redis will continue to explore alternative options (where data can
be optionally stored on disk, say) but the main goal of the project remains
the development of an in-memory database.
3 - Fundamental data structures for a fundamental API. The Redis API is a direct
consequence of fundamental data structures. APIs can often be arbitrary but
not an API that resembles the nature of fundamental data structures. If we
ever meet intelligent life forms from another part of the universe, they'll
likely know, understand and recognize the same basic data structures we have
in our computer science books. Redis will avoid intermediate layers in API,
so that the complexity is obvious and more complex operations can be
performed as the sum of the basic operations.
4 - We believe in code efficiency. Computers get faster and faster, yet we
believe that abusing computing capabilities is not wise: the amount of
operations you can do for a given amount of energy remains anyway a
significant parameter: it allows to do more with less computers and, at
the same time, having a smaller environmental impact. Similarly Redis is
able to "scale down" to smaller devices. It is perfectly usable in a
Raspberry Pi and other small ARM based computers. Faster code having
just the layers of abstractions that are really needed will also result,
often, in more predictable performances. We think likewise about memory
usage, one of the fundamental goals of the Redis project is to
incrementally build more and more memory efficient data structures, so that
problems that were not approachable in RAM in the past will be perfectly
fine to handle in the future.
5 - Code is like a poem; it's not just something we write to reach some
practical result. Sometimes people that are far from the Redis philosophy
suggest using other code written by other authors (frequently in other
languages) in order to implement something Redis currently lacks. But to us
this is like if Shakespeare decided to end Enrico IV using the Paradiso from
the Divina Commedia. Is using any external code a bad idea? Not at all. Like
in "One Thousand and One Nights" smaller self contained stories are embedded
in a bigger story, we'll be happy to use beautiful self contained libraries
when needed. At the same time, when writing the Redis story we're trying to
write smaller stories that will fit in to other code.
6 - We're against complexity. We believe designing systems is a fight against
complexity. We'll accept to fight the complexity when it's worthwhile but
we'll try hard to recognize when a small feature is not worth 1000s of lines
of code. Most of the time the best way to fight complexity is by not
creating it at all. Complexity is also a form of lock-in: code that is
very hard to understand cannot be modified by users in an independent way
regardless of the license. One of the main Redis goals is to remain
understandable, enough for a single programmer to have a clear idea of how
it works in detail just reading the source code for a couple of weeks.
7 - Threading is not a silver bullet. Instead of making Redis threaded we
believe on the idea of an efficient (mostly) single threaded Redis core.
Multiple of such cores, that may run in the same computer or may run
in multiple computers, are abstracted away as a single big system by
higher order protocols and features: Redis Cluster and the upcoming
Redis Proxy are our main goals. A shared nothing approach is not just
much simpler (see the previous point in this document), is also optimal
in NUMA systems. In the specific case of Redis it allows for each instance
to have a more limited amount of data, making the Redis persist-by-fork
approach more sounding. In the future we may explore parallelism only for
I/O, which is the low hanging fruit: minimal complexity could provide an
improved single process experience.
8 - Two levels of API. The Redis API has two levels: 1) a subset of the API fits
naturally into a distributed version of Redis and 2) a more complex API that
supports multi-key operations. Both are useful if used judiciously but
there's no way to make the more complex multi-keys API distributed in an
opaque way without violating our other principles. We don't want to provide
the illusion of something that will work magically when actually it can't in
all cases. Instead we'll provide commands to quickly migrate keys from one
instance to another to perform multi-key operations and expose the
trade-offs to the user.
9 - We optimize for joy. We believe writing code is a lot of hard work, and the
only way it can be worth is by enjoying it. When there is no longer joy in
writing code, the best thing to do is stop. To prevent this, we'll avoid
taking paths that will make Redis less of a joy to develop.
10 - All the above points are put together in what we call opportunistic
programming: trying to get the most for the user with minimal increases
in complexity (hanging fruits). Solve 95% of the problem with 5% of the
code when it is acceptable. Avoid a fixed schedule but follow the flow of
user requests, inspiration, Redis internal readiness for certain features
(sometimes many past changes reach a critical point making a previously
complex feature very easy to obtain).
+1 -1
View File
@@ -1,4 +1,4 @@
# Top level makefile, the real shit is at src/Makefile
# Top level makefile, this just calls into src/Makefile where the real work is done. Changes should be made there.
default: all
+164 -330
View File
@@ -1,63 +1,145 @@
This README is just a fast *quick start* document. You can find more detailed documentation at [redis.io](https://redis.io).
![Current Release](https://img.shields.io/github/release/JohnSully/KeyDB.svg)
![CI](https://github.com/JohnSully/KeyDB/workflows/CI/badge.svg?branch=unstable)
[![StackShare](http://img.shields.io/badge/tech-stack-0690fa.svg?style=flat)](https://stackshare.io/eq-alpha-technology-inc/eq-alpha-technology-inc)
What is Redis?
##### KeyDB is now a part of Snap Inc! Check out the announcement [here](https://docs.keydb.dev/news/2022/05/12/keydb-joins-snap)
##### [Release v6.3.0](https://github.com/EQ-Alpha/KeyDB/releases/tag/v6.3.0) is here with major improvements as we consolodate our Open Source and Enterprise offerings into a single BSD-3 licensed project. See our [roadmap](https://docs.keydb.dev/docs/coming-soon) for details.
##### Want to extend KeyDB with Javascript? Try [ModJS](https://github.com/JohnSully/ModJS)
##### Need Help? Check out our extensive [documentation](https://docs.keydb.dev).
##### KeyDB is on Slack. Click [here](https://docs.keydb.dev/slack/) to learn more and join the KeyDB Community Slack workspace.
What is KeyDB?
--------------
Redis is often referred to as a *data structures* server. What this means is that Redis provides access to mutable data structures via a set of commands, which are sent using a *server-client* model with TCP sockets and a simple protocol. So different processes can query and modify the same data structures in a shared way.
KeyDB is a high performance fork of Redis with a focus on multithreading, memory efficiency, and high throughput. In addition to performance improvements, KeyDB offers features such as Active Replication, FLASH Storage and Subkey Expires. KeyDB has a MVCC architecture that allows you to execute queries such as KEYS and SCAN without blocking the database and degrading performance.
Data structures implemented into Redis have a few special properties:
KeyDB maintains full compatibility with the Redis protocol, modules, and scripts. This includes the atomicity guarantees for scripts and transactions. Because KeyDB keeps in sync with Redis development KeyDB is a superset of Redis functionality, making KeyDB a drop in replacement for existing Redis deployments.
* Redis cares to store them on disk, even if they are always served and modified into the server memory. This means that Redis is fast, but that it is also non-volatile.
* The implementation of data structures emphasizes memory efficiency, so data structures inside Redis will likely use less memory compared to the same data structure modelled using a high-level programming language.
* Redis offers a number of features that are natural to find in a database, like replication, tunable levels of durability, clustering, and high availability.
On the same hardware KeyDB can achieve significantly higher throughput than Redis. Active-Replication simplifies hot-spare failover allowing you to easily distribute writes over replicas and use simple TCP based load balancing/failover. KeyDB's higher performance allows you to do more on less hardware which reduces operation costs and complexity.
Another good example is to think of Redis as a more complex version of memcached, where the operations are not just SETs and GETs, but operations that work with complex data types like Lists, Sets, ordered data structures, and so forth.
The chart below compares several KeyDB and Redis setups, including the latest Redis6 io-threads option, and TLS benchmarks.
If you want to know more, this is a list of selected starting points:
<img src="https://docs.keydb.dev/img/blog/2020-09-15/ops_comparison.png"/>
* Introduction to Redis data types. https://redis.io/topics/data-types-intro
* Try Redis directly inside your browser. http://try.redis.io
* The full list of Redis commands. https://redis.io/commands
* There is much more inside the official Redis documentation. https://redis.io/documentation
See the full benchmark results and setup information here: https://docs.keydb.dev/blog/2020/09/29/blog-post/
Building Redis
Why fork Redis?
---------------
KeyDB has a different philosophy on how the codebase should evolve. We feel that ease of use, high performance, and a "batteries included" approach is the best way to create a good user experience. While we have great respect for the Redis maintainers it is our opinion that the Redis approach focuses too much on simplicity of the code base at the expense of complexity for the user. This results in the need for external components and workarounds to solve common problems - resulting in more complexity overall.
Because of this difference of opinion features which are right for KeyDB may not be appropriate for Redis. A fork allows us to explore this new development path and implement features which may never be a part of Redis. KeyDB keeps in sync with upstream Redis changes, and where applicable we upstream bug fixes and changes. It is our hope that the two projects can continue to grow and learn from each other.
Project Support
-------------------
The KeyDB team maintains this project as part of Snap Inc. KeyDB is used by Snap as part of its caching infrastructure and is fully open sourced. There is no separate commercial product and no paid support options available. We really value collaborating with the open source community and welcome PRs, bug reports, and open discussion. For community support or to get involved further with the project check out our community support options [here](https://docs.keydb.dev/docs/support) (slack, forum, meetup, github issues). Our team monitors these channlels regularly.
Additional Resources
--------------------
Try the KeyDB [Docker Image](https://hub.docker.com/r/eqalpha/keydb)
Join us on [Slack](https://docs.keydb.dev/slack/)
Learn more using KeyDB's extensive [documentation](https://docs.keydb.dev)
Post to our [Community Forum](https://community.keydb.dev)
See the [KeyDB Roadmap](https://docs.keydb.dev/docs/coming-soon) to see what's in store
Benchmarking KeyDB
------------------
Please note keydb-benchmark and redis-benchmark are currently single threaded and too slow to properly benchmark KeyDB. We recommend using a redis cluster benchmark tool such as [memtier](https://github.com/RedisLabs/memtier_benchmark). Please ensure your machine has enough cores for both KeyDB and memtier if testing locally. KeyDB expects exclusive use of any cores assigned to it.
New Configuration Options
-------------------------
With new features comes new options. All other configuration options behave as you'd expect. Your existing configuration files should continue to work unchanged.
```
server-threads N
server-thread-affinity [true/false]
```
The number of threads used to serve requests. This should be related to the number of queues available in your network hardware, *not* the number of cores on your
machine. Because KeyDB uses spinlocks to reduce latency; making this too high will reduce performance. We recommend using 4 here. By default this is set to two.
```
min-clients-per-thread 50
```
The minimum number of clients on a thread before KeyDB assigns new connections to a different thread. Tuning this parameter is a tradeoff between locking overhead and distributing the workload over multiple cores
```
replica-weighting-factor 2
```
KeyDB will attempt to balance clients across threads evenly; However, replica clients are usually much more expensive than a normal client, and so KeyDB will try to assign fewer clients to threads with a replica. The weighting factor below is intented to help tune this behavior. A replica weighting factor of 2 means we treat a replica as the equivalent of two normal clients. Adjusting this value may improve performance when replication is used. The best weighting is workload specific - e.g. read heavy workloads should set this to 1. Very write heavy workloads may benefit from higher numbers.
```
active-client-balancing yes
```
Should KeyDB make active attempts at balancing clients across threads? This can impact performance accepting new clients. By default this is enabled. If disabled there is still a best effort from the kernel to distribute across threads with SO_REUSEPORT but it will not be as fair. By default this is enabled
```
active-replica yes
```
If you are using active-active replication set `active-replica` option to “yes”. This will enable both instances to accept reads and writes while remaining synced. [Click here](https://docs.keydb.dev/docs/active-rep/) to see more on active-rep in our docs section. There are also [docker examples]( https://docs.keydb.dev/docs/docker-active-rep/) on docs.
```
multi-master-no-forward no
```
Avoid forwarding RREPLAY messages to other masters? WARNING: This setting is dangerous! You must be certain all masters are connected to eachother in a true mesh topology or data loss will occur! This command can be used to reduce multimaster bus traffic
```
db-s3-object /path/to/bucket
```
If you would like KeyDB to dump and load directly to AWS S3 this option specifies the bucket. Using this option with the traditional RDB options will result in KeyDB backing up twice to both locations. If both are specified KeyDB will first attempt to load from the local dump file and if that fails load from S3. This requires the AWS CLI tools to be installed and configured which are used under the hood to transfer the data.
Building KeyDB
--------------
Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD.
We support big endian and little endian architectures, and both 32 bit
and 64 bit systems.
KeyDB can be compiled and is tested for use on Linux. KeyDB currently relies on SO_REUSEPORT's load balancing behavior which is available only in Linux. When we support marshalling connections across threads we plan to support other operating systems such as FreeBSD.
It may compile on Solaris derived systems (for instance SmartOS) but our
support for this platform is *best effort* and Redis is not guaranteed to
work as well as in Linux, OSX, and \*BSD.
More on CentOS/Archlinux/Alpine/Debian/Ubuntu dependencies and builds can be found here: https://docs.keydb.dev/docs/build/
It is as simple as:
Init and clone submodule dependencies:
% git submodule init && git submodule update
Install dependencies:
% sudo apt install build-essential nasm autotools-dev autoconf libjemalloc-dev tcl tcl-dev uuid-dev libcurl4-openssl-dev libbz2-dev libzstd-dev liblz4-dev libsnappy-dev libssl-dev
Compiling is as simple as:
% make
To build with TLS support, you'll need OpenSSL development libraries (e.g.
libssl-dev on Debian/Ubuntu) and run:
% make BUILD_TLS=yes
To build with systemd support, you'll need systemd development libraries (such
as libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS) and run:
% make USE_SYSTEMD=yes
To append a suffix to Redis program names, use:
To append a suffix to KeyDB program names, use:
% make PROG_SUFFIX="-alt"
You can build a 32 bit Redis binary using:
***Note that the following dependencies may be needed:
% sudo apt-get install autoconf autotools-dev libnuma-dev libtool
% make 32bit
To buik=ld with TLS support, use:
After building Redis, it is a good idea to test it using:
% make BUILD_TLS=yes
% make test
If TLS is built, running the tests with TLS enabled (you will need `tcl-tls`
Running the tests with TLS enabled (you will need `tcl-tls`
installed):
% ./utils/gen-test-certs.sh
@@ -67,7 +149,7 @@ installed):
Fixing build problems with dependencies or cached build options
---------
Redis has some dependencies which are included in the `deps` directory.
KeyDB has some dependencies which are included in the `deps` directory.
`make` does not automatically rebuild dependencies even if something in
the source code of dependencies changes.
@@ -87,11 +169,11 @@ command.
Fixing problems building 32 bit binaries
---------
If after building Redis with a 32 bit target you need to rebuild it
If after building KeyDB with a 32 bit target you need to rebuild it
with a 64 bit target, or the other way around, you need to perform a
`make distclean` in the root directory of the Redis distribution.
`make distclean` in the root directory of the KeyDB distribution.
In case of build errors when trying to build a 32 bit binary of Redis, try
In case of build errors when trying to build a 32 bit binary of KeyDB, try
the following steps:
* Install the package libc6-dev-i386 (also try g++-multilib).
@@ -101,8 +183,8 @@ the following steps:
Allocator
---------
Selecting a non-default memory allocator when building Redis is done by setting
the `MALLOC` environment variable. Redis is compiled and linked against libc
Selecting a non-default memory allocator when building KeyDB is done by setting
the `MALLOC` environment variable. KeyDB is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.
@@ -118,7 +200,7 @@ To compile against jemalloc on Mac OS X systems, use:
Monotonic clock
---------------
By default, Redis will build using the POSIX clock_gettime function as the
By default, KeyDB will build using the POSIX clock_gettime function as the
monotonic clock source. On most modern systems, the internal processor clock
can be used to improve performance. Cautions can be found here:
http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/
@@ -130,66 +212,68 @@ To build with support for the processor's internal instruction clock, use:
Verbose build
-------------
Redis will build with a user-friendly colorized output by default.
KeyDB will build with a user friendly colorized output by default.
If you want to see a more verbose output, use the following:
% make V=1
Running Redis
Running KeyDB
-------------
To run Redis with the default configuration, just type:
To run KeyDB with the default configuration, just type:
% cd src
% ./redis-server
% ./keydb-server
If you want to provide your redis.conf, you have to run it using an additional
If you want to provide your keydb.conf, you have to run it using an additional
parameter (the path of the configuration file):
% cd src
% ./redis-server /path/to/redis.conf
% ./keydb-server /path/to/keydb.conf
It is possible to alter the Redis configuration by passing parameters directly
It is possible to alter the KeyDB configuration by passing parameters directly
as options using the command line. Examples:
% ./redis-server --port 9999 --replicaof 127.0.0.1 6379
% ./redis-server /etc/redis/6379.conf --loglevel debug
% ./keydb-server --port 9999 --replicaof 127.0.0.1 6379
% ./keydb-server /etc/keydb/6379.conf --loglevel debug
All the options in redis.conf are also supported as options using the command
All the options in keydb.conf are also supported as options using the command
line, with exactly the same name.
Running Redis with TLS:
Running KeyDB with TLS:
------------------
Please consult the [TLS.md](TLS.md) file for more information on
how to use Redis with TLS.
how to use KeyDB with TLS.
Playing with Redis
Playing with KeyDB
------------------
You can use redis-cli to play with Redis. Start a redis-server instance,
You can use keydb-cli to play with KeyDB. Start a keydb-server instance,
then in another terminal try the following:
% cd src
% ./redis-cli
redis> ping
% ./keydb-cli
keydb> ping
PONG
redis> set foo bar
keydb> set foo bar
OK
redis> get foo
keydb> get foo
"bar"
redis> incr mycounter
keydb> incr mycounter
(integer) 1
redis> incr mycounter
keydb> incr mycounter
(integer) 2
redis>
keydb>
You can find the list of all the available commands at https://redis.io/commands.
You can find the list of all the available commands at https://docs.keydb.dev/docs/commands/
Installing Redis
Installing KeyDB
-----------------
In order to install Redis binaries into /usr/local/bin, just use:
In order to install KeyDB binaries into /usr/local/bin, just use:
% make install
@@ -198,7 +282,7 @@ different destination.
Make install will just install binaries in your system, but will not configure
init scripts and configuration files in the appropriate place. This is not
needed if you just want to play a bit with Redis, but if you are installing
needed if you just want to play a bit with KeyDB, but if you are installing
it the proper way for a production system, we have a script that does this
for Ubuntu and Debian systems:
@@ -208,280 +292,30 @@ for Ubuntu and Debian systems:
_Note_: `install_server.sh` will not work on Mac OSX; it is built for Linux only.
The script will ask you a few questions and will setup everything you need
to run Redis properly as a background daemon that will start again on
to run KeyDB properly as a background daemon that will start again on
system reboots.
You'll be able to stop and start Redis using the script named
`/etc/init.d/redis_<portnumber>`, for instance `/etc/init.d/redis_6379`.
You'll be able to stop and start KeyDB using the script named
`/etc/init.d/keydb_<portnumber>`, for instance `/etc/init.d/keydb_6379`.
Multithreading Architecture
---------------------------
KeyDB works by running the normal Redis event loop on multiple threads. Network IO, and query parsing are done concurrently. Each connection is assigned a thread on accept(). Access to the core hash table is guarded by spinlock. Because the hashtable access is extremely fast this lock has low contention. Transactions hold the lock for the duration of the EXEC command. Modules work in concert with the GIL which is only acquired when all server threads are paused. This maintains the atomicity guarantees modules expect.
Unlike most databases the core data structure is the fastest part of the system. Most of the query time comes from parsing the REPL protocol and copying data to/from the network.
Code contributions
-----------------
Note: By contributing code to the Redis project in any form, including sending
Note: by contributing code to the KeyDB project in any form, including sending
a pull request via Github, a code fragment or patch via private email or
public discussion groups, you agree to release your code under the terms
of the BSD license that you can find in the [COPYING][1] file included in the Redis
of the BSD license that you can find in the COPYING file included in the KeyDB
source distribution.
Please see the [CONTRIBUTING][2] file in this source distribution for more
information, including details on our process for security bugs/vulnerabilities.
Please see the CONTRIBUTING file in this source distribution for more
information.
[1]: https://github.com/redis/redis/blob/unstable/COPYING
[2]: https://github.com/redis/redis/blob/unstable/CONTRIBUTING
Redis internals
===
If you are reading this README you are likely in front of a Github page
or you just untarred the Redis distribution tar ball. In both the cases
you are basically one step away from the source code, so here we explain
the Redis source code layout, what is in each file as a general idea, the
most important functions and structures inside the Redis server and so forth.
We keep all the discussion at a high level without digging into the details
since this document would be huge otherwise and our code base changes
continuously, but a general idea should be a good starting point to
understand more. Moreover most of the code is heavily commented and easy
to follow.
Source code layout
---
The Redis root directory just contains this README, the Makefile which
calls the real Makefile inside the `src` directory and an example
configuration for Redis and Sentinel. You can find a few shell
scripts that are used in order to execute the Redis, Redis Cluster and
Redis Sentinel unit tests, which are implemented inside the `tests`
directory.
Inside the root are the following important directories:
* `src`: contains the Redis implementation, written in C.
* `tests`: contains the unit tests, implemented in Tcl.
* `deps`: contains libraries Redis uses. Everything needed to compile Redis is inside this directory; your system just needs to provide `libc`, a POSIX compatible interface and a C compiler. Notably `deps` contains a copy of `jemalloc`, which is the default allocator of Redis under Linux. Note that under `deps` there are also things which started with the Redis project, but for which the main repository is not `redis/redis`.
There are a few more directories but they are not very important for our goals
here. We'll focus mostly on `src`, where the Redis implementation is contained,
exploring what there is inside each file. The order in which files are
exposed is the logical one to follow in order to disclose different layers
of complexity incrementally.
Note: lately Redis was refactored quite a bit. Function names and file
names have been changed, so you may find that this documentation reflects the
`unstable` branch more closely. For instance, in Redis 3.0 the `server.c`
and `server.h` files were named `redis.c` and `redis.h`. However the overall
structure is the same. Keep in mind that all the new developments and pull
requests should be performed against the `unstable` branch.
server.h
---
The simplest way to understand how a program works is to understand the
data structures it uses. So we'll start from the main header file of
Redis, which is `server.h`.
All the server configuration and in general all the shared state is
defined in a global structure called `server`, of type `struct redisServer`.
A few important fields in this structure are:
* `server.db` is an array of Redis databases, where data is stored.
* `server.commands` is the command table.
* `server.clients` is a linked list of clients connected to the server.
* `server.master` is a special client, the master, if the instance is a replica.
There are tons of other fields. Most fields are commented directly inside
the structure definition.
Another important Redis data structure is the one defining a client.
In the past it was called `redisClient`, now just `client`. The structure
has many fields, here we'll just show the main ones:
```c
struct client {
int fd;
sds querybuf;
int argc;
robj **argv;
redisDb *db;
int flags;
list *reply;
char buf[PROTO_REPLY_CHUNK_BYTES];
// ... many other fields ...
}
```
The client structure defines a *connected client*:
* The `fd` field is the client socket file descriptor.
* `argc` and `argv` are populated with the command the client is executing, so that functions implementing a given Redis command can read the arguments.
* `querybuf` accumulates the requests from the client, which are parsed by the Redis server according to the Redis protocol and executed by calling the implementations of the commands the client is executing.
* `reply` and `buf` are dynamic and static buffers that accumulate the replies the server sends to the client. These buffers are incrementally written to the socket as soon as the file descriptor is writeable.
As you can see in the client structure above, arguments in a command
are described as `robj` structures. The following is the full `robj`
structure, which defines a *Redis object*:
typedef struct redisObject {
unsigned type:4;
unsigned encoding:4;
unsigned lru:LRU_BITS; /* lru time (relative to server.lruclock) */
int refcount;
void *ptr;
} robj;
Basically this structure can represent all the basic Redis data types like
strings, lists, sets, sorted sets and so forth. The interesting thing is that
it has a `type` field, so that it is possible to know what type a given
object has, and a `refcount`, so that the same object can be referenced
in multiple places without allocating it multiple times. Finally the `ptr`
field points to the actual representation of the object, which might vary
even for the same type, depending on the `encoding` used.
Redis objects are used extensively in the Redis internals, however in order
to avoid the overhead of indirect accesses, recently in many places
we just use plain dynamic strings not wrapped inside a Redis object.
server.c
---
This is the entry point of the Redis server, where the `main()` function
is defined. The following are the most important steps in order to startup
the Redis server.
* `initServerConfig()` sets up the default values of the `server` structure.
* `initServer()` allocates the data structures needed to operate, setup the listening socket, and so forth.
* `aeMain()` starts the event loop which listens for new connections.
There are two special functions called periodically by the event loop:
1. `serverCron()` is called periodically (according to `server.hz` frequency), and performs tasks that must be performed from time to time, like checking for timed out clients.
2. `beforeSleep()` is called every time the event loop fired, Redis served a few requests, and is returning back into the event loop.
Inside server.c you can find code that handles other vital things of the Redis server:
* `call()` is used in order to call a given command in the context of a given client.
* `activeExpireCycle()` handles eviction of keys with a time to live set via the `EXPIRE` command.
* `performEvictions()` is called when a new write command should be performed but Redis is out of memory according to the `maxmemory` directive.
* The global variable `redisCommandTable` defines all the Redis commands, specifying the name of the command, the function implementing the command, the number of arguments required, and other properties of each command.
networking.c
---
This file defines all the I/O functions with clients, masters and replicas
(which in Redis are just special clients):
* `createClient()` allocates and initializes a new client.
* the `addReply*()` family of functions are used by command implementations in order to append data to the client structure, that will be transmitted to the client as a reply for a given command executed.
* `writeToClient()` transmits the data pending in the output buffers to the client and is called by the *writable event handler* `sendReplyToClient()`.
* `readQueryFromClient()` is the *readable event handler* and accumulates data read from the client into the query buffer.
* `processInputBuffer()` is the entry point in order to parse the client query buffer according to the Redis protocol. Once commands are ready to be processed, it calls `processCommand()` which is defined inside `server.c` in order to actually execute the command.
* `freeClient()` deallocates, disconnects and removes a client.
aof.c and rdb.c
---
As you can guess from the names, these files implement the RDB and AOF
persistence for Redis. Redis uses a persistence model based on the `fork()`
system call in order to create a thread with the same (shared) memory
content of the main Redis thread. This secondary thread dumps the content
of the memory on disk. This is used by `rdb.c` to create the snapshots
on disk and by `aof.c` in order to perform the AOF rewrite when the
append only file gets too big.
The implementation inside `aof.c` has additional functions in order to
implement an API that allows commands to append new commands into the AOF
file as clients execute them.
The `call()` function defined inside `server.c` is responsible for calling
the functions that in turn will write the commands into the AOF.
db.c
---
Certain Redis commands operate on specific data types; others are general.
Examples of generic commands are `DEL` and `EXPIRE`. They operate on keys
and not on their values specifically. All those generic commands are
defined inside `db.c`.
Moreover `db.c` implements an API in order to perform certain operations
on the Redis dataset without directly accessing the internal data structures.
The most important functions inside `db.c` which are used in many command
implementations are the following:
* `lookupKeyRead()` and `lookupKeyWrite()` are used in order to get a pointer to the value associated to a given key, or `NULL` if the key does not exist.
* `dbAdd()` and its higher level counterpart `setKey()` create a new key in a Redis database.
* `dbDelete()` removes a key and its associated value.
* `emptyDb()` removes an entire single database or all the databases defined.
The rest of the file implements the generic commands exposed to the client.
object.c
---
The `robj` structure defining Redis objects was already described. Inside
`object.c` there are all the functions that operate with Redis objects at
a basic level, like functions to allocate new objects, handle the reference
counting and so forth. Notable functions inside this file:
* `incrRefCount()` and `decrRefCount()` are used in order to increment or decrement an object reference count. When it drops to 0 the object is finally freed.
* `createObject()` allocates a new object. There are also specialized functions to allocate string objects having a specific content, like `createStringObjectFromLongLong()` and similar functions.
This file also implements the `OBJECT` command.
replication.c
---
This is one of the most complex files inside Redis, it is recommended to
approach it only after getting a bit familiar with the rest of the code base.
In this file there is the implementation of both the master and replica role
of Redis.
One of the most important functions inside this file is `replicationFeedSlaves()` that writes commands to the clients representing replica instances connected
to our master, so that the replicas can get the writes performed by the clients:
this way their data set will remain synchronized with the one in the master.
This file also implements both the `SYNC` and `PSYNC` commands that are
used in order to perform the first synchronization between masters and
replicas, or to continue the replication after a disconnection.
Other C files
---
* `t_hash.c`, `t_list.c`, `t_set.c`, `t_string.c`, `t_zset.c` and `t_stream.c` contains the implementation of the Redis data types. They implement both an API to access a given data type, and the client command implementations for these data types.
* `ae.c` implements the Redis event loop, it's a self contained library which is simple to read and understand.
* `sds.c` is the Redis string library, check http://github.com/antirez/sds for more information.
* `anet.c` is a library to use POSIX networking in a simpler way compared to the raw interface exposed by the kernel.
* `dict.c` is an implementation of a non-blocking hash table which rehashes incrementally.
* `scripting.c` implements Lua scripting. It is completely self-contained and isolated from the rest of the Redis implementation and is simple enough to understand if you are familiar with the Lua API.
* `cluster.c` implements the Redis Cluster. Probably a good read only after being very familiar with the rest of the Redis code base. If you want to read `cluster.c` make sure to read the [Redis Cluster specification][3].
[3]: https://redis.io/topics/cluster-spec
Anatomy of a Redis command
---
All the Redis commands are defined in the following way:
void foobarCommand(client *c) {
printf("%s",c->argv[1]->ptr); /* Do something with the argument. */
addReply(c,shared.ok); /* Reply something to the client. */
}
The command is then referenced inside `server.c` in the command table:
{"foobar",foobarCommand,2,"rtF",0,NULL,0,0,0,0,0},
In the above example `2` is the number of arguments the command takes,
while `"rtF"` are the command flags, as documented in the command table
top comment inside `server.c`.
After the command operates in some way, it returns a reply to the client,
usually using `addReply()` or a similar function defined inside `networking.c`.
There are tons of command implementations inside the Redis source code
that can serve as examples of actual commands implementations. Writing
a few toy commands can be a good exercise to get familiar with the code base.
There are also many other files not described here, but it is useless to
cover everything. We just want to help you with the first steps.
Eventually you'll find your way inside the Redis code base :-)
Enjoy!
+15 -30
View File
@@ -6,20 +6,17 @@ Getting Started
### Building
To build with TLS support you'll need OpenSSL development libraries (e.g.
libssl-dev on Debian/Ubuntu).
Run `make BUILD_TLS=yes`.
TLS support is enabled in the default build. To build without TLS, run `make BUILD_TLS=no`.
### Tests
To run Redis test suite with TLS, you'll need TLS support for TCL (i.e.
To run KeyDB test suite with TLS, you'll need TLS support for TCL (i.e.
`tcl-tls` package on Debian/Ubuntu).
1. Run `./utils/gen-test-certs.sh` to generate a root CA and a server
certificate.
2. Run `./runtest --tls` or `./runtest-cluster --tls` to run Redis and Redis
2. Run `./runtest --tls` or `./runtest-cluster --tls` to run KeyDB and KeyDB
Cluster tests in TLS mode.
### Running manually
@@ -27,23 +24,23 @@ To run Redis test suite with TLS, you'll need TLS support for TCL (i.e.
To manually run a Redis server with TLS mode (assuming `gen-test-certs.sh` was
invoked so sample certificates/keys are available):
./src/redis-server --tls-port 6379 --port 0 \
--tls-cert-file ./tests/tls/redis.crt \
--tls-key-file ./tests/tls/redis.key \
./src/keydb-server --tls-port 6379 --port 0 \
--tls-cert-file ./tests/tls/client.crt \
--tls-key-file ./tests/tls/client.key \
--tls-ca-cert-file ./tests/tls/ca.crt
To connect to this Redis server with `redis-cli`:
To connect to this Redis server with `keydb-cli`:
./src/redis-cli --tls \
--cert ./tests/tls/redis.crt \
--key ./tests/tls/redis.key \
./src/keydb-cli --tls \
--cert ./tests/tls/keydb.crt \
--key ./tests/tls/keydb.key \
--cacert ./tests/tls/ca.crt
This will disable TCP and enable TLS on port 6379. It's also possible to have
both TCP and TLS available, but you'll need to assign different ports.
To make a Replica connect to the master using TLS, use `--tls-replication yes`,
and to make Redis Cluster use TLS across nodes use `--tls-cluster yes`.
and to make KeyDB Cluster use TLS across nodes use `--tls-cluster yes`.
Connections
-----------
@@ -51,35 +48,23 @@ Connections
All socket operations now go through a connection abstraction layer that hides
I/O and read/write event handling from the caller.
**Multi-threading I/O is not currently supported for TLS**, as a TLS connection
needs to do its own manipulation of AE events which is not thread safe. The
solution is probably to manage independent AE loops for I/O threads and longer
term association of connections with threads. This may potentially improve
overall performance as well.
Sync IO for TLS is currently implemented in a hackish way, i.e. making the
socket blocking and configuring socket-level timeout. This means the timeout
value may not be so accurate, and there would be a lot of syscall overhead.
However I believe that getting rid of syncio completely in favor of pure async
work is probably a better move than trying to fix that. For replication it would
probably not be so hard. For cluster keys migration it might be more difficult,
but there are probably other good reasons to improve that part anyway.
Note that unlike Redis, KeyDB fully supports multithreading of TLS connections.
To-Do List
----------
- [ ] redis-benchmark support. The current implementation is a mix of using
- [ ] keydb-benchmark support. The current implementation is a mix of using
hiredis for parsing and basic networking (establishing connections), but
directly manipulating sockets for most actions. This will need to be cleaned
up for proper TLS support. The best approach is probably to migrate to hiredis
async mode.
- [ ] redis-cli `--slave` and `--rdb` support.
- [ ] keydb-cli `--slave` and `--rdb` support.
Multi-port
----------
Consider the implications of allowing TLS to be configured on a separate port,
making Redis listening on multiple ports:
making KeyDB listening on multiple ports:
1. Startup banner port notification
2. Proctitle
+48
View File
@@ -0,0 +1,48 @@
# Doc: https://wiki.sc-corp.net/pages/viewpage.action?pageId=121500284
version: 1
machamp:
keydb-build:
# Optional - build counter is linked to the build def
tag_template: 0.0.%build.counter%
# Optional - value in seconds before a build is terminated, default is 3600 seconds
timeout: 3600
# Optional - update ghe or not, default to true
update_ghe: true
code_coverage: false
# Required
steps:
make-build:
type: cmd
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
command: ./machamp_scripts/build.sh
tls-test:
type: cmd
parent: make-build
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
command: ./runtest --clients $(nproc) --verbose --tls
cluster-test:
type: cmd
parent: make-build
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
command: ./runtest-cluster --tls
sentinel-test:
type: cmd
parent: make-build
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
command: ./runtest-sentinel
module-test:
type: cmd
parent: make-build
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
command: ./runtest-moduleapi
rotation-test:
type: cmd
parent: make-build
# https://github.sc-corp.net/Snapchat/img/tree/master/keydb/ubuntu-20-04
builder_image: us.gcr.io/snapchat-build-artifacts/prod/snapchat/img/keydb/keydb-ubuntu-20-04@sha256:cf869a3f5d1de1e1d976bb906689c37b7031938eb68661b844a38c532f27248c
command: ./runtest-rotation
+16
View File
@@ -0,0 +1,16 @@
# Doc: https://wiki.sc-corp.net/display/TOOL/ci.yaml+User+Guide
version: 1
on:
pull_request:
- workflows:
# All builds that use machamp should use the defined `backend_workflow`
- workflow_type: backend_workflow
# references a build defined in build.yaml
build_name: keydb-build
arch_types: ["amd64", "arm64"]
push:
- branches: [master]
workflows:
- workflow_type: backend_workflow
build_name: keydb-build
arch_types: ["amd64", "arm64"]
+18 -1
View File
@@ -1,6 +1,7 @@
# Redis dependency Makefile
uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
@@ -37,6 +38,7 @@ distclean:
-(cd linenoise && $(MAKE) clean) > /dev/null || true
-(cd lua && $(MAKE) clean) > /dev/null || true
-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
-(cd rocksdb && $(MAKE) clean) > /dev/null || true
-(cd hdr_histogram && $(MAKE) clean) > /dev/null || true
-(rm -f .make-*)
@@ -58,6 +60,11 @@ linenoise: .make-prerequisites
.PHONY: linenoise
.PHONY: memkind
memkind:
cd memkind && $(MAKE)
hdr_histogram: .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
cd hdr_histogram && $(MAKE)
@@ -88,7 +95,17 @@ JEMALLOC_LDFLAGS= $(LDFLAGS)
jemalloc: .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
cd jemalloc && ./configure --with-version=5.1.0-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
cd jemalloc && ./configure --with-version=5.2.1-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ --disable-cxx CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a
.PHONY: jemalloc
rocksdb: .make-prerequisites
# @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
ifeq ($(uname_M),x86_64)
# cd rocksdb && CFLAGS=-Wno-error PORTABLE=1 USE_SSE=1 FORCE_SSE42=1 $(MAKE) static_lib
else
# cd rocksdb && PORTABLE=1 $(MAKE) static_lib
endif
.PHONY: rocksdb
+583
View File
@@ -0,0 +1,583 @@
// Provides an efficient blocking version of moodycamel::ConcurrentQueue.
// ©2015-2020 Cameron Desrochers. Distributed under the terms of the simplified
// BSD license, available at the top of concurrentqueue.h.
// Also dual-licensed under the Boost Software License (see LICENSE.md)
// Uses Jeff Preshing's semaphore implementation (under the terms of its
// separate zlib license, see lightweightsemaphore.h).
#pragma once
#include "concurrentqueue.h"
#include "lightweightsemaphore.h"
#include <type_traits>
#include <cerrno>
#include <memory>
#include <chrono>
#include <ctime>
namespace moodycamel
{
// This is a blocking version of the queue. It has an almost identical interface to
// the normal non-blocking version, with the addition of various wait_dequeue() methods
// and the removal of producer-specific dequeue methods.
template<typename T, typename Traits = ConcurrentQueueDefaultTraits>
class BlockingConcurrentQueue
{
private:
typedef ::moodycamel::ConcurrentQueue<T, Traits> ConcurrentQueue;
typedef ::moodycamel::LightweightSemaphore LightweightSemaphore;
public:
typedef typename ConcurrentQueue::producer_token_t producer_token_t;
typedef typename ConcurrentQueue::consumer_token_t consumer_token_t;
typedef typename ConcurrentQueue::index_t index_t;
typedef typename ConcurrentQueue::size_t size_t;
typedef typename std::make_signed<size_t>::type ssize_t;
static const size_t BLOCK_SIZE = ConcurrentQueue::BLOCK_SIZE;
static const size_t EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD = ConcurrentQueue::EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD;
static const size_t EXPLICIT_INITIAL_INDEX_SIZE = ConcurrentQueue::EXPLICIT_INITIAL_INDEX_SIZE;
static const size_t IMPLICIT_INITIAL_INDEX_SIZE = ConcurrentQueue::IMPLICIT_INITIAL_INDEX_SIZE;
static const size_t INITIAL_IMPLICIT_PRODUCER_HASH_SIZE = ConcurrentQueue::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE;
static const std::uint32_t EXPLICIT_CONSUMER_CONSUMPTION_QUOTA_BEFORE_ROTATE = ConcurrentQueue::EXPLICIT_CONSUMER_CONSUMPTION_QUOTA_BEFORE_ROTATE;
static const size_t MAX_SUBQUEUE_SIZE = ConcurrentQueue::MAX_SUBQUEUE_SIZE;
public:
// Creates a queue with at least `capacity` element slots; note that the
// actual number of elements that can be inserted without additional memory
// allocation depends on the number of producers and the block size (e.g. if
// the block size is equal to `capacity`, only a single block will be allocated
// up-front, which means only a single producer will be able to enqueue elements
// without an extra allocation -- blocks aren't shared between producers).
// This method is not thread safe -- it is up to the user to ensure that the
// queue is fully constructed before it starts being used by other threads (this
// includes making the memory effects of construction visible, possibly with a
// memory barrier).
explicit BlockingConcurrentQueue(size_t capacity = 6 * BLOCK_SIZE)
: inner(capacity), sema(create<LightweightSemaphore, ssize_t, int>(0, (int)Traits::MAX_SEMA_SPINS), &BlockingConcurrentQueue::template destroy<LightweightSemaphore>)
{
assert(reinterpret_cast<ConcurrentQueue*>((BlockingConcurrentQueue*)1) == &((BlockingConcurrentQueue*)1)->inner && "BlockingConcurrentQueue must have ConcurrentQueue as its first member");
if (!sema) {
MOODYCAMEL_THROW(std::bad_alloc());
}
}
BlockingConcurrentQueue(size_t minCapacity, size_t maxExplicitProducers, size_t maxImplicitProducers)
: inner(minCapacity, maxExplicitProducers, maxImplicitProducers), sema(create<LightweightSemaphore, ssize_t, int>(0, (int)Traits::MAX_SEMA_SPINS), &BlockingConcurrentQueue::template destroy<LightweightSemaphore>)
{
assert(reinterpret_cast<ConcurrentQueue*>((BlockingConcurrentQueue*)1) == &((BlockingConcurrentQueue*)1)->inner && "BlockingConcurrentQueue must have ConcurrentQueue as its first member");
if (!sema) {
MOODYCAMEL_THROW(std::bad_alloc());
}
}
// Disable copying and copy assignment
BlockingConcurrentQueue(BlockingConcurrentQueue const&) MOODYCAMEL_DELETE_FUNCTION;
BlockingConcurrentQueue& operator=(BlockingConcurrentQueue const&) MOODYCAMEL_DELETE_FUNCTION;
// Moving is supported, but note that it is *not* a thread-safe operation.
// Nobody can use the queue while it's being moved, and the memory effects
// of that move must be propagated to other threads before they can use it.
// Note: When a queue is moved, its tokens are still valid but can only be
// used with the destination queue (i.e. semantically they are moved along
// with the queue itself).
BlockingConcurrentQueue(BlockingConcurrentQueue&& other) MOODYCAMEL_NOEXCEPT
: inner(std::move(other.inner)), sema(std::move(other.sema))
{ }
inline BlockingConcurrentQueue& operator=(BlockingConcurrentQueue&& other) MOODYCAMEL_NOEXCEPT
{
return swap_internal(other);
}
// Swaps this queue's state with the other's. Not thread-safe.
// Swapping two queues does not invalidate their tokens, however
// the tokens that were created for one queue must be used with
// only the swapped queue (i.e. the tokens are tied to the
// queue's movable state, not the object itself).
inline void swap(BlockingConcurrentQueue& other) MOODYCAMEL_NOEXCEPT
{
swap_internal(other);
}
private:
BlockingConcurrentQueue& swap_internal(BlockingConcurrentQueue& other)
{
if (this == &other) {
return *this;
}
inner.swap(other.inner);
sema.swap(other.sema);
return *this;
}
public:
// Enqueues a single item (by copying it).
// Allocates memory if required. Only fails if memory allocation fails (or implicit
// production is disabled because Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE is 0,
// or Traits::MAX_SUBQUEUE_SIZE has been defined and would be surpassed).
// Thread-safe.
inline bool enqueue(T const& item)
{
if ((details::likely)(inner.enqueue(item))) {
sema->signal();
return true;
}
return false;
}
// Enqueues a single item (by moving it, if possible).
// Allocates memory if required. Only fails if memory allocation fails (or implicit
// production is disabled because Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE is 0,
// or Traits::MAX_SUBQUEUE_SIZE has been defined and would be surpassed).
// Thread-safe.
inline bool enqueue(T&& item)
{
if ((details::likely)(inner.enqueue(std::move(item)))) {
sema->signal();
return true;
}
return false;
}
// Enqueues a single item (by copying it) using an explicit producer token.
// Allocates memory if required. Only fails if memory allocation fails (or
// Traits::MAX_SUBQUEUE_SIZE has been defined and would be surpassed).
// Thread-safe.
inline bool enqueue(producer_token_t const& token, T const& item)
{
if ((details::likely)(inner.enqueue(token, item))) {
sema->signal();
return true;
}
return false;
}
// Enqueues a single item (by moving it, if possible) using an explicit producer token.
// Allocates memory if required. Only fails if memory allocation fails (or
// Traits::MAX_SUBQUEUE_SIZE has been defined and would be surpassed).
// Thread-safe.
inline bool enqueue(producer_token_t const& token, T&& item)
{
if ((details::likely)(inner.enqueue(token, std::move(item)))) {
sema->signal();
return true;
}
return false;
}
// Enqueues several items.
// Allocates memory if required. Only fails if memory allocation fails (or
// implicit production is disabled because Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE
// is 0, or Traits::MAX_SUBQUEUE_SIZE has been defined and would be surpassed).
// Note: Use std::make_move_iterator if the elements should be moved instead of copied.
// Thread-safe.
template<typename It>
inline bool enqueue_bulk(It itemFirst, size_t count)
{
if ((details::likely)(inner.enqueue_bulk(std::forward<It>(itemFirst), count))) {
sema->signal((LightweightSemaphore::ssize_t)(ssize_t)count);
return true;
}
return false;
}
// Enqueues several items using an explicit producer token.
// Allocates memory if required. Only fails if memory allocation fails
// (or Traits::MAX_SUBQUEUE_SIZE has been defined and would be surpassed).
// Note: Use std::make_move_iterator if the elements should be moved
// instead of copied.
// Thread-safe.
template<typename It>
inline bool enqueue_bulk(producer_token_t const& token, It itemFirst, size_t count)
{
if ((details::likely)(inner.enqueue_bulk(token, std::forward<It>(itemFirst), count))) {
sema->signal((LightweightSemaphore::ssize_t)(ssize_t)count);
return true;
}
return false;
}
// Enqueues a single item (by copying it).
// Does not allocate memory. Fails if not enough room to enqueue (or implicit
// production is disabled because Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE
// is 0).
// Thread-safe.
inline bool try_enqueue(T const& item)
{
if (inner.try_enqueue(item)) {
sema->signal();
return true;
}
return false;
}
// Enqueues a single item (by moving it, if possible).
// Does not allocate memory (except for one-time implicit producer).
// Fails if not enough room to enqueue (or implicit production is
// disabled because Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE is 0).
// Thread-safe.
inline bool try_enqueue(T&& item)
{
if (inner.try_enqueue(std::move(item))) {
sema->signal();
return true;
}
return false;
}
// Enqueues a single item (by copying it) using an explicit producer token.
// Does not allocate memory. Fails if not enough room to enqueue.
// Thread-safe.
inline bool try_enqueue(producer_token_t const& token, T const& item)
{
if (inner.try_enqueue(token, item)) {
sema->signal();
return true;
}
return false;
}
// Enqueues a single item (by moving it, if possible) using an explicit producer token.
// Does not allocate memory. Fails if not enough room to enqueue.
// Thread-safe.
inline bool try_enqueue(producer_token_t const& token, T&& item)
{
if (inner.try_enqueue(token, std::move(item))) {
sema->signal();
return true;
}
return false;
}
// Enqueues several items.
// Does not allocate memory (except for one-time implicit producer).
// Fails if not enough room to enqueue (or implicit production is
// disabled because Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE is 0).
// Note: Use std::make_move_iterator if the elements should be moved
// instead of copied.
// Thread-safe.
template<typename It>
inline bool try_enqueue_bulk(It itemFirst, size_t count)
{
if (inner.try_enqueue_bulk(std::forward<It>(itemFirst), count)) {
sema->signal((LightweightSemaphore::ssize_t)(ssize_t)count);
return true;
}
return false;
}
// Enqueues several items using an explicit producer token.
// Does not allocate memory. Fails if not enough room to enqueue.
// Note: Use std::make_move_iterator if the elements should be moved
// instead of copied.
// Thread-safe.
template<typename It>
inline bool try_enqueue_bulk(producer_token_t const& token, It itemFirst, size_t count)
{
if (inner.try_enqueue_bulk(token, std::forward<It>(itemFirst), count)) {
sema->signal((LightweightSemaphore::ssize_t)(ssize_t)count);
return true;
}
return false;
}
// Attempts to dequeue from the queue.
// Returns false if all producer streams appeared empty at the time they
// were checked (so, the queue is likely but not guaranteed to be empty).
// Never allocates. Thread-safe.
template<typename U>
inline bool try_dequeue(U& item)
{
if (sema->tryWait()) {
while (!inner.try_dequeue(item)) {
continue;
}
return true;
}
return false;
}
// Attempts to dequeue from the queue using an explicit consumer token.
// Returns false if all producer streams appeared empty at the time they
// were checked (so, the queue is likely but not guaranteed to be empty).
// Never allocates. Thread-safe.
template<typename U>
inline bool try_dequeue(consumer_token_t& token, U& item)
{
if (sema->tryWait()) {
while (!inner.try_dequeue(token, item)) {
continue;
}
return true;
}
return false;
}
// Attempts to dequeue several elements from the queue.
// Returns the number of items actually dequeued.
// Returns 0 if all producer streams appeared empty at the time they
// were checked (so, the queue is likely but not guaranteed to be empty).
// Never allocates. Thread-safe.
template<typename It>
inline size_t try_dequeue_bulk(It itemFirst, size_t max)
{
size_t count = 0;
max = (size_t)sema->tryWaitMany((LightweightSemaphore::ssize_t)(ssize_t)max);
while (count != max) {
count += inner.template try_dequeue_bulk<It&>(itemFirst, max - count);
}
return count;
}
// Attempts to dequeue several elements from the queue using an explicit consumer token.
// Returns the number of items actually dequeued.
// Returns 0 if all producer streams appeared empty at the time they
// were checked (so, the queue is likely but not guaranteed to be empty).
// Never allocates. Thread-safe.
template<typename It>
inline size_t try_dequeue_bulk(consumer_token_t& token, It itemFirst, size_t max)
{
size_t count = 0;
max = (size_t)sema->tryWaitMany((LightweightSemaphore::ssize_t)(ssize_t)max);
while (count != max) {
count += inner.template try_dequeue_bulk<It&>(token, itemFirst, max - count);
}
return count;
}
// Blocks the current thread until there's something to dequeue, then
// dequeues it.
// Never allocates. Thread-safe.
template<typename U>
inline void wait_dequeue(U& item)
{
while (!sema->wait()) {
continue;
}
while (!inner.try_dequeue(item)) {
continue;
}
}
// Blocks the current thread until either there's something to dequeue
// or the timeout (specified in microseconds) expires. Returns false
// without setting `item` if the timeout expires, otherwise assigns
// to `item` and returns true.
// Using a negative timeout indicates an indefinite timeout,
// and is thus functionally equivalent to calling wait_dequeue.
// Never allocates. Thread-safe.
template<typename U>
inline bool wait_dequeue_timed(U& item, std::int64_t timeout_usecs)
{
if (!sema->wait(timeout_usecs)) {
return false;
}
while (!inner.try_dequeue(item)) {
continue;
}
return true;
}
// Blocks the current thread until either there's something to dequeue
// or the timeout expires. Returns false without setting `item` if the
// timeout expires, otherwise assigns to `item` and returns true.
// Never allocates. Thread-safe.
template<typename U, typename Rep, typename Period>
inline bool wait_dequeue_timed(U& item, std::chrono::duration<Rep, Period> const& timeout)
{
return wait_dequeue_timed(item, std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
}
// Blocks the current thread until there's something to dequeue, then
// dequeues it using an explicit consumer token.
// Never allocates. Thread-safe.
template<typename U>
inline void wait_dequeue(consumer_token_t& token, U& item)
{
while (!sema->wait()) {
continue;
}
while (!inner.try_dequeue(token, item)) {
continue;
}
}
// Blocks the current thread until either there's something to dequeue
// or the timeout (specified in microseconds) expires. Returns false
// without setting `item` if the timeout expires, otherwise assigns
// to `item` and returns true.
// Using a negative timeout indicates an indefinite timeout,
// and is thus functionally equivalent to calling wait_dequeue.
// Never allocates. Thread-safe.
template<typename U>
inline bool wait_dequeue_timed(consumer_token_t& token, U& item, std::int64_t timeout_usecs)
{
if (!sema->wait(timeout_usecs)) {
return false;
}
while (!inner.try_dequeue(token, item)) {
continue;
}
return true;
}
// Blocks the current thread until either there's something to dequeue
// or the timeout expires. Returns false without setting `item` if the
// timeout expires, otherwise assigns to `item` and returns true.
// Never allocates. Thread-safe.
template<typename U, typename Rep, typename Period>
inline bool wait_dequeue_timed(consumer_token_t& token, U& item, std::chrono::duration<Rep, Period> const& timeout)
{
return wait_dequeue_timed(token, item, std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
}
// Attempts to dequeue several elements from the queue.
// Returns the number of items actually dequeued, which will
// always be at least one (this method blocks until the queue
// is non-empty) and at most max.
// Never allocates. Thread-safe.
template<typename It>
inline size_t wait_dequeue_bulk(It itemFirst, size_t max)
{
size_t count = 0;
max = (size_t)sema->waitMany((LightweightSemaphore::ssize_t)(ssize_t)max);
while (count != max) {
count += inner.template try_dequeue_bulk<It&>(itemFirst, max - count);
}
return count;
}
// Attempts to dequeue several elements from the queue.
// Returns the number of items actually dequeued, which can
// be 0 if the timeout expires while waiting for elements,
// and at most max.
// Using a negative timeout indicates an indefinite timeout,
// and is thus functionally equivalent to calling wait_dequeue_bulk.
// Never allocates. Thread-safe.
template<typename It>
inline size_t wait_dequeue_bulk_timed(It itemFirst, size_t max, std::int64_t timeout_usecs)
{
size_t count = 0;
max = (size_t)sema->waitMany((LightweightSemaphore::ssize_t)(ssize_t)max, timeout_usecs);
while (count != max) {
count += inner.template try_dequeue_bulk<It&>(itemFirst, max - count);
}
return count;
}
// Attempts to dequeue several elements from the queue.
// Returns the number of items actually dequeued, which can
// be 0 if the timeout expires while waiting for elements,
// and at most max.
// Never allocates. Thread-safe.
template<typename It, typename Rep, typename Period>
inline size_t wait_dequeue_bulk_timed(It itemFirst, size_t max, std::chrono::duration<Rep, Period> const& timeout)
{
return wait_dequeue_bulk_timed<It&>(itemFirst, max, std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
}
// Attempts to dequeue several elements from the queue using an explicit consumer token.
// Returns the number of items actually dequeued, which will
// always be at least one (this method blocks until the queue
// is non-empty) and at most max.
// Never allocates. Thread-safe.
template<typename It>
inline size_t wait_dequeue_bulk(consumer_token_t& token, It itemFirst, size_t max)
{
size_t count = 0;
max = (size_t)sema->waitMany((LightweightSemaphore::ssize_t)(ssize_t)max);
while (count != max) {
count += inner.template try_dequeue_bulk<It&>(token, itemFirst, max - count);
}
return count;
}
// Attempts to dequeue several elements from the queue using an explicit consumer token.
// Returns the number of items actually dequeued, which can
// be 0 if the timeout expires while waiting for elements,
// and at most max.
// Using a negative timeout indicates an indefinite timeout,
// and is thus functionally equivalent to calling wait_dequeue_bulk.
// Never allocates. Thread-safe.
template<typename It>
inline size_t wait_dequeue_bulk_timed(consumer_token_t& token, It itemFirst, size_t max, std::int64_t timeout_usecs)
{
size_t count = 0;
max = (size_t)sema->waitMany((LightweightSemaphore::ssize_t)(ssize_t)max, timeout_usecs);
while (count != max) {
count += inner.template try_dequeue_bulk<It&>(token, itemFirst, max - count);
}
return count;
}
// Attempts to dequeue several elements from the queue using an explicit consumer token.
// Returns the number of items actually dequeued, which can
// be 0 if the timeout expires while waiting for elements,
// and at most max.
// Never allocates. Thread-safe.
template<typename It, typename Rep, typename Period>
inline size_t wait_dequeue_bulk_timed(consumer_token_t& token, It itemFirst, size_t max, std::chrono::duration<Rep, Period> const& timeout)
{
return wait_dequeue_bulk_timed<It&>(token, itemFirst, max, std::chrono::duration_cast<std::chrono::microseconds>(timeout).count());
}
// Returns an estimate of the total number of elements currently in the queue. This
// estimate is only accurate if the queue has completely stabilized before it is called
// (i.e. all enqueue and dequeue operations have completed and their memory effects are
// visible on the calling thread, and no further operations start while this method is
// being called).
// Thread-safe.
inline size_t size_approx() const
{
return (size_t)sema->availableApprox();
}
// Returns true if the underlying atomic variables used by
// the queue are lock-free (they should be on most platforms).
// Thread-safe.
static bool is_lock_free()
{
return ConcurrentQueue::is_lock_free();
}
private:
template<typename U, typename A1, typename A2>
static inline U* create(A1&& a1, A2&& a2)
{
void* p = (Traits::malloc)(sizeof(U));
return p != nullptr ? new (p) U(std::forward<A1>(a1), std::forward<A2>(a2)) : nullptr;
}
template<typename U>
static inline void destroy(U* p)
{
if (p != nullptr) {
p->~U();
}
(Traits::free)(p);
}
private:
ConcurrentQueue inner;
std::unique_ptr<LightweightSemaphore, void (*)(LightweightSemaphore*)> sema;
};
template<typename T, typename Traits>
inline void swap(BlockingConcurrentQueue<T, Traits>& a, BlockingConcurrentQueue<T, Traits>& b) MOODYCAMEL_NOEXCEPT
{
a.swap(b);
}
} // end namespace moodycamel
File diff suppressed because it is too large. Load diff
+412
View File
@@ -0,0 +1,412 @@
// Provides an efficient implementation of a semaphore (LightweightSemaphore).
// This is an extension of Jeff Preshing's sempahore implementation (licensed
// under the terms of its separate zlib license) that has been adapted and
// extended by Cameron Desrochers.
#pragma once
#include <cstddef> // For std::size_t
#include <atomic>
#include <type_traits> // For std::make_signed<T>
#if defined(_WIN32)
// Avoid including windows.h in a header; we only need a handful of
// items, so we'll redeclare them here (this is relatively safe since
// the API generally has to remain stable between Windows versions).
// I know this is an ugly hack but it still beats polluting the global
// namespace with thousands of generic names or adding a .cpp for nothing.
extern "C" {
struct _SECURITY_ATTRIBUTES;
__declspec(dllimport) void* __stdcall CreateSemaphoreW(_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, long lInitialCount, long lMaximumCount, const wchar_t* lpName);
__declspec(dllimport) int __stdcall CloseHandle(void* hObject);
__declspec(dllimport) unsigned long __stdcall WaitForSingleObject(void* hHandle, unsigned long dwMilliseconds);
__declspec(dllimport) int __stdcall ReleaseSemaphore(void* hSemaphore, long lReleaseCount, long* lpPreviousCount);
}
#elif defined(__MACH__)
#include <mach/mach.h>
#elif defined(__unix__)
#include <semaphore.h>
#endif
namespace moodycamel
{
namespace details
{
// Code in the mpmc_sema namespace below is an adaptation of Jeff Preshing's
// portable + lightweight semaphore implementations, originally from
// https://github.com/preshing/cpp11-on-multicore/blob/master/common/sema.h
// LICENSE:
// Copyright (c) 2015 Jeff Preshing
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgement in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#if defined(_WIN32)
class Semaphore
{
private:
void* m_hSema;
Semaphore(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
Semaphore& operator=(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
public:
Semaphore(int initialCount = 0)
{
assert(initialCount >= 0);
const long maxLong = 0x7fffffff;
m_hSema = CreateSemaphoreW(nullptr, initialCount, maxLong, nullptr);
assert(m_hSema);
}
~Semaphore()
{
CloseHandle(m_hSema);
}
bool wait()
{
const unsigned long infinite = 0xffffffff;
return WaitForSingleObject(m_hSema, infinite) == 0;
}
bool try_wait()
{
return WaitForSingleObject(m_hSema, 0) == 0;
}
bool timed_wait(std::uint64_t usecs)
{
return WaitForSingleObject(m_hSema, (unsigned long)(usecs / 1000)) == 0;
}
void signal(int count = 1)
{
while (!ReleaseSemaphore(m_hSema, count, nullptr));
}
};
#elif defined(__MACH__)
//---------------------------------------------------------
// Semaphore (Apple iOS and OSX)
// Can't use POSIX semaphores due to http://lists.apple.com/archives/darwin-kernel/2009/Apr/msg00010.html
//---------------------------------------------------------
class Semaphore
{
private:
semaphore_t m_sema;
Semaphore(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
Semaphore& operator=(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
public:
Semaphore(int initialCount = 0)
{
assert(initialCount >= 0);
kern_return_t rc = semaphore_create(mach_task_self(), &m_sema, SYNC_POLICY_FIFO, initialCount);
assert(rc == KERN_SUCCESS);
(void)rc;
}
~Semaphore()
{
semaphore_destroy(mach_task_self(), m_sema);
}
bool wait()
{
return semaphore_wait(m_sema) == KERN_SUCCESS;
}
bool try_wait()
{
return timed_wait(0);
}
bool timed_wait(std::uint64_t timeout_usecs)
{
mach_timespec_t ts;
ts.tv_sec = static_cast<unsigned int>(timeout_usecs / 1000000);
ts.tv_nsec = static_cast<int>((timeout_usecs % 1000000) * 1000);
// added in OSX 10.10: https://developer.apple.com/library/prerelease/mac/documentation/General/Reference/APIDiffsMacOSX10_10SeedDiff/modules/Darwin.html
kern_return_t rc = semaphore_timedwait(m_sema, ts);
return rc == KERN_SUCCESS;
}
void signal()
{
while (semaphore_signal(m_sema) != KERN_SUCCESS);
}
void signal(int count)
{
while (count-- > 0)
{
while (semaphore_signal(m_sema) != KERN_SUCCESS);
}
}
};
#elif defined(__unix__)
//---------------------------------------------------------
// Semaphore (POSIX, Linux)
//---------------------------------------------------------
class Semaphore
{
private:
sem_t m_sema;
Semaphore(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
Semaphore& operator=(const Semaphore& other) MOODYCAMEL_DELETE_FUNCTION;
public:
Semaphore(int initialCount = 0)
{
assert(initialCount >= 0);
int rc = sem_init(&m_sema, 0, static_cast<unsigned int>(initialCount));
assert(rc == 0);
(void)rc;
}
~Semaphore()
{
sem_destroy(&m_sema);
}
bool wait()
{
// http://stackoverflow.com/questions/2013181/gdb-causes-sem-wait-to-fail-with-eintr-error
int rc;
do {
rc = sem_wait(&m_sema);
} while (rc == -1 && errno == EINTR);
return rc == 0;
}
bool try_wait()
{
int rc;
do {
rc = sem_trywait(&m_sema);
} while (rc == -1 && errno == EINTR);
return rc == 0;
}
bool timed_wait(std::uint64_t usecs)
{
struct timespec ts;
const int usecs_in_1_sec = 1000000;
const int nsecs_in_1_sec = 1000000000;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += (time_t)(usecs / usecs_in_1_sec);
ts.tv_nsec += (long)(usecs % usecs_in_1_sec) * 1000;
// sem_timedwait bombs if you have more than 1e9 in tv_nsec
// so we have to clean things up before passing it in
if (ts.tv_nsec >= nsecs_in_1_sec) {
ts.tv_nsec -= nsecs_in_1_sec;
++ts.tv_sec;
}
int rc;
do {
rc = sem_timedwait(&m_sema, &ts);
} while (rc == -1 && errno == EINTR);
return rc == 0;
}
void signal()
{
while (sem_post(&m_sema) == -1);
}
void signal(int count)
{
while (count-- > 0)
{
while (sem_post(&m_sema) == -1);
}
}
};
#else
#error Unsupported platform! (No semaphore wrapper available)
#endif
} // end namespace details
//---------------------------------------------------------
// LightweightSemaphore
//---------------------------------------------------------
class LightweightSemaphore
{
public:
typedef std::make_signed<std::size_t>::type ssize_t;
private:
std::atomic<ssize_t> m_count;
details::Semaphore m_sema;
int m_maxSpins;
bool waitWithPartialSpinning(std::int64_t timeout_usecs = -1)
{
ssize_t oldCount;
int spin = m_maxSpins;
while (--spin >= 0)
{
oldCount = m_count.load(std::memory_order_relaxed);
if ((oldCount > 0) && m_count.compare_exchange_strong(oldCount, oldCount - 1, std::memory_order_acquire, std::memory_order_relaxed))
return true;
std::atomic_signal_fence(std::memory_order_acquire); // Prevent the compiler from collapsing the loop.
}
oldCount = m_count.fetch_sub(1, std::memory_order_acquire);
if (oldCount > 0)
return true;
if (timeout_usecs < 0)
{
if (m_sema.wait())
return true;
}
if (timeout_usecs > 0 && m_sema.timed_wait((std::uint64_t)timeout_usecs))
return true;
// At this point, we've timed out waiting for the semaphore, but the
// count is still decremented indicating we may still be waiting on
// it. So we have to re-adjust the count, but only if the semaphore
// wasn't signaled enough times for us too since then. If it was, we
// need to release the semaphore too.
while (true)
{
oldCount = m_count.load(std::memory_order_acquire);
if (oldCount >= 0 && m_sema.try_wait())
return true;
if (oldCount < 0 && m_count.compare_exchange_strong(oldCount, oldCount + 1, std::memory_order_relaxed, std::memory_order_relaxed))
return false;
}
}
ssize_t waitManyWithPartialSpinning(ssize_t max, std::int64_t timeout_usecs = -1)
{
assert(max > 0);
ssize_t oldCount;
int spin = m_maxSpins;
while (--spin >= 0)
{
oldCount = m_count.load(std::memory_order_relaxed);
if (oldCount > 0)
{
ssize_t newCount = oldCount > max ? oldCount - max : 0;
if (m_count.compare_exchange_strong(oldCount, newCount, std::memory_order_acquire, std::memory_order_relaxed))
return oldCount - newCount;
}
std::atomic_signal_fence(std::memory_order_acquire);
}
oldCount = m_count.fetch_sub(1, std::memory_order_acquire);
if (oldCount <= 0)
{
if ((timeout_usecs == 0) || (timeout_usecs < 0 && !m_sema.wait()) || (timeout_usecs > 0 && !m_sema.timed_wait((std::uint64_t)timeout_usecs)))
{
while (true)
{
oldCount = m_count.load(std::memory_order_acquire);
if (oldCount >= 0 && m_sema.try_wait())
break;
if (oldCount < 0 && m_count.compare_exchange_strong(oldCount, oldCount + 1, std::memory_order_relaxed, std::memory_order_relaxed))
return 0;
}
}
}
if (max > 1)
return 1 + tryWaitMany(max - 1);
return 1;
}
public:
LightweightSemaphore(ssize_t initialCount = 0, int maxSpins = 10000) : m_count(initialCount), m_maxSpins(maxSpins)
{
assert(initialCount >= 0);
assert(maxSpins >= 0);
}
bool tryWait()
{
ssize_t oldCount = m_count.load(std::memory_order_relaxed);
while (oldCount > 0)
{
if (m_count.compare_exchange_weak(oldCount, oldCount - 1, std::memory_order_acquire, std::memory_order_relaxed))
return true;
}
return false;
}
bool wait()
{
return tryWait() || waitWithPartialSpinning();
}
bool wait(std::int64_t timeout_usecs)
{
return tryWait() || waitWithPartialSpinning(timeout_usecs);
}
// Acquires between 0 and (greedily) max, inclusive
ssize_t tryWaitMany(ssize_t max)
{
assert(max >= 0);
ssize_t oldCount = m_count.load(std::memory_order_relaxed);
while (oldCount > 0)
{
ssize_t newCount = oldCount > max ? oldCount - max : 0;
if (m_count.compare_exchange_weak(oldCount, newCount, std::memory_order_acquire, std::memory_order_relaxed))
return oldCount - newCount;
}
return 0;
}
// Acquires at least one, and (greedily) at most max
ssize_t waitMany(ssize_t max, std::int64_t timeout_usecs)
{
assert(max >= 0);
ssize_t result = tryWaitMany(max);
if (result == 0 && max > 0)
result = waitManyWithPartialSpinning(max, timeout_usecs);
return result;
}
ssize_t waitMany(ssize_t max)
{
ssize_t result = waitMany(max, -1);
assert(result > 0);
return result;
}
void signal(ssize_t count = 1)
{
assert(count >= 0);
ssize_t oldCount = m_count.fetch_add(count, std::memory_order_release);
ssize_t toRelease = -oldCount < count ? -oldCount : count;
if (toRelease > 0)
{
m_sema.signal((int)toRelease);
}
}
std::size_t availableApprox() const
{
ssize_t count = m_count.load(std::memory_order_relaxed);
return count > 0 ? static_cast<std::size_t>(count) : 0;
}
};
} // end namespace moodycamel
+2 -2
View File
@@ -29,9 +29,9 @@ INSTALL_INCLUDE_PATH= $(DESTDIR)$(PREFIX)/$(INCLUDE_PATH)
INSTALL_LIBRARY_PATH= $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH)
INSTALL_PKGCONF_PATH= $(INSTALL_LIBRARY_PATH)/$(PKGCONF_PATH)
# redis-server configuration used for testing
# keydb-server configuration used for testing
REDIS_PORT=56379
REDIS_SERVER=redis-server
REDIS_SERVER=keydb-server
define REDIS_TEST_CONFIG
daemonize yes
pidfile /tmp/hiredis-test-redis.pid
+12 -1
View File
@@ -50,31 +50,41 @@ typedef char *hisds;
* However is here to document the layout of type 5 SDS strings. */
struct __attribute__ ((__packed__)) hisdshdr5 {
unsigned char flags; /* 3 lsb of type, and 5 msb of string length */
#ifndef __cplusplus
char buf[];
#endif
};
struct __attribute__ ((__packed__)) hisdshdr8 {
uint8_t len; /* used */
uint8_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
#ifndef __cplusplus
char buf[];
#endif
};
struct __attribute__ ((__packed__)) hisdshdr16 {
uint16_t len; /* used */
uint16_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
#ifndef __cplusplus
char buf[];
#endif
};
struct __attribute__ ((__packed__)) hisdshdr32 {
uint32_t len; /* used */
uint32_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
#ifndef __cplusplus
char buf[];
#endif
};
struct __attribute__ ((__packed__)) hisdshdr64 {
uint64_t len; /* used */
uint64_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
#ifndef __cplusplus
char buf[];
#endif
};
#define HI_SDS_TYPE_5 0
@@ -90,7 +100,8 @@ struct __attribute__ ((__packed__)) hisdshdr64 {
static inline size_t hi_sdslen(const hisds s) {
unsigned char flags = s[-1];
switch(flags & HI_SDS_TYPE_MASK) {
switch(__builtin_expect((flags&HI_SDS_TYPE_MASK), HI_SDS_TYPE_5)) {
case HI_SDS_TYPE_5:
return HI_SDS_TYPE_5_LEN(flags);
case HI_SDS_TYPE_8:
+8 -8
View File
@@ -5,27 +5,27 @@ environment:
- MSYSTEM: MINGW64
CPU: x86_64
MSVC: amd64
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW64
CPU: x86_64
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW32
CPU: i686
MSVC: x86
- MSYSTEM: MINGW64
CPU: x86_64
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW32
CPU: i686
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW64
CPU: x86_64
MSVC: amd64
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW64
CPU: x86_64
- MSYSTEM: MINGW32
CPU: i686
MSVC: x86
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW64
CPU: x86_64
CONFIG_FLAGS: --enable-debug
- MSYSTEM: MINGW32
CPU: i686
CONFIG_FLAGS: --enable-debug
install:
- set PATH=c:\msys64\%MSYSTEM%\bin;c:\msys64\usr\bin;%PATH%
+21
View File
@@ -0,0 +1,21 @@
env:
CIRRUS_CLONE_DEPTH: 1
ARCH: amd64
task:
freebsd_instance:
matrix:
image: freebsd-12-0-release-amd64
image: freebsd-11-2-release-amd64
install_script:
- sed -i.bak -e 's,pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly,pkg+http://pkg.FreeBSD.org/\${ABI}/latest,' /etc/pkg/FreeBSD.conf
- pkg upgrade -y
- pkg install -y autoconf gmake
script:
- autoconf
#- ./configure ${COMPILER_FLAGS:+ CC="$CC $COMPILER_FLAGS" CXX="$CXX $COMPILER_FLAGS" } $CONFIGURE_FLAGS
- ./configure
- export JFLAG=`sysctl -n kern.smp.cpus`
- gmake -j${JFLAG}
- gmake -j${JFLAG} tests
- gmake check
-1
View File
@@ -30,7 +30,6 @@
/include/jemalloc/internal/public_namespace.h
/include/jemalloc/internal/public_symbols.txt
/include/jemalloc/internal/public_unnamespace.h
/include/jemalloc/internal/size_classes.h
/include/jemalloc/jemalloc.h
/include/jemalloc/jemalloc_defs.h
/include/jemalloc/jemalloc_macros.h
+72 -33
View File
@@ -11,7 +11,7 @@ matrix:
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
addons: &gcc_multilib
apt:
packages:
- gcc-multilib
@@ -21,6 +21,10 @@ matrix:
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
@@ -37,20 +41,25 @@ matrix:
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: osx
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: osx
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: osx
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: osx
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
@@ -61,50 +70,39 @@ matrix:
env: CC=clang CXX=clang++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--enable-debug" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--enable-prof" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--disable-stats" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--with-malloc-conf=dss:primary" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--with-malloc-conf=percpu_arena:percpu" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="-m32" CONFIGURE_FLAGS="--with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
addons:
apt:
packages:
- gcc-multilib
addons: *gcc_multilib
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --enable-prof" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --disable-stats" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
@@ -115,6 +113,10 @@ matrix:
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof --disable-stats" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof --disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof --enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof --with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
@@ -123,6 +125,10 @@ matrix:
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof --with-malloc-conf=percpu_arena:percpu" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-prof --with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats --disable-libdl" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats --enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats --with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
@@ -131,6 +137,24 @@ matrix:
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats --with-malloc-conf=percpu_arena:percpu" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-stats --with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl --enable-opt-safety-checks" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl --with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl --with-malloc-conf=dss:primary" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl --with-malloc-conf=percpu_arena:percpu" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--disable-libdl --with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks --with-malloc-conf=tcache:false" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks --with-malloc-conf=dss:primary" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks --with-malloc-conf=percpu_arena:percpu" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-opt-safety-checks --with-malloc-conf=background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=tcache:false,dss:primary" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
@@ -143,10 +167,25 @@ matrix:
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=dss:primary,background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--with-malloc-conf=percpu_arena:percpu,background_thread:true" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
# Development build
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --disable-cache-oblivious --enable-stats --enable-log --enable-prof" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
# --enable-expermental-smallocx:
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="--enable-debug --enable-experimental-smallocx --enable-stats --enable-prof" EXTRA_CFLAGS="-Werror -Wno-array-bounds"
# Valgrind
- os: linux
env: CC=gcc CXX=g++ COMPILER_FLAGS="" CONFIGURE_FLAGS="" EXTRA_CFLAGS="-Werror -Wno-array-bounds" JEMALLOC_TEST_PREFIX="valgrind"
addons:
apt:
packages:
- valgrind
before_script:
- autoconf
- scripts/gen_travis.py > travis_script && diff .travis.yml travis_script
- ./configure ${COMPILER_FLAGS:+ CC="$CC $COMPILER_FLAGS" CXX="$CXX $COMPILER_FLAGS" } $CONFIGURE_FLAGS
- make -j3
- make -j3 tests
+2 -2
View File
@@ -1,10 +1,10 @@
Unless otherwise specified, files in the jemalloc source distribution are
subject to the following license:
--------------------------------------------------------------------------------
Copyright (C) 2002-2018 Jason Evans <jasone@canonware.com>.
Copyright (C) 2002-present Jason Evans <jasone@canonware.com>.
All rights reserved.
Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved.
Copyright (C) 2009-2018 Facebook, Inc. All rights reserved.
Copyright (C) 2009-present Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+137 -1
View File
@@ -4,7 +4,143 @@ brevity. Much more detail can be found in the git revision history:
https://github.com/jemalloc/jemalloc
* 5.1.0 (May 4th, 2018)
* 5.2.1 (August 5, 2019)
This release is primarily about Windows. A critical virtual memory leak is
resolved on all Windows platforms. The regression was present in all releases
since 5.0.0.
Bug fixes:
- Fix a severe virtual memory leak on Windows. This regression was first
released in 5.0.0. (@Ignition, @j0t, @frederik-h, @davidtgoldblatt,
@interwq)
- Fix size 0 handling in posix_memalign(). This regression was first released
in 5.2.0. (@interwq)
- Fix the prof_log unit test which may observe unexpected backtraces from
compiler optimizations. The test was first added in 5.2.0. (@marxin,
@gnzlbg, @interwq)
- Fix the declaration of the extent_avail tree. This regression was first
released in 5.1.0. (@zoulasc)
- Fix an incorrect reference in jeprof. This functionality was first released
in 3.0.0. (@prehistoric-penguin)
- Fix an assertion on the deallocation fast-path. This regression was first
released in 5.2.0. (@yinan1048576)
- Fix the TLS_MODEL attribute in headers. This regression was first released
in 5.0.0. (@zoulasc, @interwq)
Optimizations and refactors:
- Implement opt.retain on Windows and enable by default on 64-bit. (@interwq,
@davidtgoldblatt)
- Optimize away a branch on the operator delete[] path. (@mgrice)
- Add format annotation to the format generator function. (@zoulasc)
- Refactor and improve the size class header generation. (@yinan1048576)
- Remove best fit. (@djwatson)
- Avoid blocking on background thread locks for stats. (@oranagra, @interwq)
* 5.2.0 (April 2, 2019)
This release includes a few notable improvements, which are summarized below:
1) improved fast-path performance from the optimizations by @djwatson; 2)
reduced virtual memory fragmentation and metadata usage; and 3) bug fixes on
setting the number of background threads. In addition, peak / spike memory
usage is improved with certain allocation patterns. As usual, the release and
prior dev versions have gone through large-scale production testing.
New features:
- Implement oversize_threshold, which uses a dedicated arena for allocations
crossing the specified threshold to reduce fragmentation. (@interwq)
- Add extents usage information to stats. (@tyleretzel)
- Log time information for sampled allocations. (@tyleretzel)
- Support 0 size in sdallocx. (@djwatson)
- Output rate for certain counters in malloc_stats. (@zinoale)
- Add configure option --enable-readlinkat, which allows the use of readlinkat
over readlink. (@davidtgoldblatt)
- Add configure options --{enable,disable}-{static,shared} to allow not
building unwanted libraries. (@Ericson2314)
- Add configure option --disable-libdl to enable fully static builds.
(@interwq)
- Add mallctl interfaces:
+ opt.oversize_threshold (@interwq)
+ stats.arenas.<i>.extent_avail (@tyleretzel)
+ stats.arenas.<i>.extents.<j>.n{dirty,muzzy,retained} (@tyleretzel)
+ stats.arenas.<i>.extents.<j>.{dirty,muzzy,retained}_bytes
(@tyleretzel)
Portability improvements:
- Update MSVC builds. (@maksqwe, @rustyx)
- Workaround a compiler optimizer bug on s390x. (@rkmisra)
- Make use of pthread_set_name_np(3) on FreeBSD. (@trasz)
- Implement malloc_getcpu() to enable percpu_arena for windows. (@santagada)
- Link against -pthread instead of -lpthread. (@paravoid)
- Make background_thread not dependent on libdl. (@interwq)
- Add stringify to fix a linker directive issue on MSVC. (@daverigby)
- Detect and fall back when 8-bit atomics are unavailable. (@interwq)
- Fall back to the default pthread_create if dlsym(3) fails. (@interwq)
Optimizations and refactors:
- Refactor the TSD module. (@davidtgoldblatt)
- Avoid taking extents_muzzy mutex when muzzy is disabled. (@interwq)
- Avoid taking large_mtx for auto arenas on the tcache flush path. (@interwq)
- Optimize ixalloc by avoiding a size lookup. (@interwq)
- Implement opt.oversize_threshold which uses a dedicated arena for requests
crossing the threshold, also eagerly purges the oversize extents. Default
the threshold to 8 MiB. (@interwq)
- Clean compilation with -Wextra. (@gnzlbg, @jasone)
- Refactor the size class module. (@davidtgoldblatt)
- Refactor the stats emitter. (@tyleretzel)
- Optimize pow2_ceil. (@rkmisra)
- Avoid runtime detection of lazy purging on FreeBSD. (@trasz)
- Optimize mmap(2) alignment handling on FreeBSD. (@trasz)
- Improve error handling for THP state initialization. (@jsteemann)
- Rework the malloc() fast path. (@djwatson)
- Rework the free() fast path. (@djwatson)
- Refactor and optimize the tcache fill / flush paths. (@djwatson)
- Optimize sync / lwsync on PowerPC. (@chmeeedalf)
- Bypass extent_dalloc() when retain is enabled. (@interwq)
- Optimize the locking on large deallocation. (@interwq)
- Reduce the number of pages committed from sanity checking in debug build.
(@trasz, @interwq)
- Deprecate OSSpinLock. (@interwq)
- Lower the default number of background threads to 4 (when the feature
is enabled). (@interwq)
- Optimize the trylock spin wait. (@djwatson)
- Use arena index for arena-matching checks. (@interwq)
- Avoid forced decay on thread termination when using background threads.
(@interwq)
- Disable muzzy decay by default. (@djwatson, @interwq)
- Only initialize libgcc unwinder when profiling is enabled. (@paravoid,
@interwq)
Bug fixes (all only relevant to jemalloc 5.x):
- Fix background thread index issues with max_background_threads. (@djwatson,
@interwq)
- Fix stats output for opt.lg_extent_max_active_fit. (@interwq)
- Fix opt.prof_prefix initialization. (@davidtgoldblatt)
- Properly trigger decay on tcache destroy. (@interwq, @amosbird)
- Fix tcache.flush. (@interwq)
- Detect whether explicit extent zero out is necessary with huge pages or
custom extent hooks, which may change the purge semantics. (@interwq)
- Fix a side effect caused by extent_max_active_fit combined with decay-based
purging, where freed extents can accumulate and not be reused for an
extended period of time. (@interwq, @mpghf)
- Fix a missing unlock on extent register error handling. (@zoulasc)
Testing:
- Simplify the Travis script output. (@gnzlbg)
- Update the test scripts for FreeBSD. (@devnexen)
- Add unit tests for the producer-consumer pattern. (@interwq)
- Add Cirrus-CI config for FreeBSD builds. (@jasone)
- Add size-matching sanity checks on tcache flush. (@davidtgoldblatt,
@interwq)
Incompatible changes:
- Remove --with-lg-page-sizes. (@davidtgoldblatt)
Documentation:
- Attempt to build docs by default, however skip doc building when xsltproc
is missing. (@interwq, @cmuellner)
* 5.1.0 (May 4, 2018)
This release is primarily about fine-tuning, ranging from several new features
to numerous notable performance and portability enhancements. The release and
+5 -7
View File
@@ -221,13 +221,6 @@ any of the following arguments (not a definitive list) to 'configure':
system page size may change between configuration and execution, e.g. when
cross compiling.
* `--with-lg-page-sizes=<lg-page-sizes>`
Specify the comma-separated base 2 logs of the page sizes to support. This
option may be useful when cross compiling in combination with
`--with-lg-page`, but its primary use case is for integration with FreeBSD's
libc, wherein jemalloc is embedded.
* `--with-lg-hugepage=<lg-hugepage>`
Specify the base 2 log of the system huge page size. This option is useful
@@ -276,6 +269,11 @@ any of the following arguments (not a definitive list) to 'configure':
in the same process, which will almost certainly result in confusing runtime
crashes if pointers leak from one implementation to the other.
* `--disable-libdl`
Disable the usage of libdl, namely dlsym(3) which is required by the lazy
lock option. This can allow building static binaries.
The following environment variables (not a definitive list) impact configure's
behavior:
+62 -8
View File
@@ -47,6 +47,7 @@ REV := @rev@
install_suffix := @install_suffix@
ABI := @abi@
XSLTPROC := @XSLTPROC@
XSLROOT := @XSLROOT@
AUTOCONF := @AUTOCONF@
_RPATH = @RPATH@
RPATH = $(if $(1),$(call _RPATH,$(1)))
@@ -55,8 +56,12 @@ cfghdrs_out := @cfghdrs_out@
cfgoutputs_in := $(addprefix $(srcroot),@cfgoutputs_in@)
cfgoutputs_out := @cfgoutputs_out@
enable_autogen := @enable_autogen@
enable_doc := @enable_doc@
enable_shared := @enable_shared@
enable_static := @enable_static@
enable_prof := @enable_prof@
enable_zone_allocator := @enable_zone_allocator@
enable_experimental_smallocx := @enable_experimental_smallocx@
MALLOC_CONF := @JEMALLOC_CPREFIX@MALLOC_CONF
link_whole_archive := @link_whole_archive@
DSO_LDFLAGS = @DSO_LDFLAGS@
@@ -102,7 +107,7 @@ C_SRCS := $(srcroot)src/jemalloc.c \
$(srcroot)src/extent_dss.c \
$(srcroot)src/extent_mmap.c \
$(srcroot)src/hash.c \
$(srcroot)src/hooks.c \
$(srcroot)src/hook.c \
$(srcroot)src/large.c \
$(srcroot)src/log.c \
$(srcroot)src/malloc_io.c \
@@ -113,9 +118,12 @@ C_SRCS := $(srcroot)src/jemalloc.c \
$(srcroot)src/prng.c \
$(srcroot)src/prof.c \
$(srcroot)src/rtree.c \
$(srcroot)src/safety_check.c \
$(srcroot)src/stats.c \
$(srcroot)src/sc.c \
$(srcroot)src/sz.c \
$(srcroot)src/tcache.c \
$(srcroot)src/test_hooks.c \
$(srcroot)src/ticker.c \
$(srcroot)src/tsd.c \
$(srcroot)src/witness.c
@@ -165,14 +173,18 @@ TESTS_UNIT := \
$(srcroot)test/unit/background_thread_enable.c \
$(srcroot)test/unit/base.c \
$(srcroot)test/unit/bitmap.c \
$(srcroot)test/unit/bit_util.c \
$(srcroot)test/unit/binshard.c \
$(srcroot)test/unit/ckh.c \
$(srcroot)test/unit/decay.c \
$(srcroot)test/unit/div.c \
$(srcroot)test/unit/emitter.c \
$(srcroot)test/unit/extent_quantize.c \
$(srcroot)test/unit/extent_util.c \
$(srcroot)test/unit/fork.c \
$(srcroot)test/unit/hash.c \
$(srcroot)test/unit/hooks.c \
$(srcroot)test/unit/hook.c \
$(srcroot)test/unit/huge.c \
$(srcroot)test/unit/junk.c \
$(srcroot)test/unit/junk_alloc.c \
$(srcroot)test/unit/junk_free.c \
@@ -190,6 +202,7 @@ TESTS_UNIT := \
$(srcroot)test/unit/prof_active.c \
$(srcroot)test/unit/prof_gdump.c \
$(srcroot)test/unit/prof_idump.c \
$(srcroot)test/unit/prof_log.c \
$(srcroot)test/unit/prof_reset.c \
$(srcroot)test/unit/prof_tctx.c \
$(srcroot)test/unit/prof_thread_name.c \
@@ -198,13 +211,17 @@ TESTS_UNIT := \
$(srcroot)test/unit/rb.c \
$(srcroot)test/unit/retained.c \
$(srcroot)test/unit/rtree.c \
$(srcroot)test/unit/safety_check.c \
$(srcroot)test/unit/seq.c \
$(srcroot)test/unit/SFMT.c \
$(srcroot)test/unit/sc.c \
$(srcroot)test/unit/size_classes.c \
$(srcroot)test/unit/slab.c \
$(srcroot)test/unit/smoothstep.c \
$(srcroot)test/unit/spin.c \
$(srcroot)test/unit/stats.c \
$(srcroot)test/unit/stats_print.c \
$(srcroot)test/unit/test_hooks.c \
$(srcroot)test/unit/ticker.c \
$(srcroot)test/unit/nstime.c \
$(srcroot)test/unit/tsd.c \
@@ -217,15 +234,21 @@ endif
TESTS_INTEGRATION := $(srcroot)test/integration/aligned_alloc.c \
$(srcroot)test/integration/allocated.c \
$(srcroot)test/integration/extent.c \
$(srcroot)test/integration/malloc.c \
$(srcroot)test/integration/mallocx.c \
$(srcroot)test/integration/MALLOCX_ARENA.c \
$(srcroot)test/integration/overflow.c \
$(srcroot)test/integration/posix_memalign.c \
$(srcroot)test/integration/rallocx.c \
$(srcroot)test/integration/sdallocx.c \
$(srcroot)test/integration/slab_sizes.c \
$(srcroot)test/integration/thread_arena.c \
$(srcroot)test/integration/thread_tcache_enabled.c \
$(srcroot)test/integration/xallocx.c
ifeq (@enable_experimental_smallocx@, 1)
TESTS_INTEGRATION += \
$(srcroot)test/integration/smallocx.c
endif
ifeq (@enable_cxx@, 1)
CPP_SRCS := $(srcroot)src/jemalloc_cpp.cpp
TESTS_INTEGRATION_CPP := $(srcroot)test/integration/cpp/basic.cpp
@@ -233,7 +256,9 @@ else
CPP_SRCS :=
TESTS_INTEGRATION_CPP :=
endif
TESTS_STRESS := $(srcroot)test/stress/microbench.c
TESTS_STRESS := $(srcroot)test/stress/microbench.c \
$(srcroot)test/stress/hookbench.c
TESTS := $(TESTS_UNIT) $(TESTS_INTEGRATION) $(TESTS_INTEGRATION_CPP) $(TESTS_STRESS)
@@ -274,10 +299,24 @@ all: build_lib
dist: build_doc
$(objroot)doc/%.html : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/html.xsl
ifneq ($(XSLROOT),)
$(XSLTPROC) -o $@ $(objroot)doc/html.xsl $<
else
ifeq ($(wildcard $(DOCS_HTML)),)
@echo "<p>Missing xsltproc. Doc not built.</p>" > $@
endif
@echo "Missing xsltproc. "$@" not (re)built."
endif
$(objroot)doc/%.3 : $(objroot)doc/%.xml $(srcroot)doc/stylesheet.xsl $(objroot)doc/manpages.xsl
ifneq ($(XSLROOT),)
$(XSLTPROC) -o $@ $(objroot)doc/manpages.xsl $<
else
ifeq ($(wildcard $(DOCS_MAN3)),)
@echo "Missing xsltproc. Doc not built." > $@
endif
@echo "Missing xsltproc. "$@" not (re)built."
endif
build_doc_html: $(DOCS_HTML)
build_doc_man: $(DOCS_MAN3)
@@ -400,7 +439,7 @@ $(objroot)test/unit/%$(EXE): $(objroot)test/unit/%.$(O) $(C_JET_OBJS) $(C_TESTLI
$(objroot)test/integration/%$(EXE): $(objroot)test/integration/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB)
@mkdir -p $(@D)
$(CC) $(TEST_LD_MODE) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LJEMALLOC) $(LDFLAGS) $(filter-out -lm,$(filter -lrt -lpthread -lstdc++,$(LIBS))) $(LM) $(EXTRA_LDFLAGS)
$(CC) $(TEST_LD_MODE) $(LDTARGET) $(filter %.$(O),$^) $(call RPATH,$(objroot)lib) $(LJEMALLOC) $(LDFLAGS) $(filter-out -lm,$(filter -lrt -pthread -lstdc++,$(LIBS))) $(LM) $(EXTRA_LDFLAGS)
$(objroot)test/integration/cpp/%$(EXE): $(objroot)test/integration/cpp/%.$(O) $(C_TESTLIB_INTEGRATION_OBJS) $(C_UTIL_INTEGRATION_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(IMPORTLIB)
@mkdir -p $(@D)
@@ -412,7 +451,12 @@ $(objroot)test/stress/%$(EXE): $(objroot)test/stress/%.$(O) $(C_JET_OBJS) $(C_TE
build_lib_shared: $(DSOS)
build_lib_static: $(STATIC_LIBS)
build_lib: build_lib_shared build_lib_static
ifeq ($(enable_shared), 1)
build_lib: build_lib_shared
endif
ifeq ($(enable_static), 1)
build_lib: build_lib_static
endif
install_bin:
$(INSTALL) -d $(BINDIR)
@@ -449,7 +493,13 @@ install_lib_pc: $(PC)
$(INSTALL) -m 644 $$l $(LIBDIR)/pkgconfig; \
done
install_lib: install_lib_shared install_lib_static install_lib_pc
ifeq ($(enable_shared), 1)
install_lib: install_lib_shared
endif
ifeq ($(enable_static), 1)
install_lib: install_lib_static
endif
install_lib: install_lib_pc
install_doc_html:
$(INSTALL) -d $(DATADIR)/doc/jemalloc$(install_suffix)
@@ -465,9 +515,13 @@ install_doc_man:
$(INSTALL) -m 644 $$d $(MANDIR)/man3; \
done
install_doc: install_doc_html install_doc_man
install_doc: build_doc install_doc_html install_doc_man
install: install_bin install_include install_lib install_doc
install: install_bin install_include install_lib
ifeq ($(enable_doc), 1)
install: install_doc
endif
tests_unit: $(TESTS_UNIT:$(srcroot)%.c=$(objroot)%$(EXE))
tests_integration: $(TESTS_INTEGRATION:$(srcroot)%.c=$(objroot)%$(EXE)) $(TESTS_INTEGRATION_CPP:$(srcroot)%.cpp=$(objroot)%$(EXE))
+1 -1
View File
@@ -1 +1 @@
5.1.0-0-g0
5.2.1-0-g0
+2 -1
View File
@@ -2909,6 +2909,7 @@ sub RemoveUninterestingFrames {
'@JEMALLOC_PREFIX@xallocx',
'@JEMALLOC_PREFIX@dallocx',
'@JEMALLOC_PREFIX@sdallocx',
'@JEMALLOC_PREFIX@sdallocx_noflags',
'tc_calloc',
'tc_cfree',
'tc_malloc',
@@ -5366,7 +5367,7 @@ sub GetProcedureBoundaries {
my $demangle_flag = "";
my $cppfilt_flag = "";
my $to_devnull = ">$dev_null 2>&1";
if (system(ShellEscape($nm, "--demangle", "image") . $to_devnull) == 0) {
if (system(ShellEscape($nm, "--demangle", $image) . $to_devnull) == 0) {
# In this mode, we do "nm --demangle <foo>"
$demangle_flag = "--demangle";
$cppfilt_flag = "";
+623 -231
View File
File diff suppressed because it is too large. Load diff
+250 -138
View File
@@ -175,6 +175,9 @@ fi
],
XSLROOT="${DEFAULT_XSLROOT}"
)
if test "x$XSLTPROC" = "xfalse" ; then
XSLROOT=""
fi
AC_SUBST([XSLROOT])
dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
@@ -242,6 +245,7 @@ if test "x$GCC" = "xyes" ; then
fi
fi
JE_CFLAGS_ADD([-Wall])
JE_CFLAGS_ADD([-Wextra])
JE_CFLAGS_ADD([-Wshorten-64-to-32])
JE_CFLAGS_ADD([-Wsign-compare])
JE_CFLAGS_ADD([-Wundef])
@@ -289,6 +293,7 @@ if test "x$enable_cxx" = "x1" ; then
AX_CXX_COMPILE_STDCXX([14], [noext], [optional])
if test "x${HAVE_CXX14}" = "x1" ; then
JE_CXXFLAGS_ADD([-Wall])
JE_CXXFLAGS_ADD([-Wextra])
JE_CXXFLAGS_ADD([-g3])
SAVED_LIBS="${LIBS}"
@@ -536,6 +541,66 @@ AC_PROG_NM
AC_PROG_AWK
dnl ============================================================================
dnl jemalloc version.
dnl
AC_ARG_WITH([version],
[AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>],
[Version string])],
[
echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null
if test $? -eq 0 ; then
echo "$with_version" > "${objroot}VERSION"
else
echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null
if test $? -ne 0 ; then
AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION])
fi
fi
], [
dnl Set VERSION if source directory is inside a git repository.
if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
dnl Pattern globs aren't powerful enough to match both single- and
dnl double-digit version numbers, so iterate over patterns to support up
dnl to version 99.99.99 without any accidental matches.
for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
'[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
'[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
'[0-9][0-9].[0-9][0-9].[0-9]' \
'[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
(test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
if test $? -eq 0 ; then
mv "${objroot}VERSION.tmp" "${objroot}VERSION"
break
fi
done
fi
rm -f "${objroot}VERSION.tmp"
])
if test ! -e "${objroot}VERSION" ; then
if test ! -e "${srcroot}VERSION" ; then
AC_MSG_RESULT(
[Missing VERSION file, and unable to generate it; creating bogus VERSION])
echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
else
cp ${srcroot}VERSION ${objroot}VERSION
fi
fi
jemalloc_version=`cat "${objroot}VERSION"`
jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
AC_SUBST([jemalloc_version])
AC_SUBST([jemalloc_version_major])
AC_SUBST([jemalloc_version_minor])
AC_SUBST([jemalloc_version_bugfix])
AC_SUBST([jemalloc_version_nrev])
AC_SUBST([jemalloc_version_gid])
dnl Platform-specific settings. abi and RPATH can probably be determined
dnl programmatically, but doing so is error-prone, which makes it generally
dnl not worth the trouble.
@@ -673,6 +738,9 @@ case "${host}" in
libprefix=""
SOREV="${so}"
PIC_CFLAGS=""
if test "${LG_SIZEOF_PTR}" = "3"; then
default_retain="1"
fi
;;
*)
AC_MSG_RESULT([Unsupported operating system: ${host}])
@@ -786,6 +854,18 @@ if test "x${je_cv_format_printf}" = "xyes" ; then
AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ])
fi
dnl Check for format_arg(...) attribute support.
JE_CFLAGS_SAVE()
JE_CFLAGS_ADD([-Werror])
JE_CFLAGS_ADD([-herror_on_warning])
JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>],
[const char * __attribute__((__format_arg__(1))) foo(const char *format);],
[je_cv_format_arg])
JE_CFLAGS_RESTORE()
if test "x${je_cv_format_arg}" = "xyes" ; then
AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_ARG], [ ])
fi
dnl Support optional additions to rpath.
AC_ARG_WITH([rpath],
[AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
@@ -816,6 +896,49 @@ AC_PROG_RANLIB
AC_PATH_PROG([LD], [ld], [false], [$PATH])
AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
dnl Enable documentation
AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--enable-documentation], [Build documentation])],
if test "x$enable_doc" = "xno" ; then
enable_doc="0"
else
enable_doc="1"
fi
,
enable_doc="1"
)
AC_SUBST([enable_doc])
dnl Enable shared libs
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared], [Build shared libaries])],
if test "x$enable_shared" = "xno" ; then
enable_shared="0"
else
enable_shared="1"
fi
,
enable_shared="1"
)
AC_SUBST([enable_shared])
dnl Enable static libs
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static], [Build static libaries])],
if test "x$enable_static" = "xno" ; then
enable_static="0"
else
enable_static="1"
fi
,
enable_static="1"
)
AC_SUBST([enable_static])
if test "$enable_shared$enable_static" = "00" ; then
AC_MSG_ERROR([Please enable one of shared or static builds])
fi
dnl Perform no name mangling by default.
AC_ARG_WITH([mangling],
[AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
@@ -848,7 +971,7 @@ AC_ARG_WITH([export],
fi]
)
public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_message malloc_stats_print malloc_usable_size mallocx nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx"
public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_message malloc_stats_print malloc_usable_size mallocx smallocx_${jemalloc_version_gid} nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx"
dnl Check for additional platform-specific public API functions.
AC_CHECK_FUNC([memalign],
[AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
@@ -966,7 +1089,6 @@ cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
@@ -979,7 +1101,6 @@ cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols_jet.awk"
cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
@@ -991,6 +1112,10 @@ cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.i
cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in"
dnl ============================================================================
dnl jemalloc build options.
dnl
dnl Do not compile with debugging by default.
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
@@ -1043,6 +1168,22 @@ if test "x$enable_stats" = "x1" ; then
fi
AC_SUBST([enable_stats])
dnl Do not enable smallocx by default.
AC_ARG_ENABLE([experimental_smallocx],
[AS_HELP_STRING([--enable-experimental-smallocx], [Enable experimental smallocx API])],
[if test "x$enable_experimental_smallocx" = "xno" ; then
enable_experimental_smallocx="0"
else
enable_experimental_smallocx="1"
fi
],
[enable_experimental_smallocx="0"]
)
if test "x$enable_experimental_smallocx" = "x1" ; then
AC_DEFINE([JEMALLOC_EXPERIMENTAL_SMALLOCX_API])
fi
AC_SUBST([enable_experimental_smallocx])
dnl Do not enable profiling by default.
AC_ARG_ENABLE([prof],
[AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
@@ -1277,6 +1418,38 @@ if test "x$enable_log" = "x1" ; then
fi
AC_SUBST([enable_log])
dnl Do not use readlinkat by default
AC_ARG_ENABLE([readlinkat],
[AS_HELP_STRING([--enable-readlinkat], [Use readlinkat over readlink])],
[if test "x$enable_readlinkat" = "xno" ; then
enable_readlinkat="0"
else
enable_readlinkat="1"
fi
],
[enable_readlinkat="0"]
)
if test "x$enable_readlinkat" = "x1" ; then
AC_DEFINE([JEMALLOC_READLINKAT], [ ])
fi
AC_SUBST([enable_readlinkat])
dnl Avoid extra safety checks by default
AC_ARG_ENABLE([opt-safety-checks],
[AS_HELP_STRING([--enable-opt-safety-checks],
[Perform certain low-overhead checks, even in opt mode])],
[if test "x$enable_opt_safety_checks" = "xno" ; then
enable_opt_safety_checks="0"
else
enable_opt_safety_checks="1"
fi
],
[enable_opt_safety_checks="0"]
)
if test "x$enable_opt_safety_checks" = "x1" ; then
AC_DEFINE([JEMALLOC_OPT_SAFETY_CHECKS], [ ])
fi
AC_SUBST([enable_opt_safety_checks])
JE_COMPILABLE([a program using __builtin_unreachable], [
void foo (void) {
@@ -1333,6 +1506,21 @@ else
fi
fi
JE_COMPILABLE([a program using __builtin_popcountl], [
#include <stdio.h>
#include <strings.h>
#include <string.h>
], [
{
int rv = __builtin_popcountl(0x08);
printf("%d\n", rv);
}
], [je_cv_gcc_builtin_popcountl])
if test "x${je_cv_gcc_builtin_popcountl}" = "xyes" ; then
AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNT], [__builtin_popcount])
AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNTL], [__builtin_popcountl])
fi
AC_ARG_WITH([lg_quantum],
[AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
[Base 2 log of minimum allocation alignment])],
@@ -1430,70 +1618,20 @@ if test "x${LG_PAGE}" != "xundefined" -a \
fi
AC_DEFINE_UNQUOTED([LG_HUGEPAGE], [${je_cv_lg_hugepage}])
AC_ARG_WITH([lg_page_sizes],
[AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
[Base 2 logs of system page sizes to support])],
[LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
dnl ============================================================================
dnl jemalloc configuration.
dnl
AC_ARG_WITH([version],
[AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>],
[Version string])],
[
echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null
if test $? -eq 0 ; then
echo "$with_version" > "${objroot}VERSION"
else
echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null
if test $? -ne 0 ; then
AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION])
fi
fi
], [
dnl Set VERSION if source directory is inside a git repository.
if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
dnl Pattern globs aren't powerful enough to match both single- and
dnl double-digit version numbers, so iterate over patterns to support up
dnl to version 99.99.99 without any accidental matches.
for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
'[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
'[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
'[0-9][0-9].[0-9][0-9].[0-9]' \
'[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
(test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
if test $? -eq 0 ; then
mv "${objroot}VERSION.tmp" "${objroot}VERSION"
break
fi
done
fi
rm -f "${objroot}VERSION.tmp"
])
if test ! -e "${objroot}VERSION" ; then
if test ! -e "${srcroot}VERSION" ; then
AC_MSG_RESULT(
[Missing VERSION file, and unable to generate it; creating bogus VERSION])
echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
else
cp ${srcroot}VERSION ${objroot}VERSION
fi
dnl Enable libdl by default.
AC_ARG_ENABLE([libdl],
[AS_HELP_STRING([--disable-libdl],
[Do not use libdl])],
[if test "x$enable_libdl" = "xno" ; then
enable_libdl="0"
else
enable_libdl="1"
fi
jemalloc_version=`cat "${objroot}VERSION"`
jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
AC_SUBST([jemalloc_version])
AC_SUBST([jemalloc_version_major])
AC_SUBST([jemalloc_version_minor])
AC_SUBST([jemalloc_version_bugfix])
AC_SUBST([jemalloc_version_nrev])
AC_SUBST([jemalloc_version_gid])
],
[enable_libdl="1"]
)
AC_SUBST([libdl])
dnl ============================================================================
dnl Configure pthreads.
@@ -1503,20 +1641,26 @@ if test "x$abi" != "xpecoff" ; then
AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
dnl Some systems may embed pthreads functionality in libc; check for libpthread
dnl first, but try libc too before failing.
AC_CHECK_LIB([pthread], [pthread_create], [JE_APPEND_VS(LIBS, -lpthread)],
AC_CHECK_LIB([pthread], [pthread_create], [JE_APPEND_VS(LIBS, -pthread)],
[AC_SEARCH_LIBS([pthread_create], , ,
AC_MSG_ERROR([libpthread is missing]))])
wrap_syms="${wrap_syms} pthread_create"
have_pthread="1"
dnl Check if we have dlsym support.
have_dlsym="1"
AC_CHECK_HEADERS([dlfcn.h],
AC_CHECK_FUNC([dlsym], [],
[AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])]),
[have_dlsym="0"])
if test "x$have_dlsym" = "x1" ; then
AC_DEFINE([JEMALLOC_HAVE_DLSYM], [ ])
dnl Check if we have dlsym support.
if test "x$enable_libdl" = "x1" ; then
have_dlsym="1"
AC_CHECK_HEADERS([dlfcn.h],
AC_CHECK_FUNC([dlsym], [],
[AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])]),
[have_dlsym="0"])
if test "x$have_dlsym" = "x1" ; then
AC_DEFINE([JEMALLOC_HAVE_DLSYM], [ ])
fi
else
have_dlsym="0"
fi
JE_COMPILABLE([pthread_atfork(3)], [
#include <pthread.h>
], [
@@ -1780,6 +1924,19 @@ JE_COMPILABLE([GCC __atomic atomics], [
], [je_cv_gcc_atomic_atomics])
if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then
AC_DEFINE([JEMALLOC_GCC_ATOMIC_ATOMICS])
dnl check for 8-bit atomic support
JE_COMPILABLE([GCC 8-bit __atomic atomics], [
], [
unsigned char x = 0;
int val = 1;
int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED);
int after_add = (int)x;
return after_add == 1;
], [je_cv_gcc_u8_atomic_atomics])
if test "x${je_cv_gcc_u8_atomic_atomics}" = "xyes" ; then
AC_DEFINE([JEMALLOC_GCC_U8_ATOMIC_ATOMICS])
fi
fi
dnl ============================================================================
@@ -1794,12 +1951,24 @@ JE_COMPILABLE([GCC __sync atomics], [
], [je_cv_gcc_sync_atomics])
if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then
AC_DEFINE([JEMALLOC_GCC_SYNC_ATOMICS])
dnl check for 8-bit atomic support
JE_COMPILABLE([GCC 8-bit __sync atomics], [
], [
unsigned char x = 0;
int before_add = __sync_fetch_and_add(&x, 1);
int after_add = (int)x;
return (before_add == 0) && (after_add == 1);
], [je_cv_gcc_u8_sync_atomics])
if test "x${je_cv_gcc_u8_sync_atomics}" = "xyes" ; then
AC_DEFINE([JEMALLOC_GCC_U8_SYNC_ATOMICS])
fi
fi
dnl ============================================================================
dnl Check for atomic(3) operations as provided on Darwin.
dnl We need this not for the atomic operations (which are provided above), but
dnl rather for the OSSpinLock type it exposes.
dnl rather for the OS_unfair_lock type it exposes.
JE_COMPILABLE([Darwin OSAtomic*()], [
#include <libkern/OSAtomic.h>
@@ -1870,7 +2039,7 @@ if test "x${je_cv_madvise}" = "xyes" ; then
if test "x${je_cv_madv_dontdump}" = "xyes" ; then
AC_DEFINE([JEMALLOC_MADVISE_DONTDUMP], [ ])
fi
dnl Check for madvise(..., MADV_[NO]HUGEPAGE).
JE_COMPILABLE([madvise(..., MADV_[[NO]]HUGEPAGE)], [
#include <sys/mman.h>
@@ -1889,40 +2058,6 @@ case "${host_cpu}" in
esac
fi
dnl ============================================================================
dnl Check whether __sync_{add,sub}_and_fetch() are available despite
dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
[je_cv_sync_compare_and_swap_$2],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <stdint.h>
],
[
#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
{
uint$1_t x$1 = 0;
__sync_add_and_fetch(&x$1, 42);
__sync_sub_and_fetch(&x$1, 1);
}
#else
#error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
#endif
])],
[je_cv_sync_compare_and_swap_$2=yes],
[je_cv_sync_compare_and_swap_$2=no])])
if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
fi
])
if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
fi
dnl ============================================================================
dnl Check for __builtin_clz() and __builtin_clzl().
@@ -1965,21 +2100,6 @@ if test "x${je_cv_os_unfair_lock}" = "xyes" ; then
AC_DEFINE([JEMALLOC_OS_UNFAIR_LOCK], [ ])
fi
dnl ============================================================================
dnl Check for spinlock(3) operations as provided on Darwin.
JE_COMPILABLE([Darwin OSSpin*()], [
#include <libkern/OSAtomic.h>
#include <inttypes.h>
], [
OSSpinLock lock = 0;
OSSpinLockLock(&lock);
OSSpinLockUnlock(&lock);
], [je_cv_osspin])
if test "x${je_cv_osspin}" = "xyes" ; then
AC_DEFINE([JEMALLOC_OSSPIN], [ ])
fi
dnl ============================================================================
dnl Darwin-related configuration.
@@ -2032,9 +2152,7 @@ fi
dnl ============================================================================
dnl Enable background threads if possible.
if test "x${have_pthread}" = "x1" -a "x${have_dlsym}" = "x1" \
-a "x${je_cv_os_unfair_lock}" != "xyes" \
-a "x${je_cv_osspin}" != "xyes" ; then
if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" ; then
AC_DEFINE([JEMALLOC_BACKGROUND_THREAD])
fi
@@ -2175,16 +2293,6 @@ AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
srcdir="${srcdir}"
objroot="${objroot}"
])
AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
mkdir -p "${objroot}include/jemalloc/internal"
"${SHELL}" "${srcdir}/include/jemalloc/internal/size_classes.sh" "${LG_QUANTA}" 3 "${LG_PAGE_SIZES}" 2 > "${objroot}include/jemalloc/internal/size_classes.h"
], [
SHELL="${SHELL}"
srcdir="${srcdir}"
objroot="${objroot}"
LG_QUANTA="${LG_QUANTA}"
LG_PAGE_SIZES="${LG_PAGE_SIZES}"
])
AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
mkdir -p "${objroot}include/jemalloc"
cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
@@ -2277,9 +2385,13 @@ AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
AC_MSG_RESULT([install_suffix : ${install_suffix}])
AC_MSG_RESULT([malloc_conf : ${config_malloc_conf}])
AC_MSG_RESULT([documentation : ${enable_doc}])
AC_MSG_RESULT([shared libs : ${enable_shared}])
AC_MSG_RESULT([static libs : ${enable_static}])
AC_MSG_RESULT([autogen : ${enable_autogen}])
AC_MSG_RESULT([debug : ${enable_debug}])
AC_MSG_RESULT([stats : ${enable_stats}])
AC_MSG_RESULT([experimetal_smallocx : ${enable_experimental_smallocx}])
AC_MSG_RESULT([prof : ${enable_prof}])
AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
+156 -22
View File
@@ -424,7 +424,7 @@ for (i = 0; i < nbins; i++) {
called repeatedly. General information that never changes during
execution can be omitted by specifying <quote>g</quote> as a character
within the <parameter>opts</parameter> string. Note that
<function>malloc_message()</function> uses the
<function>malloc_stats_print()</function> uses the
<function>mallctl*()</function> functions internally, so inconsistent
statistics can be reported if multiple threads use these functions
simultaneously. If <option>--enable-stats</option> is specified during
@@ -433,10 +433,11 @@ for (i = 0; i < nbins; i++) {
arena statistics, respectively; <quote>b</quote> and <quote>l</quote> can
be specified to omit per size class statistics for bins and large objects,
respectively; <quote>x</quote> can be specified to omit all mutex
statistics. Unrecognized characters are silently ignored. Note that
thread caching may prevent some statistics from being completely up to
date, since extra locking would be required to merge counters that track
thread cache operations.</para>
statistics; <quote>e</quote> can be used to omit extent statistics.
Unrecognized characters are silently ignored. Note that thread caching
may prevent some statistics from being completely up to date, since extra
locking would be required to merge counters that track thread cache
operations.</para>
<para>The <function>malloc_usable_size()</function> function
returns the usable size of the allocation pointed to by
@@ -903,6 +904,23 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
</para></listitem>
</varlistentry>
<varlistentry id="opt.confirm_conf">
<term>
<mallctl>opt.confirm_conf</mallctl>
(<type>bool</type>)
<literal>r-</literal>
</term>
<listitem><para>Confirm-runtime-options-when-program-starts
enabled/disabled. If true, the string specified via
<option>--with-malloc-conf</option>, the string pointed to by the
global variable <varname>malloc_conf</varname>, the <quote>name</quote>
of the file referenced by the symbolic link named
<filename class="symlink">/etc/malloc.conf</filename>, and the value of
the environment variable <envar>MALLOC_CONF</envar>, will be printed in
order. Then, each option being set will be individually printed. This
option is disabled by default.</para></listitem>
</varlistentry>
<varlistentry id="opt.abort_conf">
<term>
<mallctl>opt.abort_conf</mallctl>
@@ -943,16 +961,19 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
<citerefentry><refentrytitle>munmap</refentrytitle>
<manvolnum>2</manvolnum></citerefentry> or equivalent (see <link
linkend="stats.retained">stats.retained</link> for related details).
This option is disabled by default unless discarding virtual memory is
known to trigger
platform-specific performance problems, e.g. for [64-bit] Linux, which
has a quirk in its virtual memory allocation algorithm that causes
semi-permanent VM map holes under normal jemalloc operation. Although
<citerefentry><refentrytitle>munmap</refentrytitle>
<manvolnum>2</manvolnum></citerefentry> causes issues on 32-bit Linux as
well, retaining virtual memory for 32-bit Linux is disabled by default
due to the practical possibility of address space exhaustion.
</para></listitem>
It also makes jemalloc use <citerefentry>
<refentrytitle>mmap</refentrytitle><manvolnum>2</manvolnum>
</citerefentry> or equivalent in a more greedy way, mapping larger
chunks in one go. This option is disabled by default unless discarding
virtual memory is known to trigger platform-specific performance
problems, namely 1) for [64-bit] Linux, which has a quirk in its virtual
memory allocation algorithm that causes semi-permanent VM map holes
under normal jemalloc operation; and 2) for [64-bit] Windows, which
disallows split / merged regions with
<parameter><constant>MEM_RELEASE</constant></parameter>. Although the
same issues may present on 32-bit platforms as well, retaining virtual
memory for 32-bit Linux and Windows is disabled by default due to the
practical possibility of address space exhaustion. </para></listitem>
</varlistentry>
<varlistentry id="opt.dss">
@@ -988,6 +1009,24 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
number of CPUs, or one if there is a single CPU.</para></listitem>
</varlistentry>
<varlistentry id="opt.oversize_threshold">
<term>
<mallctl>opt.oversize_threshold</mallctl>
(<type>size_t</type>)
<literal>r-</literal>
</term>
<listitem><para>The threshold in bytes of which requests are considered
oversize. Allocation requests with greater sizes are fulfilled from a
dedicated arena (automatically managed, however not within
<literal>narenas</literal>), in order to reduce fragmentation by not
mixing huge allocations with small ones. In addition, the decay API
guarantees on the extents greater than the specified threshold may be
overridden. Note that requests with arena index specified via
<constant>MALLOCX_ARENA</constant>, or threads associated with explicit
arenas will not be considered. The default threshold is 8MiB. Values
not within large size classes disables this feature.</para></listitem>
</varlistentry>
<varlistentry id="opt.percpu_arena">
<term>
<mallctl>opt.percpu_arena</mallctl>
@@ -1009,7 +1048,7 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
<varlistentry id="opt.background_thread">
<term>
<mallctl>opt.background_thread</mallctl>
(<type>const bool</type>)
(<type>bool</type>)
<literal>r-</literal>
</term>
<listitem><para>Internal background worker threads enabled/disabled.
@@ -1024,7 +1063,7 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
<varlistentry id="opt.max_background_threads">
<term>
<mallctl>opt.max_background_threads</mallctl>
(<type>const size_t</type>)
(<type>size_t</type>)
<literal>r-</literal>
</term>
<listitem><para>Maximum number of background threads that will be created
@@ -1055,7 +1094,11 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
linkend="arena.i.dirty_decay_ms"><mallctl>arena.&lt;i&gt;.dirty_decay_ms</mallctl></link>
for related dynamic control options. See <link
linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link>
for a description of muzzy pages.</para></listitem>
for a description of muzzy pages.for a description of muzzy pages. Note
that when the <link
linkend="opt.oversize_threshold"><mallctl>oversize_threshold</mallctl></link>
feature is enabled, the arenas reserved for oversize requests may have
its own default decay settings.</para></listitem>
</varlistentry>
<varlistentry id="opt.muzzy_decay_ms">
@@ -1763,10 +1806,11 @@ malloc_conf = "xmalloc:true";]]></programlisting>
to control allocation for arenas explicitly created via <link
linkend="arenas.create"><mallctl>arenas.create</mallctl></link> such
that all extents originate from an application-supplied extent allocator
(by specifying the custom extent hook functions during arena creation),
but the automatically created arenas will have already created extents
prior to the application having an opportunity to take over extent
allocation.</para>
(by specifying the custom extent hook functions during arena creation).
However, the API guarantees for the automatically created arenas may be
relaxed -- hooks set there may be called in a "best effort" fashion; in
addition there may be extents created prior to the application having an
opportunity to take over extent allocation.</para>
<programlisting language="C"><![CDATA[
typedef extent_hooks_s extent_hooks_t;
@@ -2593,6 +2637,17 @@ struct extent_hooks_s {
details.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.extent_avail">
<term>
<mallctl>stats.arenas.&lt;i&gt;.extent_avail</mallctl>
(<type>size_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para>Number of allocated (but unused) extent structs in this
arena.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.base">
<term>
<mallctl>stats.arenas.&lt;i&gt;.base</mallctl>
@@ -2760,6 +2815,28 @@ struct extent_hooks_s {
all bin size classes.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.small.nfills">
<term>
<mallctl>stats.arenas.&lt;i&gt;.small.nfills</mallctl>
(<type>uint64_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para>Cumulative number of tcache fills by all small size
classes.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.small.nflushes">
<term>
<mallctl>stats.arenas.&lt;i&gt;.small.nflushes</mallctl>
(<type>uint64_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para>Cumulative number of tcache flushes by all small size
classes.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.large.allocated">
<term>
<mallctl>stats.arenas.&lt;i&gt;.large.allocated</mallctl>
@@ -2810,6 +2887,28 @@ struct extent_hooks_s {
all large size classes.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.large.nfills">
<term>
<mallctl>stats.arenas.&lt;i&gt;.large.nfills</mallctl>
(<type>uint64_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para>Cumulative number of tcache fills by all large size
classes.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.large.nflushes">
<term>
<mallctl>stats.arenas.&lt;i&gt;.large.nflushes</mallctl>
(<type>uint64_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para>Cumulative number of tcache flushes by all large size
classes.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.bins.j.nmalloc">
<term>
<mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nmalloc</mallctl>
@@ -2909,6 +3008,17 @@ struct extent_hooks_s {
<listitem><para>Current number of slabs.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.bins.j.nonfull_slabs">
<term>
<mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nonfull_slabs</mallctl>
(<type>size_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para>Current number of nonfull slabs.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.bins.mutex">
<term>
<mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.mutex.{counter}</mallctl>
@@ -2922,6 +3032,30 @@ struct extent_hooks_s {
counters</link>.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.extents.n">
<term>
<mallctl>stats.arenas.&lt;i&gt;.extents.&lt;j&gt;.n{extent_type}</mallctl>
(<type>size_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para> Number of extents of the given type in this arena in
the bucket corresponding to page size index &lt;j&gt;. The extent type
is one of dirty, muzzy, or retained.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.extents.bytes">
<term>
<mallctl>stats.arenas.&lt;i&gt;.extents.&lt;j&gt;.{extent_type}_bytes</mallctl>
(<type>size_t</type>)
<literal>r-</literal>
[<option>--enable-stats</option>]
</term>
<listitem><para> Sum of the bytes managed by extents of the given type
in this arena in the bucket corresponding to page size index &lt;j&gt;.
The extent type is one of dirty, muzzy, or retained.</para></listitem>
</varlistentry>
<varlistentry id="stats.arenas.i.lextents.j.nmalloc">
<term>
<mallctl>stats.arenas.&lt;i&gt;.lextents.&lt;j&gt;.nmalloc</mallctl>
+18 -8
View File
@@ -3,8 +3,8 @@
#include "jemalloc/internal/bin.h"
#include "jemalloc/internal/extent_dss.h"
#include "jemalloc/internal/hook.h"
#include "jemalloc/internal/pages.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/stats.h"
extern ssize_t opt_dirty_decay_ms;
@@ -16,13 +16,17 @@ extern const char *percpu_arena_mode_names[];
extern const uint64_t h_steps[SMOOTHSTEP_NSTEPS];
extern malloc_mutex_t arenas_lock;
extern size_t opt_oversize_threshold;
extern size_t oversize_threshold;
void arena_basic_stats_merge(tsdn_t *tsdn, arena_t *arena,
unsigned *nthreads, const char **dss, ssize_t *dirty_decay_ms,
ssize_t *muzzy_decay_ms, size_t *nactive, size_t *ndirty, size_t *nmuzzy);
void arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
const char **dss, ssize_t *dirty_decay_ms, ssize_t *muzzy_decay_ms,
size_t *nactive, size_t *ndirty, size_t *nmuzzy, arena_stats_t *astats,
bin_stats_t *bstats, arena_stats_large_t *lstats);
bin_stats_t *bstats, arena_stats_large_t *lstats,
arena_stats_extents_t *estats);
void arena_extents_dirty_dalloc(tsdn_t *tsdn, arena_t *arena,
extent_hooks_t **r_extent_hooks, extent_t *extent);
#ifdef JEMALLOC_JET
@@ -56,16 +60,17 @@ void *arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size,
szind_t ind, bool zero);
void *arena_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize,
size_t alignment, bool zero, tcache_t *tcache);
void arena_prof_promote(tsdn_t *tsdn, const void *ptr, size_t usize);
void arena_prof_promote(tsdn_t *tsdn, void *ptr, size_t usize);
void arena_dalloc_promoted(tsdn_t *tsdn, void *ptr, tcache_t *tcache,
bool slow_path);
void arena_dalloc_bin_junked_locked(tsdn_t *tsdn, arena_t *arena,
extent_t *extent, void *ptr);
void arena_dalloc_bin_junked_locked(tsdn_t *tsdn, arena_t *arena, bin_t *bin,
szind_t binind, extent_t *extent, void *ptr);
void arena_dalloc_small(tsdn_t *tsdn, void *ptr);
bool arena_ralloc_no_move(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size,
size_t extra, bool zero);
size_t extra, bool zero, size_t *newsize);
void *arena_ralloc(tsdn_t *tsdn, arena_t *arena, void *ptr, size_t oldsize,
size_t size, size_t alignment, bool zero, tcache_t *tcache);
size_t size, size_t alignment, bool zero, tcache_t *tcache,
hook_ralloc_args_t *hook_args);
dss_prec_t arena_dss_prec_get(arena_t *arena);
bool arena_dss_prec_set(arena_t *arena, dss_prec_t dss_prec);
ssize_t arena_dirty_decay_ms_default_get(void);
@@ -79,7 +84,12 @@ void arena_nthreads_inc(arena_t *arena, bool internal);
void arena_nthreads_dec(arena_t *arena, bool internal);
size_t arena_extent_sn_next(arena_t *arena);
arena_t *arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks);
void arena_boot(void);
bool arena_init_huge(void);
bool arena_is_huge(unsigned arena_ind);
arena_t *arena_choose_huge(tsd_t *tsd);
bin_t *arena_bin_choose_lock(tsdn_t *tsdn, arena_t *arena, szind_t binind,
unsigned *binshard);
void arena_boot(sc_data_t *sc_data);
void arena_prefork0(tsdn_t *tsdn, arena_t *arena);
void arena_prefork1(tsdn_t *tsdn, arena_t *arena);
void arena_prefork2(tsdn_t *tsdn, arena_t *arena);
+115 -42
View File
@@ -4,10 +4,36 @@
#include "jemalloc/internal/jemalloc_internal_types.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/rtree.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/sz.h"
#include "jemalloc/internal/ticker.h"
JEMALLOC_ALWAYS_INLINE bool
arena_has_default_hooks(arena_t *arena) {
return (extent_hooks_get(arena) == &extent_hooks_default);
}
JEMALLOC_ALWAYS_INLINE arena_t *
arena_choose_maybe_huge(tsd_t *tsd, arena_t *arena, size_t size) {
if (arena != NULL) {
return arena;
}
/*
* For huge allocations, use the dedicated huge arena if both are true:
* 1) is using auto arena selection (i.e. arena == NULL), and 2) the
* thread is not assigned to a manual arena.
*/
if (unlikely(size >= oversize_threshold)) {
arena_t *tsd_arena = tsd_arena_get(tsd);
if (tsd_arena == NULL || arena_is_auto(tsd_arena)) {
return arena_choose_huge(tsd);
}
}
return arena_choose(tsd, NULL);
}
JEMALLOC_ALWAYS_INLINE prof_tctx_t *
arena_prof_tctx_get(tsdn_t *tsdn, const void *ptr, alloc_ctx_t *alloc_ctx) {
cassert(config_prof);
@@ -28,7 +54,7 @@ arena_prof_tctx_get(tsdn_t *tsdn, const void *ptr, alloc_ctx_t *alloc_ctx) {
}
JEMALLOC_ALWAYS_INLINE void
arena_prof_tctx_set(tsdn_t *tsdn, const void *ptr, UNUSED size_t usize,
arena_prof_tctx_set(tsdn_t *tsdn, const void *ptr, size_t usize,
alloc_ctx_t *alloc_ctx, prof_tctx_t *tctx) {
cassert(config_prof);
assert(ptr != NULL);
@@ -47,7 +73,7 @@ arena_prof_tctx_set(tsdn_t *tsdn, const void *ptr, UNUSED size_t usize,
}
static inline void
arena_prof_tctx_reset(tsdn_t *tsdn, const void *ptr, UNUSED prof_tctx_t *tctx) {
arena_prof_tctx_reset(tsdn_t *tsdn, const void *ptr, prof_tctx_t *tctx) {
cassert(config_prof);
assert(ptr != NULL);
@@ -57,6 +83,32 @@ arena_prof_tctx_reset(tsdn_t *tsdn, const void *ptr, UNUSED prof_tctx_t *tctx) {
large_prof_tctx_reset(tsdn, extent);
}
JEMALLOC_ALWAYS_INLINE nstime_t
arena_prof_alloc_time_get(tsdn_t *tsdn, const void *ptr,
alloc_ctx_t *alloc_ctx) {
cassert(config_prof);
assert(ptr != NULL);
extent_t *extent = iealloc(tsdn, ptr);
/*
* Unlike arena_prof_prof_tctx_{get, set}, we only call this once we're
* sure we have a sampled allocation.
*/
assert(!extent_slab_get(extent));
return large_prof_alloc_time_get(extent);
}
JEMALLOC_ALWAYS_INLINE void
arena_prof_alloc_time_set(tsdn_t *tsdn, const void *ptr, alloc_ctx_t *alloc_ctx,
nstime_t t) {
cassert(config_prof);
assert(ptr != NULL);
extent_t *extent = iealloc(tsdn, ptr);
assert(!extent_slab_get(extent));
large_prof_alloc_time_set(extent, t);
}
JEMALLOC_ALWAYS_INLINE void
arena_decay_ticks(tsdn_t *tsdn, arena_t *arena, unsigned nticks) {
tsd_t *tsd;
@@ -83,14 +135,33 @@ arena_decay_tick(tsdn_t *tsdn, arena_t *arena) {
arena_decay_ticks(tsdn, arena, 1);
}
/* Purge a single extent to retained / unmapped directly. */
JEMALLOC_ALWAYS_INLINE void
arena_decay_extent(tsdn_t *tsdn,arena_t *arena, extent_hooks_t **r_extent_hooks,
extent_t *extent) {
size_t extent_size = extent_size_get(extent);
extent_dalloc_wrapper(tsdn, arena,
r_extent_hooks, extent);
if (config_stats) {
/* Update stats accordingly. */
arena_stats_lock(tsdn, &arena->stats);
arena_stats_add_u64(tsdn, &arena->stats,
&arena->decay_dirty.stats->nmadvise, 1);
arena_stats_add_u64(tsdn, &arena->stats,
&arena->decay_dirty.stats->purged, extent_size >> LG_PAGE);
arena_stats_sub_zu(tsdn, &arena->stats, &arena->stats.mapped,
extent_size);
arena_stats_unlock(tsdn, &arena->stats);
}
}
JEMALLOC_ALWAYS_INLINE void *
arena_malloc(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind, bool zero,
tcache_t *tcache, bool slow_path) {
assert(!tsdn_null(tsdn) || tcache == NULL);
assert(size != 0);
if (likely(tcache != NULL)) {
if (likely(size <= SMALL_MAXCLASS)) {
if (likely(size <= SC_SMALL_MAXCLASS)) {
return tcache_alloc_small(tsdn_tsd(tsdn), arena,
tcache, size, ind, zero, slow_path);
}
@@ -119,7 +190,7 @@ arena_salloc(tsdn_t *tsdn, const void *ptr) {
szind_t szind = rtree_szind_read(tsdn, &extents_rtree, rtree_ctx,
(uintptr_t)ptr, true);
assert(szind != NSIZES);
assert(szind != SC_NSIZES);
return sz_index2size(szind);
}
@@ -152,11 +223,21 @@ arena_vsalloc(tsdn_t *tsdn, const void *ptr) {
/* Only slab members should be looked up via interior pointers. */
assert(extent_addr_get(extent) == ptr || extent_slab_get(extent));
assert(szind != NSIZES);
assert(szind != SC_NSIZES);
return sz_index2size(szind);
}
static inline void
arena_dalloc_large_no_tcache(tsdn_t *tsdn, void *ptr, szind_t szind) {
if (config_prof && unlikely(szind < SC_NBINS)) {
arena_dalloc_promoted(tsdn, ptr, NULL, true);
} else {
extent_t *extent = iealloc(tsdn, ptr);
large_dalloc(tsdn, extent);
}
}
static inline void
arena_dalloc_no_tcache(tsdn_t *tsdn, void *ptr) {
assert(ptr != NULL);
@@ -173,13 +254,28 @@ arena_dalloc_no_tcache(tsdn_t *tsdn, void *ptr) {
extent_t *extent = rtree_extent_read(tsdn, &extents_rtree,
rtree_ctx, (uintptr_t)ptr, true);
assert(szind == extent_szind_get(extent));
assert(szind < NSIZES);
assert(szind < SC_NSIZES);
assert(slab == extent_slab_get(extent));
}
if (likely(slab)) {
/* Small allocation. */
arena_dalloc_small(tsdn, ptr);
} else {
arena_dalloc_large_no_tcache(tsdn, ptr, szind);
}
}
JEMALLOC_ALWAYS_INLINE void
arena_dalloc_large(tsdn_t *tsdn, void *ptr, tcache_t *tcache, szind_t szind,
bool slow_path) {
if (szind < nhbins) {
if (config_prof && unlikely(szind < SC_NBINS)) {
arena_dalloc_promoted(tsdn, ptr, tcache, slow_path);
} else {
tcache_dalloc_large(tsdn_tsd(tsdn), tcache, ptr, szind,
slow_path);
}
} else {
extent_t *extent = iealloc(tsdn, ptr);
large_dalloc(tsdn, extent);
@@ -203,7 +299,7 @@ arena_dalloc(tsdn_t *tsdn, void *ptr, tcache_t *tcache,
if (alloc_ctx != NULL) {
szind = alloc_ctx->szind;
slab = alloc_ctx->slab;
assert(szind != NSIZES);
assert(szind != SC_NSIZES);
} else {
rtree_ctx = tsd_rtree_ctx(tsdn_tsd(tsdn));
rtree_szind_slab_read(tsdn, &extents_rtree, rtree_ctx,
@@ -215,7 +311,7 @@ arena_dalloc(tsdn_t *tsdn, void *ptr, tcache_t *tcache,
extent_t *extent = rtree_extent_read(tsdn, &extents_rtree,
rtree_ctx, (uintptr_t)ptr, true);
assert(szind == extent_szind_get(extent));
assert(szind < NSIZES);
assert(szind < SC_NSIZES);
assert(slab == extent_slab_get(extent));
}
@@ -224,25 +320,14 @@ arena_dalloc(tsdn_t *tsdn, void *ptr, tcache_t *tcache,
tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, szind,
slow_path);
} else {
if (szind < nhbins) {
if (config_prof && unlikely(szind < NBINS)) {
arena_dalloc_promoted(tsdn, ptr, tcache,
slow_path);
} else {
tcache_dalloc_large(tsdn_tsd(tsdn), tcache, ptr,
szind, slow_path);
}
} else {
extent_t *extent = iealloc(tsdn, ptr);
large_dalloc(tsdn, extent);
}
arena_dalloc_large(tsdn, ptr, tcache, szind, slow_path);
}
}
static inline void
arena_sdalloc_no_tcache(tsdn_t *tsdn, void *ptr, size_t size) {
assert(ptr != NULL);
assert(size <= LARGE_MAXCLASS);
assert(size <= SC_LARGE_MAXCLASS);
szind_t szind;
bool slab;
@@ -252,7 +337,7 @@ arena_sdalloc_no_tcache(tsdn_t *tsdn, void *ptr, size_t size) {
* object, so base szind and slab on the given size.
*/
szind = sz_size2index(size);
slab = (szind < NBINS);
slab = (szind < SC_NBINS);
}
if ((config_prof && opt_prof) || config_debug) {
@@ -264,7 +349,7 @@ arena_sdalloc_no_tcache(tsdn_t *tsdn, void *ptr, size_t size) {
(uintptr_t)ptr, true, &szind, &slab);
assert(szind == sz_size2index(size));
assert((config_prof && opt_prof) || slab == (szind < NBINS));
assert((config_prof && opt_prof) || slab == (szind < SC_NBINS));
if (config_debug) {
extent_t *extent = rtree_extent_read(tsdn,
@@ -278,8 +363,7 @@ arena_sdalloc_no_tcache(tsdn_t *tsdn, void *ptr, size_t size) {
/* Small allocation. */
arena_dalloc_small(tsdn, ptr);
} else {
extent_t *extent = iealloc(tsdn, ptr);
large_dalloc(tsdn, extent);
arena_dalloc_large_no_tcache(tsdn, ptr, szind);
}
}
@@ -288,7 +372,7 @@ arena_sdalloc(tsdn_t *tsdn, void *ptr, size_t size, tcache_t *tcache,
alloc_ctx_t *alloc_ctx, bool slow_path) {
assert(!tsdn_null(tsdn) || tcache == NULL);
assert(ptr != NULL);
assert(size <= LARGE_MAXCLASS);
assert(size <= SC_LARGE_MAXCLASS);
if (unlikely(tcache == NULL)) {
arena_sdalloc_no_tcache(tsdn, ptr, size);
@@ -297,7 +381,7 @@ arena_sdalloc(tsdn_t *tsdn, void *ptr, size_t size, tcache_t *tcache,
szind_t szind;
bool slab;
UNUSED alloc_ctx_t local_ctx;
alloc_ctx_t local_ctx;
if (config_prof && opt_prof) {
if (alloc_ctx == NULL) {
/* Uncommon case and should be a static check. */
@@ -318,7 +402,7 @@ arena_sdalloc(tsdn_t *tsdn, void *ptr, size_t size, tcache_t *tcache,
* object, so base szind and slab on the given size.
*/
szind = sz_size2index(size);
slab = (szind < NBINS);
slab = (szind < SC_NBINS);
}
if (config_debug) {
@@ -336,18 +420,7 @@ arena_sdalloc(tsdn_t *tsdn, void *ptr, size_t size, tcache_t *tcache,
tcache_dalloc_small(tsdn_tsd(tsdn), tcache, ptr, szind,
slow_path);
} else {
if (szind < nhbins) {
if (config_prof && unlikely(szind < NBINS)) {
arena_dalloc_promoted(tsdn, ptr, tcache,
slow_path);
} else {
tcache_dalloc_large(tsdn_tsd(tsdn),
tcache, ptr, szind, slow_path);
}
} else {
extent_t *extent = iealloc(tsdn, ptr);
large_dalloc(tsdn, extent);
}
arena_dalloc_large(tsdn, ptr, tcache, szind, slow_path);
}
}
+49 -15
View File
@@ -4,7 +4,9 @@
#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/mutex_prof.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
/*
* In those architectures that support 64-bit atomics, we use atomic updates for
@@ -33,6 +35,13 @@ struct arena_stats_large_s {
* periodically merges into this counter.
*/
arena_stats_u64_t nrequests; /* Partially derived. */
/*
* Number of tcache fills / flushes for large (similarly, periodically
* merged). Note that there is no large tcache batch-fill currently
* (i.e. only fill 1 at a time); however flush may be batched.
*/
arena_stats_u64_t nfills; /* Partially derived. */
arena_stats_u64_t nflushes; /* Partially derived. */
/* Current number of allocations of this size class. */
size_t curlextents; /* Derived. */
@@ -48,6 +57,22 @@ struct arena_stats_decay_s {
arena_stats_u64_t purged;
};
typedef struct arena_stats_extents_s arena_stats_extents_t;
struct arena_stats_extents_s {
/*
* Stats for a given index in the range [0, SC_NPSIZES] in an extents_t.
* We track both bytes and # of extents: two extents in the same bucket
* may have different sizes if adjacent size classes differ by more than
* a page, so bytes cannot always be derived from # of extents.
*/
atomic_zu_t ndirty;
atomic_zu_t dirty_bytes;
atomic_zu_t nmuzzy;
atomic_zu_t muzzy_bytes;
atomic_zu_t nretained;
atomic_zu_t retained_bytes;
};
/*
* Arena stats. Note that fields marked "derived" are not directly maintained
* within the arena code; rather their values are derived during stats merge
@@ -69,6 +94,9 @@ struct arena_stats_s {
*/
atomic_zu_t retained; /* Derived. */
/* Number of extent_t structs allocated by base, but not being used. */
atomic_zu_t extent_avail;
arena_stats_decay_t decay_dirty;
arena_stats_decay_t decay_muzzy;
@@ -80,22 +108,27 @@ struct arena_stats_s {
atomic_zu_t allocated_large; /* Derived. */
arena_stats_u64_t nmalloc_large; /* Derived. */
arena_stats_u64_t ndalloc_large; /* Derived. */
arena_stats_u64_t nfills_large; /* Derived. */
arena_stats_u64_t nflushes_large; /* Derived. */
arena_stats_u64_t nrequests_large; /* Derived. */
/* VM space had to be leaked (undocumented). Normally 0. */
atomic_zu_t abandoned_vm;
/* Number of bytes cached in tcache associated with this arena. */
atomic_zu_t tcache_bytes; /* Derived. */
mutex_prof_data_t mutex_prof_data[mutex_prof_num_arena_mutexes];
/* One element for each large size class. */
arena_stats_large_t lstats[NSIZES - NBINS];
arena_stats_large_t lstats[SC_NSIZES - SC_NBINS];
/* Arena uptime. */
nstime_t uptime;
};
static inline bool
arena_stats_init(UNUSED tsdn_t *tsdn, arena_stats_t *arena_stats) {
arena_stats_init(tsdn_t *tsdn, arena_stats_t *arena_stats) {
if (config_debug) {
for (size_t i = 0; i < sizeof(arena_stats_t); i++) {
assert(((char *)arena_stats)[i] == 0);
@@ -147,11 +180,11 @@ arena_stats_add_u64(tsdn_t *tsdn, arena_stats_t *arena_stats,
#endif
}
UNUSED static inline void
static inline void
arena_stats_sub_u64(tsdn_t *tsdn, arena_stats_t *arena_stats,
arena_stats_u64_t *p, uint64_t x) {
#ifdef JEMALLOC_ATOMIC_U64
UNUSED uint64_t r = atomic_fetch_sub_u64(p, x, ATOMIC_RELAXED);
uint64_t r = atomic_fetch_sub_u64(p, x, ATOMIC_RELAXED);
assert(r - x <= r);
#else
malloc_mutex_assert_owner(tsdn, &arena_stats->mtx);
@@ -176,7 +209,8 @@ arena_stats_accum_u64(arena_stats_u64_t *dst, uint64_t src) {
}
static inline size_t
arena_stats_read_zu(tsdn_t *tsdn, arena_stats_t *arena_stats, atomic_zu_t *p) {
arena_stats_read_zu(tsdn_t *tsdn, arena_stats_t *arena_stats,
atomic_zu_t *p) {
#ifdef JEMALLOC_ATOMIC_U64
return atomic_load_zu(p, ATOMIC_RELAXED);
#else
@@ -186,8 +220,8 @@ arena_stats_read_zu(tsdn_t *tsdn, arena_stats_t *arena_stats, atomic_zu_t *p) {
}
static inline void
arena_stats_add_zu(tsdn_t *tsdn, arena_stats_t *arena_stats, atomic_zu_t *p,
size_t x) {
arena_stats_add_zu(tsdn_t *tsdn, arena_stats_t *arena_stats,
atomic_zu_t *p, size_t x) {
#ifdef JEMALLOC_ATOMIC_U64
atomic_fetch_add_zu(p, x, ATOMIC_RELAXED);
#else
@@ -198,10 +232,10 @@ arena_stats_add_zu(tsdn_t *tsdn, arena_stats_t *arena_stats, atomic_zu_t *p,
}
static inline void
arena_stats_sub_zu(tsdn_t *tsdn, arena_stats_t *arena_stats, atomic_zu_t *p,
size_t x) {
arena_stats_sub_zu(tsdn_t *tsdn, arena_stats_t *arena_stats,
atomic_zu_t *p, size_t x) {
#ifdef JEMALLOC_ATOMIC_U64
UNUSED size_t r = atomic_fetch_sub_zu(p, x, ATOMIC_RELAXED);
size_t r = atomic_fetch_sub_zu(p, x, ATOMIC_RELAXED);
assert(r - x <= r);
#else
malloc_mutex_assert_owner(tsdn, &arena_stats->mtx);
@@ -218,11 +252,12 @@ arena_stats_accum_zu(atomic_zu_t *dst, size_t src) {
}
static inline void
arena_stats_large_nrequests_add(tsdn_t *tsdn, arena_stats_t *arena_stats,
arena_stats_large_flush_nrequests_add(tsdn_t *tsdn, arena_stats_t *arena_stats,
szind_t szind, uint64_t nrequests) {
arena_stats_lock(tsdn, arena_stats);
arena_stats_add_u64(tsdn, arena_stats, &arena_stats->lstats[szind -
NBINS].nrequests, nrequests);
arena_stats_large_t *lstats = &arena_stats->lstats[szind - SC_NBINS];
arena_stats_add_u64(tsdn, arena_stats, &lstats->nrequests, nrequests);
arena_stats_add_u64(tsdn, arena_stats, &lstats->nflushes, 1);
arena_stats_unlock(tsdn, arena_stats);
}
@@ -233,5 +268,4 @@ arena_stats_mapped_add(tsdn_t *tsdn, arena_stats_t *arena_stats, size_t size) {
arena_stats_unlock(tsdn, arena_stats);
}
#endif /* JEMALLOC_INTERNAL_ARENA_STATS_H */
+6 -3
View File
@@ -10,7 +10,7 @@
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/nstime.h"
#include "jemalloc/internal/ql.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/smoothstep.h"
#include "jemalloc/internal/ticker.h"
@@ -90,6 +90,9 @@ struct arena_s {
*/
atomic_u_t nthreads[2];
/* Next bin shard for binding new threads. Synchronization: atomic. */
atomic_u_t binshard_next;
/*
* When percpu_arena is enabled, to amortize the cost of reading /
* updating the current CPU id, track the most recent thread accessing
@@ -113,7 +116,6 @@ struct arena_s {
/* Synchronization: internal. */
prof_accum_t prof_accum;
uint64_t prof_accumbytes;
/*
* PRNG state for cache index randomization of large allocation base
@@ -196,6 +198,7 @@ struct arena_s {
* Synchronization: extent_avail_mtx.
*/
extent_tree_t extent_avail;
atomic_zu_t extent_avail_cnt;
malloc_mutex_t extent_avail_mtx;
/*
@@ -203,7 +206,7 @@ struct arena_s {
*
* Synchronization: internal.
*/
bin_t bins[NBINS];
bins_t bins[SC_NBINS];
/*
* Base allocator, from which arena metadata are allocated.
+10 -2
View File
@@ -1,13 +1,15 @@
#ifndef JEMALLOC_INTERNAL_ARENA_TYPES_H
#define JEMALLOC_INTERNAL_ARENA_TYPES_H
#include "jemalloc/internal/sc.h"
/* Maximum number of regions in one slab. */
#define LG_SLAB_MAXREGS (LG_PAGE - LG_TINY_MIN)
#define LG_SLAB_MAXREGS (LG_PAGE - SC_LG_TINY_MIN)
#define SLAB_MAXREGS (1U << LG_SLAB_MAXREGS)
/* Default decay times in milliseconds. */
#define DIRTY_DECAY_MS_DEFAULT ZD(10 * 1000)
#define MUZZY_DECAY_MS_DEFAULT ZD(10 * 1000)
#define MUZZY_DECAY_MS_DEFAULT (0)
/* Number of event ticks between time checks. */
#define DECAY_NTICKS_PER_UPDATE 1000
@@ -40,4 +42,10 @@ typedef enum {
#define PERCPU_ARENA_ENABLED(m) ((m) >= percpu_arena_mode_enabled_base)
#define PERCPU_ARENA_DEFAULT percpu_arena_disabled
/*
* When allocation_size >= oversize_threshold, use the dedicated huge arena
* (unless have explicitly spicified arena index). 0 disables the feature.
*/
#define OVERSIZE_THRESHOLD_DEFAULT (8 << 20)
#endif /* JEMALLOC_INTERNAL_ARENA_TYPES_H */
+10 -1
View File
@@ -1,12 +1,19 @@
#ifndef JEMALLOC_INTERNAL_ATOMIC_H
#define JEMALLOC_INTERNAL_ATOMIC_H
#define ATOMIC_INLINE static inline
#define ATOMIC_INLINE JEMALLOC_ALWAYS_INLINE
#define JEMALLOC_U8_ATOMICS
#if defined(JEMALLOC_GCC_ATOMIC_ATOMICS)
# include "jemalloc/internal/atomic_gcc_atomic.h"
# if !defined(JEMALLOC_GCC_U8_ATOMIC_ATOMICS)
# undef JEMALLOC_U8_ATOMICS
# endif
#elif defined(JEMALLOC_GCC_SYNC_ATOMICS)
# include "jemalloc/internal/atomic_gcc_sync.h"
# if !defined(JEMALLOC_GCC_U8_SYNC_ATOMICS)
# undef JEMALLOC_U8_ATOMICS
# endif
#elif defined(_MSC_VER)
# include "jemalloc/internal/atomic_msvc.h"
#elif defined(JEMALLOC_C11_ATOMICS)
@@ -66,6 +73,8 @@ JEMALLOC_GENERATE_INT_ATOMICS(size_t, zu, LG_SIZEOF_PTR)
JEMALLOC_GENERATE_INT_ATOMICS(ssize_t, zd, LG_SIZEOF_PTR)
JEMALLOC_GENERATE_INT_ATOMICS(uint8_t, u8, 0)
JEMALLOC_GENERATE_INT_ATOMICS(uint32_t, u32, 2)
#ifdef JEMALLOC_ATOMIC_U64
@@ -67,7 +67,8 @@ atomic_exchange_##short_type(atomic_##short_type##_t *a, type val, \
\
ATOMIC_INLINE bool \
atomic_compare_exchange_weak_##short_type(atomic_##short_type##_t *a, \
type *expected, type desired, atomic_memory_order_t success_mo, \
UNUSED type *expected, type desired, \
atomic_memory_order_t success_mo, \
atomic_memory_order_t failure_mo) { \
return __atomic_compare_exchange(&a->repr, expected, &desired, \
true, atomic_enum_to_builtin(success_mo), \
@@ -76,7 +77,8 @@ atomic_compare_exchange_weak_##short_type(atomic_##short_type##_t *a, \
\
ATOMIC_INLINE bool \
atomic_compare_exchange_strong_##short_type(atomic_##short_type##_t *a, \
type *expected, type desired, atomic_memory_order_t success_mo, \
UNUSED type *expected, type desired, \
atomic_memory_order_t success_mo, \
atomic_memory_order_t failure_mo) { \
return __atomic_compare_exchange(&a->repr, expected, &desired, \
false, \
+11 -7
View File
@@ -27,8 +27,10 @@ atomic_fence(atomic_memory_order_t mo) {
asm volatile("" ::: "memory");
# if defined(__i386__) || defined(__x86_64__)
/* This is implicit on x86. */
# elif defined(__ppc__)
# elif defined(__ppc64__)
asm volatile("lwsync");
# elif defined(__ppc__)
asm volatile("sync");
# elif defined(__sparc__) && defined(__arch64__)
if (mo == atomic_memory_order_acquire) {
asm volatile("membar #LoadLoad | #LoadStore");
@@ -113,8 +115,8 @@ atomic_store_##short_type(atomic_##short_type##_t *a, \
} \
\
ATOMIC_INLINE type \
atomic_exchange_##short_type(atomic_##short_type##_t *a, type val, \
atomic_memory_order_t mo) { \
atomic_exchange_##short_type(atomic_##short_type##_t *a, type val, \
atomic_memory_order_t mo) { \
/* \
* Because of FreeBSD, we care about gcc 4.2, which doesn't have\
* an atomic exchange builtin. We fake it with a CAS loop. \
@@ -129,8 +131,9 @@ atomic_exchange_##short_type(atomic_##short_type##_t *a, type val, \
\
ATOMIC_INLINE bool \
atomic_compare_exchange_weak_##short_type(atomic_##short_type##_t *a, \
type *expected, type desired, atomic_memory_order_t success_mo, \
atomic_memory_order_t failure_mo) { \
type *expected, type desired, \
atomic_memory_order_t success_mo, \
atomic_memory_order_t failure_mo) { \
type prev = __sync_val_compare_and_swap(&a->repr, *expected, \
desired); \
if (prev == *expected) { \
@@ -142,8 +145,9 @@ atomic_compare_exchange_weak_##short_type(atomic_##short_type##_t *a, \
} \
ATOMIC_INLINE bool \
atomic_compare_exchange_strong_##short_type(atomic_##short_type##_t *a, \
type *expected, type desired, atomic_memory_order_t success_mo, \
atomic_memory_order_t failure_mo) { \
type *expected, type desired, \
atomic_memory_order_t success_mo, \
atomic_memory_order_t failure_mo) { \
type prev = __sync_val_compare_and_swap(&a->repr, *expected, \
desired); \
if (prev == *expected) { \
@@ -8,7 +8,6 @@ extern atomic_b_t background_thread_enabled_state;
extern size_t n_background_threads;
extern size_t max_background_threads;
extern background_thread_info_t *background_thread_info;
extern bool can_enable_background_thread;
bool background_thread_create(tsd_t *tsd, unsigned arena_ind);
bool background_threads_enable(tsd_t *tsd);
@@ -15,7 +15,12 @@ background_thread_enabled_set(tsdn_t *tsdn, bool state) {
JEMALLOC_ALWAYS_INLINE background_thread_info_t *
arena_background_thread_info_get(arena_t *arena) {
unsigned arena_ind = arena_ind_get(arena);
return &background_thread_info[arena_ind % ncpus];
return &background_thread_info[arena_ind % max_background_threads];
}
JEMALLOC_ALWAYS_INLINE background_thread_info_t *
background_thread_info_get(size_t ind) {
return &background_thread_info[ind % max_background_threads];
}
JEMALLOC_ALWAYS_INLINE uint64_t
@@ -9,6 +9,7 @@
#define BACKGROUND_THREAD_INDEFINITE_SLEEP UINT64_MAX
#define MAX_BACKGROUND_THREAD_LIMIT MALLOCX_ARENA_LIMIT
#define DEFAULT_NUM_BACKGROUND_THREAD 4
typedef enum {
background_thread_stopped,
+2 -2
View File
@@ -3,7 +3,7 @@
#include "jemalloc/internal/jemalloc_internal_types.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
/* Embedded at the beginning of every block of base-managed virtual memory. */
struct base_block_s {
@@ -46,7 +46,7 @@ struct base_s {
base_block_t *blocks;
/* Heap of extents that track unused trailing space within blocks. */
extent_heap_t avail[NSIZES];
extent_heap_t avail[SC_NSIZES];
/* Stats, only maintained if config_stats. */
size_t allocated;
+21 -4
View File
@@ -1,10 +1,12 @@
#ifndef JEMALLOC_INTERNAL_BIN_H
#define JEMALLOC_INTERNAL_BIN_H
#include "jemalloc/internal/bin_stats.h"
#include "jemalloc/internal/bin_types.h"
#include "jemalloc/internal/extent_types.h"
#include "jemalloc/internal/extent_structs.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/bin_stats.h"
#include "jemalloc/internal/sc.h"
/*
* A bin contains a set of extents that are currently being used for slab
@@ -41,6 +43,9 @@ struct bin_info_s {
/* Total number of regions in a slab for this bin's size class. */
uint32_t nregs;
/* Number of sharded bins in each arena for this size class. */
uint32_t n_shards;
/*
* Metadata used to manipulate bitmaps for slabs associated with this
* bin.
@@ -48,8 +53,7 @@ struct bin_info_s {
bitmap_info_t bitmap_info;
};
extern const bin_info_t bin_infos[NBINS];
extern bin_info_t bin_infos[SC_NBINS];
typedef struct bin_s bin_t;
struct bin_s {
@@ -78,6 +82,18 @@ struct bin_s {
bin_stats_t stats;
};
/* A set of sharded bins of the same size class. */
typedef struct bins_s bins_t;
struct bins_s {
/* Sharded bins. Dynamically sized. */
bin_t *bin_shards;
};
void bin_shard_sizes_boot(unsigned bin_shards[SC_NBINS]);
bool bin_update_shard_size(unsigned bin_shards[SC_NBINS], size_t start_size,
size_t end_size, size_t nshards);
void bin_boot(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS]);
/* Initializes a bin to empty. Returns true on error. */
bool bin_init(bin_t *bin);
@@ -90,7 +106,7 @@ void bin_postfork_child(tsdn_t *tsdn, bin_t *bin);
static inline void
bin_stats_merge(tsdn_t *tsdn, bin_stats_t *dst_bin_stats, bin_t *bin) {
malloc_mutex_lock(tsdn, &bin->lock);
malloc_mutex_prof_read(tsdn, &dst_bin_stats->mutex_data, &bin->lock);
malloc_mutex_prof_accum(tsdn, &dst_bin_stats->mutex_data, &bin->lock);
dst_bin_stats->nmalloc += bin->stats.nmalloc;
dst_bin_stats->ndalloc += bin->stats.ndalloc;
dst_bin_stats->nrequests += bin->stats.nrequests;
@@ -100,6 +116,7 @@ bin_stats_merge(tsdn_t *tsdn, bin_stats_t *dst_bin_stats, bin_t *bin) {
dst_bin_stats->nslabs += bin->stats.nslabs;
dst_bin_stats->reslabs += bin->stats.reslabs;
dst_bin_stats->curslabs += bin->stats.curslabs;
dst_bin_stats->nonfull_slabs += bin->stats.nonfull_slabs;
malloc_mutex_unlock(tsdn, &bin->lock);
}
+3
View File
@@ -45,6 +45,9 @@ struct bin_stats_s {
/* Current number of slabs in this bin. */
size_t curslabs;
/* Current size of nonfull slabs heap in this bin. */
size_t nonfull_slabs;
mutex_prof_data_t mutex_data;
};
+17
View File
@@ -0,0 +1,17 @@
#ifndef JEMALLOC_INTERNAL_BIN_TYPES_H
#define JEMALLOC_INTERNAL_BIN_TYPES_H
#include "jemalloc/internal/sc.h"
#define BIN_SHARDS_MAX (1 << EXTENT_BITS_BINSHARD_WIDTH)
#define N_BIN_SHARDS_DEFAULT 1
/* Used in TSD static initializer only. Real init in arena_bind(). */
#define TSD_BINSHARDS_ZERO_INITIALIZER {{UINT8_MAX}}
typedef struct tsd_binshards_s tsd_binshards_t;
struct tsd_binshards_s {
uint8_t binshard[SC_NBINS];
};
#endif /* JEMALLOC_INTERNAL_BIN_TYPES_H */
+74
View File
@@ -27,6 +27,25 @@ ffs_u(unsigned bitmap) {
return JEMALLOC_INTERNAL_FFS(bitmap);
}
#ifdef JEMALLOC_INTERNAL_POPCOUNTL
BIT_UTIL_INLINE unsigned
popcount_lu(unsigned long bitmap) {
return JEMALLOC_INTERNAL_POPCOUNTL(bitmap);
}
#endif
/*
* Clears first unset bit in bitmap, and returns
* place of bit. bitmap *must not* be 0.
*/
BIT_UTIL_INLINE size_t
cfs_lu(unsigned long* bitmap) {
size_t bit = ffs_lu(*bitmap) - 1;
*bitmap ^= ZU(1) << bit;
return bit;
}
BIT_UTIL_INLINE unsigned
ffs_zu(size_t bitmap) {
#if LG_SIZEOF_PTR == LG_SIZEOF_INT
@@ -63,6 +82,22 @@ ffs_u32(uint32_t bitmap) {
BIT_UTIL_INLINE uint64_t
pow2_ceil_u64(uint64_t x) {
#if (defined(__amd64__) || defined(__x86_64__) || defined(JEMALLOC_HAVE_BUILTIN_CLZ))
if(unlikely(x <= 1)) {
return x;
}
size_t msb_on_index;
#if (defined(__amd64__) || defined(__x86_64__))
asm ("bsrq %1, %0"
: "=r"(msb_on_index) // Outputs.
: "r"(x-1) // Inputs.
);
#elif (defined(JEMALLOC_HAVE_BUILTIN_CLZ))
msb_on_index = (63 ^ __builtin_clzll(x - 1));
#endif
assert(msb_on_index < 63);
return 1ULL << (msb_on_index + 1);
#else
x--;
x |= x >> 1;
x |= x >> 2;
@@ -72,10 +107,27 @@ pow2_ceil_u64(uint64_t x) {
x |= x >> 32;
x++;
return x;
#endif
}
BIT_UTIL_INLINE uint32_t
pow2_ceil_u32(uint32_t x) {
#if ((defined(__i386__) || defined(JEMALLOC_HAVE_BUILTIN_CLZ)) && (!defined(__s390__)))
if(unlikely(x <= 1)) {
return x;
}
size_t msb_on_index;
#if (defined(__i386__))
asm ("bsr %1, %0"
: "=r"(msb_on_index) // Outputs.
: "r"(x-1) // Inputs.
);
#elif (defined(JEMALLOC_HAVE_BUILTIN_CLZ))
msb_on_index = (31 ^ __builtin_clz(x - 1));
#endif
assert(msb_on_index < 31);
return 1U << (msb_on_index + 1);
#else
x--;
x |= x >> 1;
x |= x >> 2;
@@ -84,6 +136,7 @@ pow2_ceil_u32(uint32_t x) {
x |= x >> 16;
x++;
return x;
#endif
}
/* Compute the smallest power of 2 that is >= x. */
@@ -160,6 +213,27 @@ lg_floor(size_t x) {
}
#endif
BIT_UTIL_INLINE unsigned
lg_ceil(size_t x) {
return lg_floor(x) + ((x & (x - 1)) == 0 ? 0 : 1);
}
#undef BIT_UTIL_INLINE
/* A compile-time version of lg_floor and lg_ceil. */
#define LG_FLOOR_1(x) 0
#define LG_FLOOR_2(x) (x < (1ULL << 1) ? LG_FLOOR_1(x) : 1 + LG_FLOOR_1(x >> 1))
#define LG_FLOOR_4(x) (x < (1ULL << 2) ? LG_FLOOR_2(x) : 2 + LG_FLOOR_2(x >> 2))
#define LG_FLOOR_8(x) (x < (1ULL << 4) ? LG_FLOOR_4(x) : 4 + LG_FLOOR_4(x >> 4))
#define LG_FLOOR_16(x) (x < (1ULL << 8) ? LG_FLOOR_8(x) : 8 + LG_FLOOR_8(x >> 8))
#define LG_FLOOR_32(x) (x < (1ULL << 16) ? LG_FLOOR_16(x) : 16 + LG_FLOOR_16(x >> 16))
#define LG_FLOOR_64(x) (x < (1ULL << 32) ? LG_FLOOR_32(x) : 32 + LG_FLOOR_32(x >> 32))
#if LG_SIZEOF_PTR == 2
# define LG_FLOOR(x) LG_FLOOR_32((x))
#else
# define LG_FLOOR(x) LG_FLOOR_64((x))
#endif
#define LG_CEIL(x) (LG_FLOOR(x) + (((x) & ((x) - 1)) == 0 ? 0 : 1))
#endif /* JEMALLOC_INTERNAL_BIT_UTIL_H */
+3 -3
View File
@@ -3,18 +3,18 @@
#include "jemalloc/internal/arena_types.h"
#include "jemalloc/internal/bit_util.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
typedef unsigned long bitmap_t;
#define LG_SIZEOF_BITMAP LG_SIZEOF_LONG
/* Maximum bitmap bit count is 2^LG_BITMAP_MAXBITS. */
#if LG_SLAB_MAXREGS > LG_CEIL_NSIZES
#if LG_SLAB_MAXREGS > LG_CEIL(SC_NSIZES)
/* Maximum bitmap bit count is determined by maximum regions per slab. */
# define LG_BITMAP_MAXBITS LG_SLAB_MAXREGS
#else
/* Maximum bitmap bit count is determined by number of extent size classes. */
# define LG_BITMAP_MAXBITS LG_CEIL_NSIZES
# define LG_BITMAP_MAXBITS LG_CEIL(SC_NSIZES)
#endif
#define BITMAP_MAXBITS (ZU(1) << LG_BITMAP_MAXBITS)
+27 -10
View File
@@ -88,11 +88,21 @@ JEMALLOC_ALWAYS_INLINE void *
cache_bin_alloc_easy(cache_bin_t *bin, bool *success) {
void *ret;
if (unlikely(bin->ncached == 0)) {
bin->low_water = -1;
*success = false;
return NULL;
bin->ncached--;
/*
* Check for both bin->ncached == 0 and ncached < low_water
* in a single branch.
*/
if (unlikely(bin->ncached <= bin->low_water)) {
bin->low_water = bin->ncached;
if (bin->ncached == -1) {
bin->ncached = 0;
*success = false;
return NULL;
}
}
/*
* success (instead of ret) should be checked upon the return of this
* function. We avoid checking (ret == NULL) because there is never a
@@ -101,14 +111,21 @@ cache_bin_alloc_easy(cache_bin_t *bin, bool *success) {
* cacheline).
*/
*success = true;
ret = *(bin->avail - bin->ncached);
bin->ncached--;
if (unlikely(bin->ncached < bin->low_water)) {
bin->low_water = bin->ncached;
}
ret = *(bin->avail - (bin->ncached + 1));
return ret;
}
JEMALLOC_ALWAYS_INLINE bool
cache_bin_dalloc_easy(cache_bin_t *bin, cache_bin_info_t *bin_info, void *ptr) {
if (unlikely(bin->ncached == bin_info->ncached_max)) {
return false;
}
assert(bin->ncached < bin_info->ncached_max);
bin->ncached++;
*(bin->avail - bin->ncached) = ptr;
return true;
}
#endif /* JEMALLOC_INTERNAL_CACHE_BIN_H */
+6 -3
View File
@@ -5,7 +5,7 @@
#include "jemalloc/internal/malloc_io.h"
#include "jemalloc/internal/mutex_prof.h"
#include "jemalloc/internal/ql.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/stats.h"
/* Maximum ctl tree depth. */
@@ -39,9 +39,12 @@ typedef struct ctl_arena_stats_s {
uint64_t nmalloc_small;
uint64_t ndalloc_small;
uint64_t nrequests_small;
uint64_t nfills_small;
uint64_t nflushes_small;
bin_stats_t bstats[NBINS];
arena_stats_large_t lstats[NSIZES - NBINS];
bin_stats_t bstats[SC_NBINS];
arena_stats_large_t lstats[SC_NSIZES - SC_NBINS];
arena_stats_extents_t estats[SC_NPSIZES];
} ctl_arena_stats_t;
typedef struct ctl_stats_s {
+244 -193
View File
@@ -45,7 +45,9 @@ struct emitter_col_s {
int int_val;
unsigned unsigned_val;
uint32_t uint32_val;
uint32_t uint32_t_val;
uint64_t uint64_val;
uint64_t uint64_t_val;
size_t size_val;
ssize_t ssize_val;
const char *str_val;
@@ -60,17 +62,6 @@ struct emitter_row_s {
ql_head(emitter_col_t) cols;
};
static inline void
emitter_row_init(emitter_row_t *row) {
ql_new(&row->cols);
}
static inline void
emitter_col_init(emitter_col_t *col, emitter_row_t *row) {
ql_elm_new(col, link);
ql_tail_insert(&row->cols, col, link);
}
typedef struct emitter_s emitter_t;
struct emitter_s {
emitter_output_t output;
@@ -80,18 +71,10 @@ struct emitter_s {
int nesting_depth;
/* True if we've already emitted a value at the given depth. */
bool item_at_depth;
/* True if we emitted a key and will emit corresponding value next. */
bool emitted_key;
};
static inline void
emitter_init(emitter_t *emitter, emitter_output_t emitter_output,
void (*write_cb)(void *, const char *), void *cbopaque) {
emitter->output = emitter_output;
emitter->write_cb = write_cb;
emitter->cbopaque = cbopaque;
emitter->item_at_depth = false;
emitter->nesting_depth = 0;
}
/* Internal convenience function. Write to the emitter the given string. */
JEMALLOC_FORMAT_PRINTF(2, 3)
static inline void
@@ -103,22 +86,11 @@ emitter_printf(emitter_t *emitter, const char *format, ...) {
va_end(ap);
}
/* Write to the emitter the given string, but only in table mode. */
JEMALLOC_FORMAT_PRINTF(2, 3)
static inline void
emitter_table_printf(emitter_t *emitter, const char *format, ...) {
if (emitter->output == emitter_output_table) {
va_list ap;
va_start(ap, format);
malloc_vcprintf(emitter->write_cb, emitter->cbopaque, format, ap);
va_end(ap);
}
}
static inline void
static inline const char * JEMALLOC_FORMAT_ARG(3)
emitter_gen_fmt(char *out_fmt, size_t out_size, const char *fmt_specifier,
emitter_justify_t justify, int width) {
size_t written;
fmt_specifier++;
if (justify == emitter_justify_none) {
written = malloc_snprintf(out_fmt, out_size,
"%%%s", fmt_specifier);
@@ -131,6 +103,7 @@ emitter_gen_fmt(char *out_fmt, size_t out_size, const char *fmt_specifier,
}
/* Only happens in case of bad format string, which *we* choose. */
assert(written < out_size);
return out_fmt;
}
/*
@@ -156,26 +129,27 @@ emitter_print_value(emitter_t *emitter, emitter_justify_t justify, int width,
char buf[BUF_SIZE];
#define EMIT_SIMPLE(type, format) \
emitter_gen_fmt(fmt, FMT_SIZE, format, justify, width); \
emitter_printf(emitter, fmt, *(const type *)value); \
emitter_printf(emitter, \
emitter_gen_fmt(fmt, FMT_SIZE, format, justify, width), \
*(const type *)value);
switch (value_type) {
case emitter_type_bool:
emitter_gen_fmt(fmt, FMT_SIZE, "s", justify, width);
emitter_printf(emitter, fmt, *(const bool *)value ?
"true" : "false");
emitter_printf(emitter,
emitter_gen_fmt(fmt, FMT_SIZE, "%s", justify, width),
*(const bool *)value ? "true" : "false");
break;
case emitter_type_int:
EMIT_SIMPLE(int, "d")
EMIT_SIMPLE(int, "%d")
break;
case emitter_type_unsigned:
EMIT_SIMPLE(unsigned, "u")
EMIT_SIMPLE(unsigned, "%u")
break;
case emitter_type_ssize:
EMIT_SIMPLE(ssize_t, "zd")
EMIT_SIMPLE(ssize_t, "%zd")
break;
case emitter_type_size:
EMIT_SIMPLE(size_t, "zu")
EMIT_SIMPLE(size_t, "%zu")
break;
case emitter_type_string:
str_written = malloc_snprintf(buf, BUF_SIZE, "\"%s\"",
@@ -185,17 +159,17 @@ emitter_print_value(emitter_t *emitter, emitter_justify_t justify, int width,
* anywhere near the fmt size.
*/
assert(str_written < BUF_SIZE);
emitter_gen_fmt(fmt, FMT_SIZE, "s", justify, width);
emitter_printf(emitter, fmt, buf);
emitter_printf(emitter,
emitter_gen_fmt(fmt, FMT_SIZE, "%s", justify, width), buf);
break;
case emitter_type_uint32:
EMIT_SIMPLE(uint32_t, FMTu32)
EMIT_SIMPLE(uint32_t, "%" FMTu32)
break;
case emitter_type_uint64:
EMIT_SIMPLE(uint64_t, FMTu64)
EMIT_SIMPLE(uint64_t, "%" FMTu64)
break;
case emitter_type_title:
EMIT_SIMPLE(char *const, "s");
EMIT_SIMPLE(char *const, "%s");
break;
default:
unreachable();
@@ -235,47 +209,143 @@ emitter_indent(emitter_t *emitter) {
static inline void
emitter_json_key_prefix(emitter_t *emitter) {
if (emitter->emitted_key) {
emitter->emitted_key = false;
return;
}
emitter_printf(emitter, "%s\n", emitter->item_at_depth ? "," : "");
emitter_indent(emitter);
}
static inline void
emitter_begin(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth == 0);
emitter_printf(emitter, "{");
emitter_nest_inc(emitter);
} else {
// tabular init
emitter_printf(emitter, "%s", "");
}
}
/******************************************************************************/
/* Public functions for emitter_t. */
static inline void
emitter_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth == 1);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n}\n");
}
emitter_init(emitter_t *emitter, emitter_output_t emitter_output,
void (*write_cb)(void *, const char *), void *cbopaque) {
emitter->output = emitter_output;
emitter->write_cb = write_cb;
emitter->cbopaque = cbopaque;
emitter->item_at_depth = false;
emitter->emitted_key = false;
emitter->nesting_depth = 0;
}
/*
* Note emits a different kv pair as well, but only in table mode. Omits the
* note if table_note_key is NULL.
/******************************************************************************/
/* JSON public API. */
/*
* Emits a key (e.g. as appears in an object). The next json entity emitted will
* be the corresponding value.
*/
static inline void
emitter_kv_note(emitter_t *emitter, const char *json_key, const char *table_key,
emitter_json_key(emitter_t *emitter, const char *json_key) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "\"%s\": ", json_key);
emitter->emitted_key = true;
}
}
static inline void
emitter_json_value(emitter_t *emitter, emitter_type_t value_type,
const void *value) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_print_value(emitter, emitter_justify_none, -1,
value_type, value);
emitter->item_at_depth = true;
}
}
/* Shorthand for calling emitter_json_key and then emitter_json_value. */
static inline void
emitter_json_kv(emitter_t *emitter, const char *json_key,
emitter_type_t value_type, const void *value) {
emitter_json_key(emitter, json_key);
emitter_json_value(emitter, value_type, value);
}
static inline void
emitter_json_array_begin(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "[");
emitter_nest_inc(emitter);
}
}
/* Shorthand for calling emitter_json_key and then emitter_json_array_begin. */
static inline void
emitter_json_array_kv_begin(emitter_t *emitter, const char *json_key) {
emitter_json_key(emitter, json_key);
emitter_json_array_begin(emitter);
}
static inline void
emitter_json_array_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth > 0);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n");
emitter_indent(emitter);
emitter_printf(emitter, "]");
}
}
static inline void
emitter_json_object_begin(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "{");
emitter_nest_inc(emitter);
}
}
/* Shorthand for calling emitter_json_key and then emitter_json_object_begin. */
static inline void
emitter_json_object_kv_begin(emitter_t *emitter, const char *json_key) {
emitter_json_key(emitter, json_key);
emitter_json_object_begin(emitter);
}
static inline void
emitter_json_object_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth > 0);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n");
emitter_indent(emitter);
emitter_printf(emitter, "}");
}
}
/******************************************************************************/
/* Table public API. */
static inline void
emitter_table_dict_begin(emitter_t *emitter, const char *table_key) {
if (emitter->output == emitter_output_table) {
emitter_indent(emitter);
emitter_printf(emitter, "%s\n", table_key);
emitter_nest_inc(emitter);
}
}
static inline void
emitter_table_dict_end(emitter_t *emitter) {
if (emitter->output == emitter_output_table) {
emitter_nest_dec(emitter);
}
}
static inline void
emitter_table_kv_note(emitter_t *emitter, const char *table_key,
emitter_type_t value_type, const void *value,
const char *table_note_key, emitter_type_t table_note_value_type,
const void *table_note_value) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth > 0);
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "\"%s\": ", json_key);
emitter_print_value(emitter, emitter_justify_none, -1,
value_type, value);
} else {
if (emitter->output == emitter_output_table) {
emitter_indent(emitter);
emitter_printf(emitter, "%s: ", table_key);
emitter_print_value(emitter, emitter_justify_none, -1,
@@ -292,130 +362,22 @@ emitter_kv_note(emitter_t *emitter, const char *json_key, const char *table_key,
}
static inline void
emitter_kv(emitter_t *emitter, const char *json_key, const char *table_key,
emitter_table_kv(emitter_t *emitter, const char *table_key,
emitter_type_t value_type, const void *value) {
emitter_kv_note(emitter, json_key, table_key, value_type, value, NULL,
emitter_table_kv_note(emitter, table_key, value_type, value, NULL,
emitter_type_bool, NULL);
}
static inline void
emitter_json_kv(emitter_t *emitter, const char *json_key,
emitter_type_t value_type, const void *value) {
if (emitter->output == emitter_output_json) {
emitter_kv(emitter, json_key, NULL, value_type, value);
}
}
/* Write to the emitter the given string, but only in table mode. */
JEMALLOC_FORMAT_PRINTF(2, 3)
static inline void
emitter_table_kv(emitter_t *emitter, const char *table_key,
emitter_type_t value_type, const void *value) {
emitter_table_printf(emitter_t *emitter, const char *format, ...) {
if (emitter->output == emitter_output_table) {
emitter_kv(emitter, NULL, table_key, value_type, value);
}
}
static inline void
emitter_dict_begin(emitter_t *emitter, const char *json_key,
const char *table_header) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "\"%s\": {", json_key);
emitter_nest_inc(emitter);
} else {
emitter_indent(emitter);
emitter_printf(emitter, "%s\n", table_header);
emitter_nest_inc(emitter);
}
}
static inline void
emitter_dict_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth > 0);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n");
emitter_indent(emitter);
emitter_printf(emitter, "}");
} else {
emitter_nest_dec(emitter);
}
}
static inline void
emitter_json_dict_begin(emitter_t *emitter, const char *json_key) {
if (emitter->output == emitter_output_json) {
emitter_dict_begin(emitter, json_key, NULL);
}
}
static inline void
emitter_json_dict_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
emitter_dict_end(emitter);
}
}
static inline void
emitter_table_dict_begin(emitter_t *emitter, const char *table_key) {
if (emitter->output == emitter_output_table) {
emitter_dict_begin(emitter, NULL, table_key);
}
}
static inline void
emitter_table_dict_end(emitter_t *emitter) {
if (emitter->output == emitter_output_table) {
emitter_dict_end(emitter);
}
}
static inline void
emitter_json_arr_begin(emitter_t *emitter, const char *json_key) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "\"%s\": [", json_key);
emitter_nest_inc(emitter);
}
}
static inline void
emitter_json_arr_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth > 0);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n");
emitter_indent(emitter);
emitter_printf(emitter, "]");
}
}
static inline void
emitter_json_arr_obj_begin(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_printf(emitter, "{");
emitter_nest_inc(emitter);
}
}
static inline void
emitter_json_arr_obj_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth > 0);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n");
emitter_indent(emitter);
emitter_printf(emitter, "}");
}
}
static inline void
emitter_json_arr_value(emitter_t *emitter, emitter_type_t value_type,
const void *value) {
if (emitter->output == emitter_output_json) {
emitter_json_key_prefix(emitter);
emitter_print_value(emitter, emitter_justify_none, -1,
value_type, value);
va_list ap;
va_start(ap, format);
malloc_vcprintf(emitter->write_cb, emitter->cbopaque, format, ap);
va_end(ap);
}
}
@@ -432,4 +394,93 @@ emitter_table_row(emitter_t *emitter, emitter_row_t *row) {
emitter_table_printf(emitter, "\n");
}
static inline void
emitter_row_init(emitter_row_t *row) {
ql_new(&row->cols);
}
static inline void
emitter_col_init(emitter_col_t *col, emitter_row_t *row) {
ql_elm_new(col, link);
ql_tail_insert(&row->cols, col, link);
}
/******************************************************************************/
/*
* Generalized public API. Emits using either JSON or table, according to
* settings in the emitter_t. */
/*
* Note emits a different kv pair as well, but only in table mode. Omits the
* note if table_note_key is NULL.
*/
static inline void
emitter_kv_note(emitter_t *emitter, const char *json_key, const char *table_key,
emitter_type_t value_type, const void *value,
const char *table_note_key, emitter_type_t table_note_value_type,
const void *table_note_value) {
if (emitter->output == emitter_output_json) {
emitter_json_key(emitter, json_key);
emitter_json_value(emitter, value_type, value);
} else {
emitter_table_kv_note(emitter, table_key, value_type, value,
table_note_key, table_note_value_type, table_note_value);
}
emitter->item_at_depth = true;
}
static inline void
emitter_kv(emitter_t *emitter, const char *json_key, const char *table_key,
emitter_type_t value_type, const void *value) {
emitter_kv_note(emitter, json_key, table_key, value_type, value, NULL,
emitter_type_bool, NULL);
}
static inline void
emitter_dict_begin(emitter_t *emitter, const char *json_key,
const char *table_header) {
if (emitter->output == emitter_output_json) {
emitter_json_key(emitter, json_key);
emitter_json_object_begin(emitter);
} else {
emitter_table_dict_begin(emitter, table_header);
}
}
static inline void
emitter_dict_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
emitter_json_object_end(emitter);
} else {
emitter_table_dict_end(emitter);
}
}
static inline void
emitter_begin(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth == 0);
emitter_printf(emitter, "{");
emitter_nest_inc(emitter);
} else {
/*
* This guarantees that we always call write_cb at least once.
* This is useful if some invariant is established by each call
* to write_cb, but doesn't hold initially: e.g., some buffer
* holds a null-terminated string.
*/
emitter_printf(emitter, "%s", "");
}
}
static inline void
emitter_end(emitter_t *emitter) {
if (emitter->output == emitter_output_json) {
assert(emitter->nesting_depth == 1);
emitter_nest_dec(emitter);
emitter_printf(emitter, "\n}\n");
}
}
#endif /* JEMALLOC_INTERNAL_EMITTER_H */
+11 -1
View File
@@ -24,13 +24,17 @@ size_t extent_size_quantize_floor(size_t size);
size_t extent_size_quantize_ceil(size_t size);
#endif
rb_proto(, extent_avail_, extent_tree_t, extent_t)
ph_proto(, extent_avail_, extent_tree_t, extent_t)
ph_proto(, extent_heap_, extent_heap_t, extent_t)
bool extents_init(tsdn_t *tsdn, extents_t *extents, extent_state_t state,
bool delay_coalesce);
extent_state_t extents_state_get(const extents_t *extents);
size_t extents_npages_get(extents_t *extents);
/* Get the number of extents in the given page size index. */
size_t extents_nextents_get(extents_t *extents, pszind_t ind);
/* Get the sum total bytes of the extents in the given page size index. */
size_t extents_nbytes_get(extents_t *extents, pszind_t ind);
extent_t *extents_alloc(tsdn_t *tsdn, arena_t *arena,
extent_hooks_t **r_extent_hooks, extents_t *extents, void *new_addr,
size_t size, size_t pad, size_t alignment, bool slab, szind_t szind,
@@ -70,4 +74,10 @@ bool extent_merge_wrapper(tsdn_t *tsdn, arena_t *arena,
bool extent_boot(void);
void extent_util_stats_get(tsdn_t *tsdn, const void *ptr,
size_t *nfree, size_t *nregs, size_t *size);
void extent_util_stats_verbose_get(tsdn_t *tsdn, const void *ptr,
size_t *nfree, size_t *nregs, size_t *size,
size_t *bin_nfree, size_t *bin_nregs, void **slabcur_addr);
#endif /* JEMALLOC_INTERNAL_EXTENT_EXTERNS_H */
+83 -15
View File
@@ -6,6 +6,7 @@
#include "jemalloc/internal/pages.h"
#include "jemalloc/internal/prng.h"
#include "jemalloc/internal/ql.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/sz.h"
static inline void
@@ -34,18 +35,19 @@ extent_unlock2(tsdn_t *tsdn, extent_t *extent1, extent_t *extent2) {
(uintptr_t)extent2);
}
static inline arena_t *
extent_arena_get(const extent_t *extent) {
static inline unsigned
extent_arena_ind_get(const extent_t *extent) {
unsigned arena_ind = (unsigned)((extent->e_bits &
EXTENT_BITS_ARENA_MASK) >> EXTENT_BITS_ARENA_SHIFT);
/*
* The following check is omitted because we should never actually read
* a NULL arena pointer.
*/
if (false && arena_ind >= MALLOCX_ARENA_LIMIT) {
return NULL;
}
assert(arena_ind < MALLOCX_ARENA_LIMIT);
return arena_ind;
}
static inline arena_t *
extent_arena_get(const extent_t *extent) {
unsigned arena_ind = extent_arena_ind_get(extent);
return (arena_t *)atomic_load_p(&arenas[arena_ind], ATOMIC_ACQUIRE);
}
@@ -53,14 +55,14 @@ static inline szind_t
extent_szind_get_maybe_invalid(const extent_t *extent) {
szind_t szind = (szind_t)((extent->e_bits & EXTENT_BITS_SZIND_MASK) >>
EXTENT_BITS_SZIND_SHIFT);
assert(szind <= NSIZES);
assert(szind <= SC_NSIZES);
return szind;
}
static inline szind_t
extent_szind_get(const extent_t *extent) {
szind_t szind = extent_szind_get_maybe_invalid(extent);
assert(szind < NSIZES); /* Never call when "invalid". */
assert(szind < SC_NSIZES); /* Never call when "invalid". */
return szind;
}
@@ -69,6 +71,14 @@ extent_usize_get(const extent_t *extent) {
return sz_index2size(extent_szind_get(extent));
}
static inline unsigned
extent_binshard_get(const extent_t *extent) {
unsigned binshard = (unsigned)((extent->e_bits &
EXTENT_BITS_BINSHARD_MASK) >> EXTENT_BITS_BINSHARD_SHIFT);
assert(binshard < bin_infos[extent_szind_get(extent)].n_shards);
return binshard;
}
static inline size_t
extent_sn_get(const extent_t *extent) {
return (size_t)((extent->e_bits & EXTENT_BITS_SN_MASK) >>
@@ -176,6 +186,11 @@ extent_prof_tctx_get(const extent_t *extent) {
ATOMIC_ACQUIRE);
}
static inline nstime_t
extent_prof_alloc_time_get(const extent_t *extent) {
return extent->e_alloc_time;
}
static inline void
extent_arena_set(extent_t *extent, arena_t *arena) {
unsigned arena_ind = (arena != NULL) ? arena_ind_get(arena) : ((1U <<
@@ -184,13 +199,21 @@ extent_arena_set(extent_t *extent, arena_t *arena) {
((uint64_t)arena_ind << EXTENT_BITS_ARENA_SHIFT);
}
static inline void
extent_binshard_set(extent_t *extent, unsigned binshard) {
/* The assertion assumes szind is set already. */
assert(binshard < bin_infos[extent_szind_get(extent)].n_shards);
extent->e_bits = (extent->e_bits & ~EXTENT_BITS_BINSHARD_MASK) |
((uint64_t)binshard << EXTENT_BITS_BINSHARD_SHIFT);
}
static inline void
extent_addr_set(extent_t *extent, void *addr) {
extent->e_addr = addr;
}
static inline void
extent_addr_randomize(UNUSED tsdn_t *tsdn, extent_t *extent, size_t alignment) {
extent_addr_randomize(tsdn_t *tsdn, extent_t *extent, size_t alignment) {
assert(extent_base_get(extent) == extent_addr_get(extent));
if (alignment < PAGE) {
@@ -234,7 +257,7 @@ extent_bsize_set(extent_t *extent, size_t bsize) {
static inline void
extent_szind_set(extent_t *extent, szind_t szind) {
assert(szind <= NSIZES); /* NSIZES means "invalid". */
assert(szind <= SC_NSIZES); /* SC_NSIZES means "invalid". */
extent->e_bits = (extent->e_bits & ~EXTENT_BITS_SZIND_MASK) |
((uint64_t)szind << EXTENT_BITS_SZIND_SHIFT);
}
@@ -246,6 +269,16 @@ extent_nfree_set(extent_t *extent, unsigned nfree) {
((uint64_t)nfree << EXTENT_BITS_NFREE_SHIFT);
}
static inline void
extent_nfree_binshard_set(extent_t *extent, unsigned nfree, unsigned binshard) {
/* The assertion assumes szind is set already. */
assert(binshard < bin_infos[extent_szind_get(extent)].n_shards);
extent->e_bits = (extent->e_bits &
(~EXTENT_BITS_NFREE_MASK & ~EXTENT_BITS_BINSHARD_MASK)) |
((uint64_t)binshard << EXTENT_BITS_BINSHARD_SHIFT) |
((uint64_t)nfree << EXTENT_BITS_NFREE_SHIFT);
}
static inline void
extent_nfree_inc(extent_t *extent) {
assert(extent_slab_get(extent));
@@ -258,6 +291,12 @@ extent_nfree_dec(extent_t *extent) {
extent->e_bits -= ((uint64_t)1U << EXTENT_BITS_NFREE_SHIFT);
}
static inline void
extent_nfree_sub(extent_t *extent, uint64_t n) {
assert(extent_slab_get(extent));
extent->e_bits -= (n << EXTENT_BITS_NFREE_SHIFT);
}
static inline void
extent_sn_set(extent_t *extent, size_t sn) {
extent->e_bits = (extent->e_bits & ~EXTENT_BITS_SN_MASK) |
@@ -299,10 +338,35 @@ extent_prof_tctx_set(extent_t *extent, prof_tctx_t *tctx) {
atomic_store_p(&extent->e_prof_tctx, tctx, ATOMIC_RELEASE);
}
static inline void
extent_prof_alloc_time_set(extent_t *extent, nstime_t t) {
nstime_copy(&extent->e_alloc_time, &t);
}
static inline bool
extent_is_head_get(extent_t *extent) {
if (maps_coalesce) {
not_reached();
}
return (bool)((extent->e_bits & EXTENT_BITS_IS_HEAD_MASK) >>
EXTENT_BITS_IS_HEAD_SHIFT);
}
static inline void
extent_is_head_set(extent_t *extent, bool is_head) {
if (maps_coalesce) {
not_reached();
}
extent->e_bits = (extent->e_bits & ~EXTENT_BITS_IS_HEAD_MASK) |
((uint64_t)is_head << EXTENT_BITS_IS_HEAD_SHIFT);
}
static inline void
extent_init(extent_t *extent, arena_t *arena, void *addr, size_t size,
bool slab, szind_t szind, size_t sn, extent_state_t state, bool zeroed,
bool committed, bool dumpable) {
bool committed, bool dumpable, extent_head_state_t is_head) {
assert(addr == PAGE_ADDR2BASE(addr) || !slab);
extent_arena_set(extent, arena);
@@ -316,6 +380,10 @@ extent_init(extent_t *extent, arena_t *arena, void *addr, size_t size,
extent_committed_set(extent, committed);
extent_dumpable_set(extent, dumpable);
ql_elm_new(extent, ql_link);
if (!maps_coalesce) {
extent_is_head_set(extent, (is_head == EXTENT_IS_HEAD) ? true :
false);
}
if (config_prof) {
extent_prof_tctx_set(extent, NULL);
}
@@ -327,7 +395,7 @@ extent_binit(extent_t *extent, void *addr, size_t bsize, size_t sn) {
extent_addr_set(extent, addr);
extent_bsize_set(extent, bsize);
extent_slab_set(extent, false);
extent_szind_set(extent, NSIZES);
extent_szind_set(extent, SC_NSIZES);
extent_sn_set(extent, sn);
extent_state_set(extent, extent_state_active);
extent_zeroed_set(extent, true);
+48 -11
View File
@@ -2,11 +2,12 @@
#define JEMALLOC_INTERNAL_EXTENT_STRUCTS_H
#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/bit_util.h"
#include "jemalloc/internal/bitmap.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/ql.h"
#include "jemalloc/internal/ph.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
typedef enum {
extent_state_active = 0,
@@ -28,9 +29,10 @@ struct extent_s {
* t: state
* i: szind
* f: nfree
* s: bin_shard
* n: sn
*
* nnnnnnnn ... nnnnffff ffffffii iiiiiitt zdcbaaaa aaaaaaaa
* nnnnnnnn ... nnnnnnss ssssffff ffffffii iiiiiitt zdcbaaaa aaaaaaaa
*
* arena_ind: Arena from which this extent came, or all 1 bits if
* unassociated.
@@ -75,6 +77,8 @@ struct extent_s {
*
* nfree: Number of free regions in slab.
*
* bin_shard: the shard of the bin from which this extent came.
*
* sn: Serial number (potentially non-unique).
*
* Serial numbers may wrap around if !opt_retain, but as long as
@@ -112,7 +116,7 @@ struct extent_s {
#define EXTENT_BITS_STATE_SHIFT (EXTENT_BITS_ZEROED_WIDTH + EXTENT_BITS_ZEROED_SHIFT)
#define EXTENT_BITS_STATE_MASK MASK(EXTENT_BITS_STATE_WIDTH, EXTENT_BITS_STATE_SHIFT)
#define EXTENT_BITS_SZIND_WIDTH LG_CEIL_NSIZES
#define EXTENT_BITS_SZIND_WIDTH LG_CEIL(SC_NSIZES)
#define EXTENT_BITS_SZIND_SHIFT (EXTENT_BITS_STATE_WIDTH + EXTENT_BITS_STATE_SHIFT)
#define EXTENT_BITS_SZIND_MASK MASK(EXTENT_BITS_SZIND_WIDTH, EXTENT_BITS_SZIND_SHIFT)
@@ -120,7 +124,15 @@ struct extent_s {
#define EXTENT_BITS_NFREE_SHIFT (EXTENT_BITS_SZIND_WIDTH + EXTENT_BITS_SZIND_SHIFT)
#define EXTENT_BITS_NFREE_MASK MASK(EXTENT_BITS_NFREE_WIDTH, EXTENT_BITS_NFREE_SHIFT)
#define EXTENT_BITS_SN_SHIFT (EXTENT_BITS_NFREE_WIDTH + EXTENT_BITS_NFREE_SHIFT)
#define EXTENT_BITS_BINSHARD_WIDTH 6
#define EXTENT_BITS_BINSHARD_SHIFT (EXTENT_BITS_NFREE_WIDTH + EXTENT_BITS_NFREE_SHIFT)
#define EXTENT_BITS_BINSHARD_MASK MASK(EXTENT_BITS_BINSHARD_WIDTH, EXTENT_BITS_BINSHARD_SHIFT)
#define EXTENT_BITS_IS_HEAD_WIDTH 1
#define EXTENT_BITS_IS_HEAD_SHIFT (EXTENT_BITS_BINSHARD_WIDTH + EXTENT_BITS_BINSHARD_SHIFT)
#define EXTENT_BITS_IS_HEAD_MASK MASK(EXTENT_BITS_IS_HEAD_WIDTH, EXTENT_BITS_IS_HEAD_SHIFT)
#define EXTENT_BITS_SN_SHIFT (EXTENT_BITS_IS_HEAD_WIDTH + EXTENT_BITS_IS_HEAD_SHIFT)
#define EXTENT_BITS_SN_MASK (UINT64_MAX << EXTENT_BITS_SN_SHIFT)
/* Pointer to the extent that this structure is responsible for. */
@@ -160,11 +172,13 @@ struct extent_s {
/* Small region slab metadata. */
arena_slab_data_t e_slab_data;
/*
* Profile counters, used for large objects. Points to a
* prof_tctx_t.
*/
atomic_p_t e_prof_tctx;
/* Profiling data, used for large objects. */
struct {
/* Time when this was allocated. */
nstime_t e_alloc_time;
/* Points to a prof_tctx_t. */
atomic_p_t e_prof_tctx;
};
};
};
typedef ql_head(extent_t) extent_list_t;
@@ -180,14 +194,16 @@ struct extents_s {
*
* Synchronization: mtx.
*/
extent_heap_t heaps[NPSIZES+1];
extent_heap_t heaps[SC_NPSIZES + 1];
atomic_zu_t nextents[SC_NPSIZES + 1];
atomic_zu_t nbytes[SC_NPSIZES + 1];
/*
* Bitmap for which set bits correspond to non-empty heaps.
*
* Synchronization: mtx.
*/
bitmap_t bitmap[BITMAP_GROUPS(NPSIZES+1)];
bitmap_t bitmap[BITMAP_GROUPS(SC_NPSIZES + 1)];
/*
* LRU of all extents in heaps.
@@ -216,4 +232,25 @@ struct extents_s {
bool delay_coalesce;
};
/*
* The following two structs are for experimental purposes. See
* experimental_utilization_query_ctl and
* experimental_utilization_batch_query_ctl in src/ctl.c.
*/
struct extent_util_stats_s {
size_t nfree;
size_t nregs;
size_t size;
};
struct extent_util_stats_verbose_s {
void *slabcur_addr;
size_t nfree;
size_t nregs;
size_t size;
size_t bin_nfree;
size_t bin_nregs;
};
#endif /* JEMALLOC_INTERNAL_EXTENT_STRUCTS_H */
+8 -2
View File
@@ -4,9 +4,10 @@
typedef struct extent_s extent_t;
typedef struct extents_s extents_t;
#define EXTENT_HOOKS_INITIALIZER NULL
typedef struct extent_util_stats_s extent_util_stats_t;
typedef struct extent_util_stats_verbose_s extent_util_stats_verbose_t;
#define EXTENT_GROW_MAX_PIND (NPSIZES - 1)
#define EXTENT_HOOKS_INITIALIZER NULL
/*
* When reuse (and split) an active extent, (1U << opt_lg_extent_max_active_fit)
@@ -14,4 +15,9 @@ typedef struct extents_s extents_t;
*/
#define LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT 6
typedef enum {
EXTENT_NOT_HEAD,
EXTENT_IS_HEAD /* Only relevant for Windows && opt.retain. */
} extent_head_state_t;
#endif /* JEMALLOC_INTERNAL_EXTENT_TYPES_H */
+33 -32
View File
@@ -104,8 +104,8 @@ hash_x86_32(const void *key, int len, uint32_t seed) {
uint32_t k1 = 0;
switch (len & 3) {
case 3: k1 ^= tail[2] << 16;
case 2: k1 ^= tail[1] << 8;
case 3: k1 ^= tail[2] << 16; JEMALLOC_FALLTHROUGH
case 2: k1 ^= tail[1] << 8; JEMALLOC_FALLTHROUGH
case 1: k1 ^= tail[0]; k1 *= c1; k1 = hash_rotl_32(k1, 15);
k1 *= c2; h1 ^= k1;
}
@@ -119,7 +119,7 @@ hash_x86_32(const void *key, int len, uint32_t seed) {
return h1;
}
UNUSED static inline void
static inline void
hash_x86_128(const void *key, const int len, uint32_t seed,
uint64_t r_out[2]) {
const uint8_t * data = (const uint8_t *) key;
@@ -177,28 +177,29 @@ hash_x86_128(const void *key, const int len, uint32_t seed,
uint32_t k4 = 0;
switch (len & 15) {
case 15: k4 ^= tail[14] << 16;
case 14: k4 ^= tail[13] << 8;
case 15: k4 ^= tail[14] << 16; JEMALLOC_FALLTHROUGH
case 14: k4 ^= tail[13] << 8; JEMALLOC_FALLTHROUGH
case 13: k4 ^= tail[12] << 0;
k4 *= c4; k4 = hash_rotl_32(k4, 18); k4 *= c1; h4 ^= k4;
case 12: k3 ^= tail[11] << 24;
case 11: k3 ^= tail[10] << 16;
case 10: k3 ^= tail[ 9] << 8;
JEMALLOC_FALLTHROUGH
case 12: k3 ^= tail[11] << 24; JEMALLOC_FALLTHROUGH
case 11: k3 ^= tail[10] << 16; JEMALLOC_FALLTHROUGH
case 10: k3 ^= tail[ 9] << 8; JEMALLOC_FALLTHROUGH
case 9: k3 ^= tail[ 8] << 0;
k3 *= c3; k3 = hash_rotl_32(k3, 17); k3 *= c4; h3 ^= k3;
case 8: k2 ^= tail[ 7] << 24;
case 7: k2 ^= tail[ 6] << 16;
case 6: k2 ^= tail[ 5] << 8;
JEMALLOC_FALLTHROUGH
case 8: k2 ^= tail[ 7] << 24; JEMALLOC_FALLTHROUGH
case 7: k2 ^= tail[ 6] << 16; JEMALLOC_FALLTHROUGH
case 6: k2 ^= tail[ 5] << 8; JEMALLOC_FALLTHROUGH
case 5: k2 ^= tail[ 4] << 0;
k2 *= c2; k2 = hash_rotl_32(k2, 16); k2 *= c3; h2 ^= k2;
case 4: k1 ^= tail[ 3] << 24;
case 3: k1 ^= tail[ 2] << 16;
case 2: k1 ^= tail[ 1] << 8;
JEMALLOC_FALLTHROUGH
case 4: k1 ^= tail[ 3] << 24; JEMALLOC_FALLTHROUGH
case 3: k1 ^= tail[ 2] << 16; JEMALLOC_FALLTHROUGH
case 2: k1 ^= tail[ 1] << 8; JEMALLOC_FALLTHROUGH
case 1: k1 ^= tail[ 0] << 0;
k1 *= c1; k1 = hash_rotl_32(k1, 15); k1 *= c2; h1 ^= k1;
JEMALLOC_FALLTHROUGH
}
}
@@ -220,7 +221,7 @@ hash_x86_128(const void *key, const int len, uint32_t seed,
r_out[1] = (((uint64_t) h4) << 32) | h3;
}
UNUSED static inline void
static inline void
hash_x64_128(const void *key, const int len, const uint32_t seed,
uint64_t r_out[2]) {
const uint8_t *data = (const uint8_t *) key;
@@ -260,22 +261,22 @@ hash_x64_128(const void *key, const int len, const uint32_t seed,
uint64_t k2 = 0;
switch (len & 15) {
case 15: k2 ^= ((uint64_t)(tail[14])) << 48; /* falls through */
case 14: k2 ^= ((uint64_t)(tail[13])) << 40; /* falls through */
case 13: k2 ^= ((uint64_t)(tail[12])) << 32; /* falls through */
case 12: k2 ^= ((uint64_t)(tail[11])) << 24; /* falls through */
case 11: k2 ^= ((uint64_t)(tail[10])) << 16; /* falls through */
case 10: k2 ^= ((uint64_t)(tail[ 9])) << 8; /* falls through */
case 15: k2 ^= ((uint64_t)(tail[14])) << 48; JEMALLOC_FALLTHROUGH
case 14: k2 ^= ((uint64_t)(tail[13])) << 40; JEMALLOC_FALLTHROUGH
case 13: k2 ^= ((uint64_t)(tail[12])) << 32; JEMALLOC_FALLTHROUGH
case 12: k2 ^= ((uint64_t)(tail[11])) << 24; JEMALLOC_FALLTHROUGH
case 11: k2 ^= ((uint64_t)(tail[10])) << 16; JEMALLOC_FALLTHROUGH
case 10: k2 ^= ((uint64_t)(tail[ 9])) << 8; JEMALLOC_FALLTHROUGH
case 9: k2 ^= ((uint64_t)(tail[ 8])) << 0;
k2 *= c2; k2 = hash_rotl_64(k2, 33); k2 *= c1; h2 ^= k2;
/* falls through */
case 8: k1 ^= ((uint64_t)(tail[ 7])) << 56; /* falls through */
case 7: k1 ^= ((uint64_t)(tail[ 6])) << 48; /* falls through */
case 6: k1 ^= ((uint64_t)(tail[ 5])) << 40; /* falls through */
case 5: k1 ^= ((uint64_t)(tail[ 4])) << 32; /* falls through */
case 4: k1 ^= ((uint64_t)(tail[ 3])) << 24; /* falls through */
case 3: k1 ^= ((uint64_t)(tail[ 2])) << 16; /* falls through */
case 2: k1 ^= ((uint64_t)(tail[ 1])) << 8; /* falls through */
JEMALLOC_FALLTHROUGH
case 8: k1 ^= ((uint64_t)(tail[ 7])) << 56; JEMALLOC_FALLTHROUGH
case 7: k1 ^= ((uint64_t)(tail[ 6])) << 48; JEMALLOC_FALLTHROUGH
case 6: k1 ^= ((uint64_t)(tail[ 5])) << 40; JEMALLOC_FALLTHROUGH
case 5: k1 ^= ((uint64_t)(tail[ 4])) << 32; JEMALLOC_FALLTHROUGH
case 4: k1 ^= ((uint64_t)(tail[ 3])) << 24; JEMALLOC_FALLTHROUGH
case 3: k1 ^= ((uint64_t)(tail[ 2])) << 16; JEMALLOC_FALLTHROUGH
case 2: k1 ^= ((uint64_t)(tail[ 1])) << 8; JEMALLOC_FALLTHROUGH
case 1: k1 ^= ((uint64_t)(tail[ 0])) << 0;
k1 *= c1; k1 = hash_rotl_64(k1, 31); k1 *= c2; h1 ^= k1;
}
+163
View File
@@ -0,0 +1,163 @@
#ifndef JEMALLOC_INTERNAL_HOOK_H
#define JEMALLOC_INTERNAL_HOOK_H
#include "jemalloc/internal/tsd.h"
/*
* This API is *extremely* experimental, and may get ripped out, changed in API-
* and ABI-incompatible ways, be insufficiently or incorrectly documented, etc.
*
* It allows hooking the stateful parts of the API to see changes as they
* happen.
*
* Allocation hooks are called after the allocation is done, free hooks are
* called before the free is done, and expand hooks are called after the
* allocation is expanded.
*
* For realloc and rallocx, if the expansion happens in place, the expansion
* hook is called. If it is moved, then the alloc hook is called on the new
* location, and then the free hook is called on the old location (i.e. both
* hooks are invoked in between the alloc and the dalloc).
*
* If we return NULL from OOM, then usize might not be trustworthy. Calling
* realloc(NULL, size) only calls the alloc hook, and calling realloc(ptr, 0)
* only calls the free hook. (Calling realloc(NULL, 0) is treated as malloc(0),
* and only calls the alloc hook).
*
* Reentrancy:
* Reentrancy is guarded against from within the hook implementation. If you
* call allocator functions from within a hook, the hooks will not be invoked
* again.
* Threading:
* The installation of a hook synchronizes with all its uses. If you can
* prove the installation of a hook happens-before a jemalloc entry point,
* then the hook will get invoked (unless there's a racing removal).
*
* Hook insertion appears to be atomic at a per-thread level (i.e. if a thread
* allocates and has the alloc hook invoked, then a subsequent free on the
* same thread will also have the free hook invoked).
*
* The *removal* of a hook does *not* block until all threads are done with
* the hook. Hook authors have to be resilient to this, and need some
* out-of-band mechanism for cleaning up any dynamically allocated memory
* associated with their hook.
* Ordering:
* Order of hook execution is unspecified, and may be different than insertion
* order.
*/
#define HOOK_MAX 4
enum hook_alloc_e {
hook_alloc_malloc,
hook_alloc_posix_memalign,
hook_alloc_aligned_alloc,
hook_alloc_calloc,
hook_alloc_memalign,
hook_alloc_valloc,
hook_alloc_mallocx,
/* The reallocating functions have both alloc and dalloc variants */
hook_alloc_realloc,
hook_alloc_rallocx,
};
/*
* We put the enum typedef after the enum, since this file may get included by
* jemalloc_cpp.cpp, and C++ disallows enum forward declarations.
*/
typedef enum hook_alloc_e hook_alloc_t;
enum hook_dalloc_e {
hook_dalloc_free,
hook_dalloc_dallocx,
hook_dalloc_sdallocx,
/*
* The dalloc halves of reallocation (not called if in-place expansion
* happens).
*/
hook_dalloc_realloc,
hook_dalloc_rallocx,
};
typedef enum hook_dalloc_e hook_dalloc_t;
enum hook_expand_e {
hook_expand_realloc,
hook_expand_rallocx,
hook_expand_xallocx,
};
typedef enum hook_expand_e hook_expand_t;
typedef void (*hook_alloc)(
void *extra, hook_alloc_t type, void *result, uintptr_t result_raw,
uintptr_t args_raw[3]);
typedef void (*hook_dalloc)(
void *extra, hook_dalloc_t type, void *address, uintptr_t args_raw[3]);
typedef void (*hook_expand)(
void *extra, hook_expand_t type, void *address, size_t old_usize,
size_t new_usize, uintptr_t result_raw, uintptr_t args_raw[4]);
typedef struct hooks_s hooks_t;
struct hooks_s {
hook_alloc alloc_hook;
hook_dalloc dalloc_hook;
hook_expand expand_hook;
void *extra;
};
/*
* Begin implementation details; everything above this point might one day live
* in a public API. Everything below this point never will.
*/
/*
* The realloc pathways haven't gotten any refactoring love in a while, and it's
* fairly difficult to pass information from the entry point to the hooks. We
* put the informaiton the hooks will need into a struct to encapsulate
* everything.
*
* Much of these pathways are force-inlined, so that the compiler can avoid
* materializing this struct until we hit an extern arena function. For fairly
* goofy reasons, *many* of the realloc paths hit an extern arena function.
* These paths are cold enough that it doesn't matter; eventually, we should
* rewrite the realloc code to make the expand-in-place and the
* free-then-realloc paths more orthogonal, at which point we don't need to
* spread the hook logic all over the place.
*/
typedef struct hook_ralloc_args_s hook_ralloc_args_t;
struct hook_ralloc_args_s {
/* I.e. as opposed to rallocx. */
bool is_realloc;
/*
* The expand hook takes 4 arguments, even if only 3 are actually used;
* we add an extra one in case the user decides to memcpy without
* looking too closely at the hooked function.
*/
uintptr_t args[4];
};
/*
* Returns an opaque handle to be used when removing the hook. NULL means that
* we couldn't install the hook.
*/
bool hook_boot();
void *hook_install(tsdn_t *tsdn, hooks_t *hooks);
/* Uninstalls the hook with the handle previously returned from hook_install. */
void hook_remove(tsdn_t *tsdn, void *opaque);
/* Hooks */
void hook_invoke_alloc(hook_alloc_t type, void *result, uintptr_t result_raw,
uintptr_t args_raw[3]);
void hook_invoke_dalloc(hook_dalloc_t type, void *address,
uintptr_t args_raw[3]);
void hook_invoke_expand(hook_expand_t type, void *address, size_t old_usize,
size_t new_usize, uintptr_t result_raw, uintptr_t args_raw[4]);
#endif /* JEMALLOC_INTERNAL_HOOK_H */
@@ -31,6 +31,9 @@
# include <sys/uio.h>
# endif
# include <pthread.h>
# ifdef __FreeBSD__
# include <pthread_np.h>
# endif
# include <signal.h>
# ifdef JEMALLOC_OS_UNFAIR_LOCK
# include <os/lock.h>
@@ -48,25 +48,13 @@
/* Defined if GCC __atomic atomics are available. */
#undef JEMALLOC_GCC_ATOMIC_ATOMICS
/* and the 8-bit variant support. */
#undef JEMALLOC_GCC_U8_ATOMIC_ATOMICS
/* Defined if GCC __sync atomics are available. */
#undef JEMALLOC_GCC_SYNC_ATOMICS
/*
* Defined if __sync_add_and_fetch(uint32_t *, uint32_t) and
* __sync_sub_and_fetch(uint32_t *, uint32_t) are available, despite
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
* functions are defined in libgcc instead of being inlines).
*/
#undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4
/*
* Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
* __sync_sub_and_fetch(uint64_t *, uint64_t) are available, despite
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
* functions are defined in libgcc instead of being inlines).
*/
#undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8
/* and the 8-bit variant support. */
#undef JEMALLOC_GCC_U8_SYNC_ATOMICS
/*
* Defined if __builtin_clz() and __builtin_clzl() are available.
@@ -78,12 +66,6 @@
*/
#undef JEMALLOC_OS_UNFAIR_LOCK
/*
* Defined if OSSpin*() functions are available, as provided by Darwin, and
* documented in the spinlock(3) manual page.
*/
#undef JEMALLOC_OSSPIN
/* Defined if syscall(2) is usable. */
#undef JEMALLOC_USE_SYSCALL
@@ -153,6 +135,9 @@
/* JEMALLOC_STATS enables statistics calculation. */
#undef JEMALLOC_STATS
/* JEMALLOC_EXPERIMENTAL_SMALLOCX_API enables experimental smallocx API. */
#undef JEMALLOC_EXPERIMENTAL_SMALLOCX_API
/* JEMALLOC_PROF enables allocation profiling. */
#undef JEMALLOC_PROF
@@ -233,6 +218,12 @@
#undef JEMALLOC_INTERNAL_FFSL
#undef JEMALLOC_INTERNAL_FFS
/*
* popcount*() functions to use for bitmapping.
*/
#undef JEMALLOC_INTERNAL_POPCOUNTL
#undef JEMALLOC_INTERNAL_POPCOUNT
/*
* If defined, explicitly attempt to more uniformly distribute large allocation
* pointer alignments across all cache indices.
@@ -245,6 +236,12 @@
*/
#undef JEMALLOC_LOG
/*
* If defined, use readlinkat() (instead of readlink()) to follow
* /etc/malloc_conf.
*/
#undef JEMALLOC_READLINKAT
/*
* Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
*/
@@ -363,4 +360,7 @@
*/
#undef JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE
/* Performs additional safety checks when defined. */
#undef JEMALLOC_OPT_SAFETY_CHECKS
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
@@ -2,7 +2,6 @@
#define JEMALLOC_INTERNAL_EXTERNS_H
#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/tsd_types.h"
/* TSD checks this to set thread local slow state accordingly. */
@@ -11,6 +10,7 @@ extern bool malloc_slow;
/* Run-time options. */
extern bool opt_abort;
extern bool opt_abort_conf;
extern bool opt_confirm_conf;
extern const char *opt_junk;
extern bool opt_junk_alloc;
extern bool opt_junk_free;
@@ -25,6 +25,9 @@ extern unsigned ncpus;
/* Number of arenas used for automatic multiplexing of threads and arenas. */
extern unsigned narenas_auto;
/* Base index for manual arenas. */
extern unsigned manual_arena_base;
/*
* Arenas that are used to service external requests. Not all elements of the
* arenas array are necessarily used; arenas are created lazily as needed.
@@ -49,5 +52,6 @@ void jemalloc_prefork(void);
void jemalloc_postfork_parent(void);
void jemalloc_postfork_child(void);
bool malloc_initialized(void);
void je_sdallocx_noflags(void *ptr, size_t size);
#endif /* JEMALLOC_INTERNAL_EXTERNS_H */
@@ -4,13 +4,15 @@
#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/bit_util.h"
#include "jemalloc/internal/jemalloc_internal_types.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/ticker.h"
JEMALLOC_ALWAYS_INLINE malloc_cpuid_t
malloc_getcpu(void) {
assert(have_percpu_arena);
#if defined(JEMALLOC_HAVE_SCHED_GETCPU)
#if defined(_WIN32)
return GetCurrentProcessorNumber();
#elif defined(JEMALLOC_HAVE_SCHED_GETCPU)
return (malloc_cpuid_t)sched_getcpu();
#else
not_reached();
@@ -108,14 +110,14 @@ decay_ticker_get(tsd_t *tsd, unsigned ind) {
JEMALLOC_ALWAYS_INLINE cache_bin_t *
tcache_small_bin_get(tcache_t *tcache, szind_t binind) {
assert(binind < NBINS);
assert(binind < SC_NBINS);
return &tcache->bins_small[binind];
}
JEMALLOC_ALWAYS_INLINE cache_bin_t *
tcache_large_bin_get(tcache_t *tcache, szind_t binind) {
assert(binind >= NBINS &&binind < nhbins);
return &tcache->bins_large[binind - NBINS];
assert(binind >= SC_NBINS &&binind < nhbins);
return &tcache->bins_large[binind - SC_NBINS];
}
JEMALLOC_ALWAYS_INLINE bool
@@ -156,7 +158,7 @@ pre_reentrancy(tsd_t *tsd, arena_t *arena) {
if (fast) {
/* Prepare slow path for reentrancy. */
tsd_slow_update(tsd);
assert(tsd->state == tsd_state_nominal_slow);
assert(tsd_state_get(tsd) == tsd_state_nominal_slow);
}
}
@@ -71,7 +71,8 @@ arena_ichoose(tsd_t *tsd, arena_t *arena) {
static inline bool
arena_is_auto(arena_t *arena) {
assert(narenas_auto > 0);
return (arena_ind_get(arena) < narenas_auto);
return (arena_ind_get(arena) < manual_arena_base);
}
JEMALLOC_ALWAYS_INLINE extent_t *
@@ -1,6 +1,7 @@
#ifndef JEMALLOC_INTERNAL_INLINES_C_H
#define JEMALLOC_INTERNAL_INLINES_C_H
#include "jemalloc/internal/hook.h"
#include "jemalloc/internal/jemalloc_internal_types.h"
#include "jemalloc/internal/sz.h"
#include "jemalloc/internal/witness.h"
@@ -42,7 +43,6 @@ iallocztm(tsdn_t *tsdn, size_t size, szind_t ind, bool zero, tcache_t *tcache,
bool is_internal, arena_t *arena, bool slow_path) {
void *ret;
assert(size != 0);
assert(!is_internal || tcache == NULL);
assert(!is_internal || arena == NULL || arena_is_auto(arena));
if (!tsdn_null(tsdn) && tsd_reentrancy_level_get(tsdn_tsd(tsdn)) == 0) {
@@ -133,31 +133,20 @@ isdalloct(tsdn_t *tsdn, void *ptr, size_t size, tcache_t *tcache,
JEMALLOC_ALWAYS_INLINE void *
iralloct_realign(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size,
size_t extra, size_t alignment, bool zero, tcache_t *tcache,
arena_t *arena) {
size_t alignment, bool zero, tcache_t *tcache, arena_t *arena,
hook_ralloc_args_t *hook_args) {
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
WITNESS_RANK_CORE, 0);
void *p;
size_t usize, copysize;
usize = sz_sa2u(size + extra, alignment);
if (unlikely(usize == 0 || usize > LARGE_MAXCLASS)) {
usize = sz_sa2u(size, alignment);
if (unlikely(usize == 0 || usize > SC_LARGE_MAXCLASS)) {
return NULL;
}
p = ipalloct(tsdn, usize, alignment, zero, tcache, arena);
if (p == NULL) {
if (extra == 0) {
return NULL;
}
/* Try again, without extra this time. */
usize = sz_sa2u(size, alignment);
if (unlikely(usize == 0 || usize > LARGE_MAXCLASS)) {
return NULL;
}
p = ipalloct(tsdn, usize, alignment, zero, tcache, arena);
if (p == NULL) {
return NULL;
}
return NULL;
}
/*
* Copy at most size bytes (not size+extra), since the caller has no
@@ -165,13 +154,26 @@ iralloct_realign(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size,
*/
copysize = (size < oldsize) ? size : oldsize;
memcpy(p, ptr, copysize);
hook_invoke_alloc(hook_args->is_realloc
? hook_alloc_realloc : hook_alloc_rallocx, p, (uintptr_t)p,
hook_args->args);
hook_invoke_dalloc(hook_args->is_realloc
? hook_dalloc_realloc : hook_dalloc_rallocx, ptr, hook_args->args);
isdalloct(tsdn, ptr, oldsize, tcache, NULL, true);
return p;
}
/*
* is_realloc threads through the knowledge of whether or not this call comes
* from je_realloc (as opposed to je_rallocx); this ensures that we pass the
* correct entry point into any hooks.
* Note that these functions are all force-inlined, so no actual bool gets
* passed-around anywhere.
*/
JEMALLOC_ALWAYS_INLINE void *
iralloct(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size, size_t alignment,
bool zero, tcache_t *tcache, arena_t *arena) {
bool zero, tcache_t *tcache, arena_t *arena, hook_ralloc_args_t *hook_args)
{
assert(ptr != NULL);
assert(size != 0);
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
@@ -183,24 +185,24 @@ iralloct(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size, size_t alignment,
* Existing object alignment is inadequate; allocate new space
* and copy.
*/
return iralloct_realign(tsdn, ptr, oldsize, size, 0, alignment,
zero, tcache, arena);
return iralloct_realign(tsdn, ptr, oldsize, size, alignment,
zero, tcache, arena, hook_args);
}
return arena_ralloc(tsdn, arena, ptr, oldsize, size, alignment, zero,
tcache);
tcache, hook_args);
}
JEMALLOC_ALWAYS_INLINE void *
iralloc(tsd_t *tsd, void *ptr, size_t oldsize, size_t size, size_t alignment,
bool zero) {
bool zero, hook_ralloc_args_t *hook_args) {
return iralloct(tsd_tsdn(tsd), ptr, oldsize, size, alignment, zero,
tcache_get(tsd), NULL);
tcache_get(tsd), NULL, hook_args);
}
JEMALLOC_ALWAYS_INLINE bool
ixalloc(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size, size_t extra,
size_t alignment, bool zero) {
size_t alignment, bool zero, size_t *newsize) {
assert(ptr != NULL);
assert(size != 0);
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
@@ -209,10 +211,12 @@ ixalloc(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size, size_t extra,
if (alignment != 0 && ((uintptr_t)ptr & ((uintptr_t)alignment-1))
!= 0) {
/* Existing object alignment is inadequate. */
*newsize = oldsize;
return true;
}
return arena_ralloc_no_move(tsdn, ptr, oldsize, size, extra, zero);
return arena_ralloc_no_move(tsdn, ptr, oldsize, size, extra, zero,
newsize);
}
JEMALLOC_ALWAYS_INLINE int
@@ -228,18 +232,20 @@ iget_defrag_hint(tsdn_t *tsdn, void* ptr) {
extent_t *slab = iealloc(tsdn, ptr);
arena_t *arena = extent_arena_get(slab);
szind_t binind = extent_szind_get(slab);
bin_t *bin = &arena->bins[binind];
malloc_mutex_lock(tsdn, &bin->lock);
unsigned shardind = extent_binshard_get(slab);
bins_t *bin = &arena->bins[binind];
bin_t* binshard = &bin->bin_shards[shardind];
malloc_mutex_lock(tsdn, &binshard->lock);
/* don't bother moving allocations from the slab currently used for new allocations */
if (slab != bin->slabcur) {
if (slab != binshard->slabcur) {
int free_in_slab = extent_nfree_get(slab);
if (free_in_slab) {
const bin_info_t *bin_info = &bin_infos[binind];
unsigned long curslabs = bin->stats.curslabs;
size_t curregs = bin->stats.curregs;
if (bin->slabcur) {
ssize_t curslabs = binshard->stats.curslabs;
size_t curregs = binshard->stats.curregs;
if (binshard->slabcur) {
/* remove slabcur from the overall utilization */
curregs -= bin_info->nregs - extent_nfree_get(bin->slabcur);
curregs -= bin_info->nregs - extent_nfree_get(binshard->slabcur);
curslabs -= 1;
}
/* Compare the utilization ratio of the slab in question to the total average,
@@ -249,7 +255,7 @@ iget_defrag_hint(tsdn_t *tsdn, void* ptr) {
defrag = (bin_info->nregs - free_in_slab) * curslabs <= curregs;
}
}
malloc_mutex_unlock(tsdn, &bin->lock);
malloc_mutex_unlock(tsdn, &binshard->lock);
}
return defrag;
}
@@ -30,7 +30,7 @@
# define restrict
#endif
/* Various function pointers are statick and immutable except during testing. */
/* Various function pointers are static and immutable except during testing. */
#ifdef JEMALLOC_JET
# define JET_MUTABLE
#else
@@ -40,4 +40,75 @@
#define JEMALLOC_VA_ARGS_HEAD(head, ...) head
#define JEMALLOC_VA_ARGS_TAIL(head, ...) __VA_ARGS__
#if (defined(__GNUC__) || defined(__GNUG__)) && !defined(__clang__) \
&& defined(JEMALLOC_HAVE_ATTR) && (__GNUC__ >= 7)
#define JEMALLOC_FALLTHROUGH JEMALLOC_ATTR(fallthrough);
#else
#define JEMALLOC_FALLTHROUGH /* falls through */
#endif
/* Diagnostic suppression macros */
#if defined(_MSC_VER) && !defined(__clang__)
# define JEMALLOC_DIAGNOSTIC_PUSH __pragma(warning(push))
# define JEMALLOC_DIAGNOSTIC_POP __pragma(warning(pop))
# define JEMALLOC_DIAGNOSTIC_IGNORE(W) __pragma(warning(disable:W))
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
# define JEMALLOC_DIAGNOSTIC_IGNORE_TYPE_LIMITS
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
# define JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
/* #pragma GCC diagnostic first appeared in gcc 4.6. */
#elif (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && \
(__GNUC_MINOR__ > 5)))) || defined(__clang__)
/*
* The JEMALLOC_PRAGMA__ macro is an implementation detail of the GCC and Clang
* diagnostic suppression macros and should not be used anywhere else.
*/
# define JEMALLOC_PRAGMA__(X) _Pragma(#X)
# define JEMALLOC_DIAGNOSTIC_PUSH JEMALLOC_PRAGMA__(GCC diagnostic push)
# define JEMALLOC_DIAGNOSTIC_POP JEMALLOC_PRAGMA__(GCC diagnostic pop)
# define JEMALLOC_DIAGNOSTIC_IGNORE(W) \
JEMALLOC_PRAGMA__(GCC diagnostic ignored W)
/*
* The -Wmissing-field-initializers warning is buggy in GCC versions < 5.1 and
* all clang versions up to version 7 (currently trunk, unreleased). This macro
* suppresses the warning for the affected compiler versions only.
*/
# if ((defined(__GNUC__) && !defined(__clang__)) && (__GNUC__ < 5)) || \
defined(__clang__)
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS \
JEMALLOC_DIAGNOSTIC_IGNORE("-Wmissing-field-initializers")
# else
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
# endif
# define JEMALLOC_DIAGNOSTIC_IGNORE_TYPE_LIMITS \
JEMALLOC_DIAGNOSTIC_IGNORE("-Wtype-limits")
# define JEMALLOC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER \
JEMALLOC_DIAGNOSTIC_IGNORE("-Wunused-parameter")
# if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN \
JEMALLOC_DIAGNOSTIC_IGNORE("-Walloc-size-larger-than=")
# else
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
# endif
# define JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS \
JEMALLOC_DIAGNOSTIC_PUSH \
JEMALLOC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER
#else
# define JEMALLOC_DIAGNOSTIC_PUSH
# define JEMALLOC_DIAGNOSTIC_POP
# define JEMALLOC_DIAGNOSTIC_IGNORE(W)
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
# define JEMALLOC_DIAGNOSTIC_IGNORE_TYPE_LIMITS
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
# define JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
#endif
/*
* Disables spurious diagnostics for all headers. Since these headers are not
* included by users directly, it does not affect their diagnostic settings.
*/
JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
#endif /* JEMALLOC_INTERNAL_MACROS_H */
@@ -1,6 +1,8 @@
#ifndef JEMALLOC_INTERNAL_TYPES_H
#define JEMALLOC_INTERNAL_TYPES_H
#include "jemalloc/internal/quantum.h"
/* Page size index type. */
typedef unsigned pszind_t;
@@ -50,79 +52,6 @@ typedef int malloc_cpuid_t;
/* Smallest size class to support. */
#define TINY_MIN (1U << LG_TINY_MIN)
/*
* Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
* classes).
*/
#ifndef LG_QUANTUM
# if (defined(__i386__) || defined(_M_IX86))
# define LG_QUANTUM 4
# endif
# ifdef __ia64__
# define LG_QUANTUM 4
# endif
# ifdef __alpha__
# define LG_QUANTUM 4
# endif
# if (defined(__sparc64__) || defined(__sparcv9) || defined(__sparc_v9__))
# define LG_QUANTUM 4
# endif
# if (defined(__amd64__) || defined(__x86_64__) || defined(_M_X64))
# define LG_QUANTUM 4
# endif
# ifdef __arm__
# define LG_QUANTUM 3
# endif
# ifdef __aarch64__
# define LG_QUANTUM 4
# endif
# ifdef __hppa__
# define LG_QUANTUM 4
# endif
# ifdef __m68k__
# define LG_QUANTUM 3
# endif
# ifdef __mips__
# define LG_QUANTUM 3
# endif
# ifdef __nios2__
# define LG_QUANTUM 3
# endif
# ifdef __or1k__
# define LG_QUANTUM 3
# endif
# ifdef __powerpc__
# define LG_QUANTUM 4
# endif
# if defined(__riscv) || defined(__riscv__)
# define LG_QUANTUM 4
# endif
# ifdef __s390__
# define LG_QUANTUM 4
# endif
# if (defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || \
defined(__SH4_SINGLE_ONLY__))
# define LG_QUANTUM 4
# endif
# ifdef __tile__
# define LG_QUANTUM 4
# endif
# ifdef __le32__
# define LG_QUANTUM 4
# endif
# ifndef LG_QUANTUM
# error "Unknown minimum alignment for architecture; specify via "
"--with-lg-quantum"
# endif
#endif
#define QUANTUM ((size_t)(1U << LG_QUANTUM))
#define QUANTUM_MASK (QUANTUM - 1)
/* Return the smallest quantum multiple that is >= a. */
#define QUANTUM_CEILING(a) \
(((a) + QUANTUM_MASK) & ~QUANTUM_MASK)
#define LONG ((size_t)(1U << LG_SIZEOF_LONG))
#define LONG_MASK (LONG - 1)
@@ -21,7 +21,7 @@
# include "../jemalloc@install_suffix@.h"
#endif
#if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN))
#if defined(JEMALLOC_OSATOMIC)
#include <libkern/OSAtomic.h>
#endif
@@ -45,7 +45,7 @@
# include "jemalloc/internal/private_namespace_jet.h"
# endif
#endif
#include "jemalloc/internal/hooks.h"
#include "jemalloc/internal/test_hooks.h"
#ifdef JEMALLOC_DEFINE_MADVISE_FREE
# define JEMALLOC_MADV_FREE 8
@@ -161,7 +161,26 @@ static const bool config_log =
false
#endif
;
#ifdef JEMALLOC_HAVE_SCHED_GETCPU
/*
* Are extra safety checks enabled; things like checking the size of sized
* deallocations, double-frees, etc.
*/
static const bool config_opt_safety_checks =
#ifdef JEMALLOC_OPT_SAFETY_CHECKS
true
#elif defined(JEMALLOC_DEBUG)
/*
* This lets us only guard safety checks by one flag instead of two; fast
* checks can guard solely by config_opt_safety_checks and run in debug mode
* too.
*/
true
#else
false
#endif
;
#if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU)
/* Currently percpu_arena depends on sched_getcpu. */
#define JEMALLOC_PERCPU_ARENA
#endif
+8 -2
View File
@@ -1,13 +1,16 @@
#ifndef JEMALLOC_INTERNAL_LARGE_EXTERNS_H
#define JEMALLOC_INTERNAL_LARGE_EXTERNS_H
#include "jemalloc/internal/hook.h"
void *large_malloc(tsdn_t *tsdn, arena_t *arena, size_t usize, bool zero);
void *large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
bool zero);
bool large_ralloc_no_move(tsdn_t *tsdn, extent_t *extent, size_t usize_min,
size_t usize_max, bool zero);
void *large_ralloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent, size_t usize,
size_t alignment, bool zero, tcache_t *tcache);
void *large_ralloc(tsdn_t *tsdn, arena_t *arena, void *ptr, size_t usize,
size_t alignment, bool zero, tcache_t *tcache,
hook_ralloc_args_t *hook_args);
typedef void (large_dalloc_junk_t)(void *, size_t);
extern large_dalloc_junk_t *JET_MUTABLE large_dalloc_junk;
@@ -23,4 +26,7 @@ prof_tctx_t *large_prof_tctx_get(tsdn_t *tsdn, const extent_t *extent);
void large_prof_tctx_set(tsdn_t *tsdn, extent_t *extent, prof_tctx_t *tctx);
void large_prof_tctx_reset(tsdn_t *tsdn, extent_t *extent);
nstime_t large_prof_alloc_time_get(const extent_t *extent);
void large_prof_alloc_time_set(extent_t *extent, nstime_t time);
#endif /* JEMALLOC_INTERNAL_LARGE_EXTERNS_H */
+1 -1
View File
@@ -54,7 +54,7 @@ size_t malloc_vsnprintf(char *str, size_t size, const char *format,
size_t malloc_snprintf(char *str, size_t size, const char *format, ...)
JEMALLOC_FORMAT_PRINTF(3, 4);
/*
* The caller can set write_cb and cbopaque to null to choose to print with the
* The caller can set write_cb to null to choose to print with the
* je_malloc_message hook.
*/
void malloc_vcprintf(void (*write_cb)(void *, const char *), void *cbopaque,
+57 -17
View File
@@ -37,14 +37,17 @@ struct malloc_mutex_s {
# endif
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
os_unfair_lock lock;
#elif (defined(JEMALLOC_OSSPIN))
OSSpinLock lock;
#elif (defined(JEMALLOC_MUTEX_INIT_CB))
pthread_mutex_t lock;
malloc_mutex_t *postponed_next;
#else
pthread_mutex_t lock;
#endif
/*
* Hint flag to avoid exclusive cache line contention
* during spin waiting
*/
atomic_b_t locked;
};
/*
* We only touch witness when configured w/ debug. However we
@@ -84,10 +87,6 @@ struct malloc_mutex_s {
# define MALLOC_MUTEX_LOCK(m) os_unfair_lock_lock(&(m)->lock)
# define MALLOC_MUTEX_UNLOCK(m) os_unfair_lock_unlock(&(m)->lock)
# define MALLOC_MUTEX_TRYLOCK(m) (!os_unfair_lock_trylock(&(m)->lock))
#elif (defined(JEMALLOC_OSSPIN))
# define MALLOC_MUTEX_LOCK(m) OSSpinLockLock(&(m)->lock)
# define MALLOC_MUTEX_UNLOCK(m) OSSpinLockUnlock(&(m)->lock)
# define MALLOC_MUTEX_TRYLOCK(m) (!OSSpinLockTry(&(m)->lock))
#else
# define MALLOC_MUTEX_LOCK(m) pthread_mutex_lock(&(m)->lock)
# define MALLOC_MUTEX_UNLOCK(m) pthread_mutex_unlock(&(m)->lock)
@@ -101,22 +100,37 @@ struct malloc_mutex_s {
#ifdef _WIN32
# define MALLOC_MUTEX_INITIALIZER
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, OS_UNFAIR_LOCK_INIT}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT)}
#elif (defined(JEMALLOC_OSSPIN))
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, 0}}, \
# if defined(JEMALLOC_DEBUG)
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, OS_UNFAIR_LOCK_INIT, ATOMIC_INIT(false)}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT), 0}
# else
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, OS_UNFAIR_LOCK_INIT, ATOMIC_INIT(false)}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT)}
# endif
#elif (defined(JEMALLOC_MUTEX_INIT_CB))
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, NULL}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT)}
# if (defined(JEMALLOC_DEBUG))
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, NULL, ATOMIC_INIT(false)}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT), 0}
# else
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, NULL, ATOMIC_INIT(false)}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT)}
# endif
#else
# define MALLOC_MUTEX_TYPE PTHREAD_MUTEX_DEFAULT
# if defined(JEMALLOC_DEBUG)
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT)}
{{{LOCK_PROF_DATA_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, ATOMIC_INIT(false)}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT), 0}
# else
# define MALLOC_MUTEX_INITIALIZER \
{{{LOCK_PROF_DATA_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, ATOMIC_INIT(false)}}, \
WITNESS_INITIALIZER("mutex", WITNESS_RANK_OMIT)}
# endif
#endif
#ifdef JEMALLOC_LAZY_LOCK
@@ -139,6 +153,7 @@ void malloc_mutex_lock_slow(malloc_mutex_t *mutex);
static inline void
malloc_mutex_lock_final(malloc_mutex_t *mutex) {
MALLOC_MUTEX_LOCK(mutex);
atomic_store_b(&mutex->locked, true, ATOMIC_RELAXED);
}
static inline bool
@@ -164,6 +179,7 @@ malloc_mutex_trylock(tsdn_t *tsdn, malloc_mutex_t *mutex) {
witness_assert_not_owner(tsdn_witness_tsdp_get(tsdn), &mutex->witness);
if (isthreaded) {
if (malloc_mutex_trylock_final(mutex)) {
atomic_store_b(&mutex->locked, true, ATOMIC_RELAXED);
return true;
}
mutex_owner_stats_update(tsdn, mutex);
@@ -203,6 +219,7 @@ malloc_mutex_lock(tsdn_t *tsdn, malloc_mutex_t *mutex) {
if (isthreaded) {
if (malloc_mutex_trylock_final(mutex)) {
malloc_mutex_lock_slow(mutex);
atomic_store_b(&mutex->locked, true, ATOMIC_RELAXED);
}
mutex_owner_stats_update(tsdn, mutex);
}
@@ -211,6 +228,7 @@ malloc_mutex_lock(tsdn_t *tsdn, malloc_mutex_t *mutex) {
static inline void
malloc_mutex_unlock(tsdn_t *tsdn, malloc_mutex_t *mutex) {
atomic_store_b(&mutex->locked, false, ATOMIC_RELAXED);
witness_unlock(tsdn_witness_tsdp_get(tsdn), &mutex->witness);
if (isthreaded) {
MALLOC_MUTEX_UNLOCK(mutex);
@@ -245,4 +263,26 @@ malloc_mutex_prof_read(tsdn_t *tsdn, mutex_prof_data_t *data,
atomic_store_u32(&data->n_waiting_thds, 0, ATOMIC_RELAXED);
}
static inline void
malloc_mutex_prof_accum(tsdn_t *tsdn, mutex_prof_data_t *data,
malloc_mutex_t *mutex) {
mutex_prof_data_t *source = &mutex->prof_data;
/* Can only read holding the mutex. */
malloc_mutex_assert_owner(tsdn, mutex);
nstime_add(&data->tot_wait_time, &source->tot_wait_time);
if (nstime_compare(&source->max_wait_time, &data->max_wait_time) > 0) {
nstime_copy(&data->max_wait_time, &source->max_wait_time);
}
data->n_wait_times += source->n_wait_times;
data->n_spin_acquired += source->n_spin_acquired;
if (data->max_n_thds < source->max_n_thds) {
data->max_n_thds = source->max_n_thds;
}
/* n_wait_thds is not reported. */
atomic_store_u32(&data->n_waiting_thds, 0, ATOMIC_RELAXED);
data->n_owner_switches += source->n_owner_switches;
data->n_lock_ops += source->n_lock_ops;
}
#endif /* JEMALLOC_INTERNAL_MUTEX_H */
+17 -8
View File
@@ -35,22 +35,31 @@ typedef enum {
mutex_prof_num_arena_mutexes
} mutex_prof_arena_ind_t;
/*
* The forth parameter is a boolean value that is true for derived rate counters
* and false for real ones.
*/
#define MUTEX_PROF_UINT64_COUNTERS \
OP(num_ops, uint64_t, "n_lock_ops") \
OP(num_wait, uint64_t, "n_waiting") \
OP(num_spin_acq, uint64_t, "n_spin_acq") \
OP(num_owner_switch, uint64_t, "n_owner_switch") \
OP(total_wait_time, uint64_t, "total_wait_ns") \
OP(max_wait_time, uint64_t, "max_wait_ns")
OP(num_ops, uint64_t, "n_lock_ops", false, num_ops) \
OP(num_ops_ps, uint64_t, "(#/sec)", true, num_ops) \
OP(num_wait, uint64_t, "n_waiting", false, num_wait) \
OP(num_wait_ps, uint64_t, "(#/sec)", true, num_wait) \
OP(num_spin_acq, uint64_t, "n_spin_acq", false, num_spin_acq) \
OP(num_spin_acq_ps, uint64_t, "(#/sec)", true, num_spin_acq) \
OP(num_owner_switch, uint64_t, "n_owner_switch", false, num_owner_switch) \
OP(num_owner_switch_ps, uint64_t, "(#/sec)", true, num_owner_switch) \
OP(total_wait_time, uint64_t, "total_wait_ns", false, total_wait_time) \
OP(total_wait_time_ps, uint64_t, "(#/sec)", true, total_wait_time) \
OP(max_wait_time, uint64_t, "max_wait_ns", false, max_wait_time)
#define MUTEX_PROF_UINT32_COUNTERS \
OP(max_num_thds, uint32_t, "max_n_thds")
OP(max_num_thds, uint32_t, "max_n_thds", false, max_num_thds)
#define MUTEX_PROF_COUNTERS \
MUTEX_PROF_UINT64_COUNTERS \
MUTEX_PROF_UINT32_COUNTERS
#define OP(counter, type, human) mutex_counter_##counter,
#define OP(counter, type, human, derived, base_counter) mutex_counter_##counter,
#define COUNTER_ENUM(counter_list, t) \
typedef enum { \
+14 -1
View File
@@ -14,6 +14,7 @@ extern bool opt_prof_gdump; /* High-water memory dumping. */
extern bool opt_prof_final; /* Final profile dumping. */
extern bool opt_prof_leak; /* Dump leak summary at exit. */
extern bool opt_prof_accum; /* Report cumulative bytes. */
extern bool opt_prof_log; /* Turn logging on at boot. */
extern char opt_prof_prefix[
/* Minimize memory bloat for non-prof builds. */
#ifdef JEMALLOC_PROF
@@ -45,7 +46,8 @@ extern size_t lg_prof_sample;
void prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated);
void prof_malloc_sample_object(tsdn_t *tsdn, const void *ptr, size_t usize,
prof_tctx_t *tctx);
void prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_tctx_t *tctx);
void prof_free_sampled_object(tsd_t *tsd, const void *ptr, size_t usize,
prof_tctx_t *tctx);
void bt_init(prof_bt_t *bt, void **vec);
void prof_backtrace(prof_bt_t *bt);
prof_tctx_t *prof_lookup(tsd_t *tsd, prof_bt_t *bt);
@@ -89,4 +91,15 @@ void prof_postfork_parent(tsdn_t *tsdn);
void prof_postfork_child(tsdn_t *tsdn);
void prof_sample_threshold_update(prof_tdata_t *tdata);
bool prof_log_start(tsdn_t *tsdn, const char *filename);
bool prof_log_stop(tsdn_t *tsdn);
#ifdef JEMALLOC_JET
size_t prof_log_bt_count(void);
size_t prof_log_alloc_count(void);
size_t prof_log_thr_count(void);
bool prof_log_is_logging(void);
bool prof_log_rep_check(void);
void prof_log_dummy_set(bool new_value);
#endif
#endif /* JEMALLOC_INTERNAL_PROF_EXTERNS_H */
+8 -6
View File
@@ -4,7 +4,8 @@
#include "jemalloc/internal/mutex.h"
static inline bool
prof_accum_add(tsdn_t *tsdn, prof_accum_t *prof_accum, uint64_t accumbytes) {
prof_accum_add(tsdn_t *tsdn, prof_accum_t *prof_accum,
uint64_t accumbytes) {
cassert(config_prof);
bool overflow;
@@ -42,7 +43,8 @@ prof_accum_add(tsdn_t *tsdn, prof_accum_t *prof_accum, uint64_t accumbytes) {
}
static inline void
prof_accum_cancel(tsdn_t *tsdn, prof_accum_t *prof_accum, size_t usize) {
prof_accum_cancel(tsdn_t *tsdn, prof_accum_t *prof_accum,
size_t usize) {
cassert(config_prof);
/*
@@ -55,15 +57,15 @@ prof_accum_cancel(tsdn_t *tsdn, prof_accum_t *prof_accum, size_t usize) {
#ifdef JEMALLOC_ATOMIC_U64
a0 = atomic_load_u64(&prof_accum->accumbytes, ATOMIC_RELAXED);
do {
a1 = (a0 >= LARGE_MINCLASS - usize) ? a0 - (LARGE_MINCLASS -
usize) : 0;
a1 = (a0 >= SC_LARGE_MINCLASS - usize)
? a0 - (SC_LARGE_MINCLASS - usize) : 0;
} while (!atomic_compare_exchange_weak_u64(&prof_accum->accumbytes, &a0,
a1, ATOMIC_RELAXED, ATOMIC_RELAXED));
#else
malloc_mutex_lock(tsdn, &prof_accum->mtx);
a0 = prof_accum->accumbytes;
a1 = (a0 >= LARGE_MINCLASS - usize) ? a0 - (LARGE_MINCLASS - usize) :
0;
a1 = (a0 >= SC_LARGE_MINCLASS - usize)
? a0 - (SC_LARGE_MINCLASS - usize) : 0;
prof_accum->accumbytes = a1;
malloc_mutex_unlock(tsdn, &prof_accum->mtx);
#endif
+60 -16
View File
@@ -1,6 +1,7 @@
#ifndef JEMALLOC_INTERNAL_PROF_INLINES_B_H
#define JEMALLOC_INTERNAL_PROF_INLINES_B_H
#include "jemalloc/internal/safety_check.h"
#include "jemalloc/internal/sz.h"
JEMALLOC_ALWAYS_INLINE bool
@@ -61,13 +62,54 @@ prof_tctx_reset(tsdn_t *tsdn, const void *ptr, prof_tctx_t *tctx) {
arena_prof_tctx_reset(tsdn, ptr, tctx);
}
JEMALLOC_ALWAYS_INLINE nstime_t
prof_alloc_time_get(tsdn_t *tsdn, const void *ptr, alloc_ctx_t *alloc_ctx) {
cassert(config_prof);
assert(ptr != NULL);
return arena_prof_alloc_time_get(tsdn, ptr, alloc_ctx);
}
JEMALLOC_ALWAYS_INLINE void
prof_alloc_time_set(tsdn_t *tsdn, const void *ptr, alloc_ctx_t *alloc_ctx,
nstime_t t) {
cassert(config_prof);
assert(ptr != NULL);
arena_prof_alloc_time_set(tsdn, ptr, alloc_ctx, t);
}
JEMALLOC_ALWAYS_INLINE bool
prof_sample_check(tsd_t *tsd, size_t usize, bool update) {
ssize_t check = update ? 0 : usize;
int64_t bytes_until_sample = tsd_bytes_until_sample_get(tsd);
if (update) {
bytes_until_sample -= usize;
if (tsd_nominal(tsd)) {
tsd_bytes_until_sample_set(tsd, bytes_until_sample);
}
}
if (likely(bytes_until_sample >= check)) {
return true;
}
return false;
}
JEMALLOC_ALWAYS_INLINE bool
prof_sample_accum_update(tsd_t *tsd, size_t usize, bool update,
prof_tdata_t **tdata_out) {
prof_tdata_t **tdata_out) {
prof_tdata_t *tdata;
cassert(config_prof);
/* Fastpath: no need to load tdata */
if (likely(prof_sample_check(tsd, usize, update))) {
return true;
}
bool booted = tsd_prof_tdata_get(tsd);
tdata = prof_tdata_get(tsd, true);
if (unlikely((uintptr_t)tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)) {
tdata = NULL;
@@ -81,21 +123,23 @@ prof_sample_accum_update(tsd_t *tsd, size_t usize, bool update,
return true;
}
if (likely(tdata->bytes_until_sample >= usize)) {
if (update) {
tdata->bytes_until_sample -= usize;
}
/*
* If this was the first creation of tdata, then
* prof_tdata_get() reset bytes_until_sample, so decrement and
* check it again
*/
if (!booted && prof_sample_check(tsd, usize, update)) {
return true;
} else {
if (tsd_reentrancy_level_get(tsd) > 0) {
return true;
}
/* Compute new sample threshold. */
if (update) {
prof_sample_threshold_update(tdata);
}
return !tdata->active;
}
if (tsd_reentrancy_level_get(tsd) > 0) {
return true;
}
/* Compute new sample threshold. */
if (update) {
prof_sample_threshold_update(tdata);
}
return !tdata->active;
}
JEMALLOC_ALWAYS_INLINE prof_tctx_t *
@@ -187,7 +231,7 @@ prof_realloc(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx,
* counters.
*/
if (unlikely(old_sampled)) {
prof_free_sampled_object(tsd, old_usize, old_tctx);
prof_free_sampled_object(tsd, ptr, old_usize, old_tctx);
}
}
@@ -199,7 +243,7 @@ prof_free(tsd_t *tsd, const void *ptr, size_t usize, alloc_ctx_t *alloc_ctx) {
assert(usize == isalloc(tsd_tsdn(tsd), ptr));
if (unlikely((uintptr_t)tctx > (uintptr_t)1U)) {
prof_free_sampled_object(tsd, usize, tctx);
prof_free_sampled_object(tsd, ptr, usize, tctx);
}
}
@@ -169,7 +169,6 @@ struct prof_tdata_s {
/* Sampling state. */
uint64_t prng_state;
uint64_t bytes_until_sample;
/* State used to avoid dumping while operating on prof internals. */
bool enq;
+77
View File
@@ -0,0 +1,77 @@
#ifndef JEMALLOC_INTERNAL_QUANTUM_H
#define JEMALLOC_INTERNAL_QUANTUM_H
/*
* Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
* classes).
*/
#ifndef LG_QUANTUM
# if (defined(__i386__) || defined(_M_IX86))
# define LG_QUANTUM 4
# endif
# ifdef __ia64__
# define LG_QUANTUM 4
# endif
# ifdef __alpha__
# define LG_QUANTUM 4
# endif
# if (defined(__sparc64__) || defined(__sparcv9) || defined(__sparc_v9__))
# define LG_QUANTUM 4
# endif
# if (defined(__amd64__) || defined(__x86_64__) || defined(_M_X64))
# define LG_QUANTUM 4
# endif
# ifdef __arm__
# define LG_QUANTUM 3
# endif
# ifdef __aarch64__
# define LG_QUANTUM 4
# endif
# ifdef __hppa__
# define LG_QUANTUM 4
# endif
# ifdef __m68k__
# define LG_QUANTUM 3
# endif
# ifdef __mips__
# define LG_QUANTUM 3
# endif
# ifdef __nios2__
# define LG_QUANTUM 3
# endif
# ifdef __or1k__
# define LG_QUANTUM 3
# endif
# ifdef __powerpc__
# define LG_QUANTUM 4
# endif
# if defined(__riscv) || defined(__riscv__)
# define LG_QUANTUM 4
# endif
# ifdef __s390__
# define LG_QUANTUM 4
# endif
# if (defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || \
defined(__SH4_SINGLE_ONLY__))
# define LG_QUANTUM 4
# endif
# ifdef __tile__
# define LG_QUANTUM 4
# endif
# ifdef __le32__
# define LG_QUANTUM 4
# endif
# ifndef LG_QUANTUM
# error "Unknown minimum alignment for architecture; specify via "
"--with-lg-quantum"
# endif
#endif
#define QUANTUM ((size_t)(1U << LG_QUANTUM))
#define QUANTUM_MASK (QUANTUM - 1)
/* Return the smallest quantum multiple that is >= a. */
#define QUANTUM_CEILING(a) \
(((a) + QUANTUM_MASK) & ~QUANTUM_MASK)
#endif /* JEMALLOC_INTERNAL_QUANTUM_H */
+53 -17
View File
@@ -4,7 +4,7 @@
#include "jemalloc/internal/atomic.h"
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/rtree_tsd.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/tsd.h"
/*
@@ -31,7 +31,7 @@
# error Unsupported number of significant virtual address bits
#endif
/* Use compact leaf representation if virtual address encoding allows. */
#if RTREE_NHIB >= LG_CEIL_NSIZES
#if RTREE_NHIB >= LG_CEIL(SC_NSIZES)
# define RTREE_LEAF_COMPACT
#endif
@@ -170,8 +170,8 @@ rtree_subkey(uintptr_t key, unsigned level) {
*/
# ifdef RTREE_LEAF_COMPACT
JEMALLOC_ALWAYS_INLINE uintptr_t
rtree_leaf_elm_bits_read(tsdn_t *tsdn, rtree_t *rtree, rtree_leaf_elm_t *elm,
bool dependent) {
rtree_leaf_elm_bits_read(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, bool dependent) {
return (uintptr_t)atomic_load_p(&elm->le_bits, dependent
? ATOMIC_RELAXED : ATOMIC_ACQUIRE);
}
@@ -208,7 +208,7 @@ rtree_leaf_elm_bits_slab_get(uintptr_t bits) {
# endif
JEMALLOC_ALWAYS_INLINE extent_t *
rtree_leaf_elm_extent_read(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
rtree_leaf_elm_extent_read(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, bool dependent) {
#ifdef RTREE_LEAF_COMPACT
uintptr_t bits = rtree_leaf_elm_bits_read(tsdn, rtree, elm, dependent);
@@ -221,7 +221,7 @@ rtree_leaf_elm_extent_read(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
}
JEMALLOC_ALWAYS_INLINE szind_t
rtree_leaf_elm_szind_read(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
rtree_leaf_elm_szind_read(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, bool dependent) {
#ifdef RTREE_LEAF_COMPACT
uintptr_t bits = rtree_leaf_elm_bits_read(tsdn, rtree, elm, dependent);
@@ -233,7 +233,7 @@ rtree_leaf_elm_szind_read(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
}
JEMALLOC_ALWAYS_INLINE bool
rtree_leaf_elm_slab_read(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
rtree_leaf_elm_slab_read(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, bool dependent) {
#ifdef RTREE_LEAF_COMPACT
uintptr_t bits = rtree_leaf_elm_bits_read(tsdn, rtree, elm, dependent);
@@ -245,7 +245,7 @@ rtree_leaf_elm_slab_read(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
}
static inline void
rtree_leaf_elm_extent_write(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
rtree_leaf_elm_extent_write(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, extent_t *extent) {
#ifdef RTREE_LEAF_COMPACT
uintptr_t old_bits = rtree_leaf_elm_bits_read(tsdn, rtree, elm, true);
@@ -259,9 +259,9 @@ rtree_leaf_elm_extent_write(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
}
static inline void
rtree_leaf_elm_szind_write(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
rtree_leaf_elm_szind_write(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, szind_t szind) {
assert(szind <= NSIZES);
assert(szind <= SC_NSIZES);
#ifdef RTREE_LEAF_COMPACT
uintptr_t old_bits = rtree_leaf_elm_bits_read(tsdn, rtree, elm,
@@ -277,7 +277,7 @@ rtree_leaf_elm_szind_write(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
}
static inline void
rtree_leaf_elm_slab_write(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
rtree_leaf_elm_slab_write(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, bool slab) {
#ifdef RTREE_LEAF_COMPACT
uintptr_t old_bits = rtree_leaf_elm_bits_read(tsdn, rtree, elm,
@@ -292,8 +292,8 @@ rtree_leaf_elm_slab_write(UNUSED tsdn_t *tsdn, UNUSED rtree_t *rtree,
}
static inline void
rtree_leaf_elm_write(tsdn_t *tsdn, rtree_t *rtree, rtree_leaf_elm_t *elm,
extent_t *extent, szind_t szind, bool slab) {
rtree_leaf_elm_write(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, extent_t *extent, szind_t szind, bool slab) {
#ifdef RTREE_LEAF_COMPACT
uintptr_t bits = ((uintptr_t)szind << LG_VADDR) |
((uintptr_t)extent & (((uintptr_t)0x1 << LG_VADDR) - 1)) |
@@ -313,7 +313,7 @@ rtree_leaf_elm_write(tsdn_t *tsdn, rtree_t *rtree, rtree_leaf_elm_t *elm,
static inline void
rtree_leaf_elm_szind_slab_update(tsdn_t *tsdn, rtree_t *rtree,
rtree_leaf_elm_t *elm, szind_t szind, bool slab) {
assert(!slab || szind < NBINS);
assert(!slab || szind < SC_NBINS);
/*
* The caller implicitly assures that it is the only writer to the szind
@@ -429,7 +429,7 @@ rtree_szind_read(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
rtree_leaf_elm_t *elm = rtree_read(tsdn, rtree, rtree_ctx, key,
dependent);
if (!dependent && elm == NULL) {
return NSIZES;
return SC_NSIZES;
}
return rtree_leaf_elm_szind_read(tsdn, rtree, elm, dependent);
}
@@ -452,6 +452,42 @@ rtree_extent_szind_read(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
return false;
}
/*
* Try to read szind_slab from the L1 cache. Returns true on a hit,
* and fills in r_szind and r_slab. Otherwise returns false.
*
* Key is allowed to be NULL in order to save an extra branch on the
* fastpath. returns false in this case.
*/
JEMALLOC_ALWAYS_INLINE bool
rtree_szind_slab_read_fast(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
uintptr_t key, szind_t *r_szind, bool *r_slab) {
rtree_leaf_elm_t *elm;
size_t slot = rtree_cache_direct_map(key);
uintptr_t leafkey = rtree_leafkey(key);
assert(leafkey != RTREE_LEAFKEY_INVALID);
if (likely(rtree_ctx->cache[slot].leafkey == leafkey)) {
rtree_leaf_elm_t *leaf = rtree_ctx->cache[slot].leaf;
assert(leaf != NULL);
uintptr_t subkey = rtree_subkey(key, RTREE_HEIGHT-1);
elm = &leaf[subkey];
#ifdef RTREE_LEAF_COMPACT
uintptr_t bits = rtree_leaf_elm_bits_read(tsdn, rtree,
elm, true);
*r_szind = rtree_leaf_elm_bits_szind_get(bits);
*r_slab = rtree_leaf_elm_bits_slab_get(bits);
#else
*r_szind = rtree_leaf_elm_szind_read(tsdn, rtree, elm, true);
*r_slab = rtree_leaf_elm_slab_read(tsdn, rtree, elm, true);
#endif
return true;
} else {
return false;
}
}
JEMALLOC_ALWAYS_INLINE bool
rtree_szind_slab_read(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
uintptr_t key, bool dependent, szind_t *r_szind, bool *r_slab) {
@@ -474,7 +510,7 @@ rtree_szind_slab_read(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
static inline void
rtree_szind_slab_update(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
uintptr_t key, szind_t szind, bool slab) {
assert(!slab || szind < NBINS);
assert(!slab || szind < SC_NBINS);
rtree_leaf_elm_t *elm = rtree_read(tsdn, rtree, rtree_ctx, key, true);
rtree_leaf_elm_szind_slab_update(tsdn, rtree, elm, szind, slab);
@@ -486,7 +522,7 @@ rtree_clear(tsdn_t *tsdn, rtree_t *rtree, rtree_ctx_t *rtree_ctx,
rtree_leaf_elm_t *elm = rtree_read(tsdn, rtree, rtree_ctx, key, true);
assert(rtree_leaf_elm_extent_read(tsdn, rtree, elm, false) !=
NULL);
rtree_leaf_elm_write(tsdn, rtree, elm, NULL, NSIZES, false);
rtree_leaf_elm_write(tsdn, rtree, elm, NULL, SC_NSIZES, false);
}
#endif /* JEMALLOC_INTERNAL_RTREE_H */
+1 -1
View File
@@ -26,7 +26,7 @@
* Zero initializer required for tsd initialization only. Proper initialization
* done via rtree_ctx_data_init().
*/
#define RTREE_CTX_ZERO_INITIALIZER {{{0}}, {{0}}}
#define RTREE_CTX_ZERO_INITIALIZER {{{0, 0}}, {{0, 0}}}
typedef struct rtree_leaf_elm_s rtree_leaf_elm_t;
+26
View File
@@ -0,0 +1,26 @@
#ifndef JEMALLOC_INTERNAL_SAFETY_CHECK_H
#define JEMALLOC_INTERNAL_SAFETY_CHECK_H
void safety_check_fail(const char *format, ...);
/* Can set to NULL for a default. */
void safety_check_set_abort(void (*abort_fn)());
JEMALLOC_ALWAYS_INLINE void
safety_check_set_redzone(void *ptr, size_t usize, size_t bumped_usize) {
assert(usize < bumped_usize);
for (size_t i = usize; i < bumped_usize && i < usize + 32; ++i) {
*((unsigned char *)ptr + i) = 0xBC;
}
}
JEMALLOC_ALWAYS_INLINE void
safety_check_verify_redzone(const void *ptr, size_t usize, size_t bumped_usize)
{
for (size_t i = usize; i < bumped_usize && i < usize + 32; ++i) {
if (unlikely(*((unsigned char *)ptr + i) != 0xBC)) {
safety_check_fail("Use after free error\n");
}
}
}
#endif /*JEMALLOC_INTERNAL_SAFETY_CHECK_H */
+333
View File
@@ -0,0 +1,333 @@
#ifndef JEMALLOC_INTERNAL_SC_H
#define JEMALLOC_INTERNAL_SC_H
#include "jemalloc/internal/jemalloc_internal_types.h"
/*
* Size class computations:
*
* These are a little tricky; we'll first start by describing how things
* generally work, and then describe some of the details.
*
* Ignore the first few size classes for a moment. We can then split all the
* remaining size classes into groups. The size classes in a group are spaced
* such that they cover allocation request sizes in a power-of-2 range. The
* power of two is called the base of the group, and the size classes in it
* satisfy allocations in the half-open range (base, base * 2]. There are
* SC_NGROUP size classes in each group, equally spaced in the range, so that
* each one covers allocations for base / SC_NGROUP possible allocation sizes.
* We call that value (base / SC_NGROUP) the delta of the group. Each size class
* is delta larger than the one before it (including the initial size class in a
* group, which is delta larger than base, the largest size class in the
* previous group).
* To make the math all work out nicely, we require that SC_NGROUP is a power of
* two, and define it in terms of SC_LG_NGROUP. We'll often talk in terms of
* lg_base and lg_delta. For each of these groups then, we have that
* lg_delta == lg_base - SC_LG_NGROUP.
* The size classes in a group with a given lg_base and lg_delta (which, recall,
* can be computed from lg_base for these groups) are therefore:
* base + 1 * delta
* which covers allocations in (base, base + 1 * delta]
* base + 2 * delta
* which covers allocations in (base + 1 * delta, base + 2 * delta].
* base + 3 * delta
* which covers allocations in (base + 2 * delta, base + 3 * delta].
* ...
* base + SC_NGROUP * delta ( == 2 * base)
* which covers allocations in (base + (SC_NGROUP - 1) * delta, 2 * base].
* (Note that currently SC_NGROUP is always 4, so the "..." is empty in
* practice.)
* Note that the last size class in the group is the next power of two (after
* base), so that we've set up the induction correctly for the next group's
* selection of delta.
*
* Now, let's start considering the first few size classes. Two extra constants
* come into play here: LG_QUANTUM and SC_LG_TINY_MIN. LG_QUANTUM ensures
* correct platform alignment; all objects of size (1 << LG_QUANTUM) or larger
* are at least (1 << LG_QUANTUM) aligned; this can be used to ensure that we
* never return improperly aligned memory, by making (1 << LG_QUANTUM) equal the
* highest required alignment of a platform. For allocation sizes smaller than
* (1 << LG_QUANTUM) though, we can be more relaxed (since we don't support
* platforms with types with alignment larger than their size). To allow such
* allocations (without wasting space unnecessarily), we introduce tiny size
* classes; one per power of two, up until we hit the quantum size. There are
* therefore LG_QUANTUM - SC_LG_TINY_MIN such size classes.
*
* Next, we have a size class of size (1 << LG_QUANTUM). This can't be the
* start of a group in the sense we described above (covering a power of two
* range) since, if we divided into it to pick a value of delta, we'd get a
* delta smaller than (1 << LG_QUANTUM) for sizes >= (1 << LG_QUANTUM), which
* is against the rules.
*
* The first base we can divide by SC_NGROUP while still being at least
* (1 << LG_QUANTUM) is SC_NGROUP * (1 << LG_QUANTUM). We can get there by
* having SC_NGROUP size classes, spaced (1 << LG_QUANTUM) apart. These size
* classes are:
* 1 * (1 << LG_QUANTUM)
* 2 * (1 << LG_QUANTUM)
* 3 * (1 << LG_QUANTUM)
* ... (although, as above, this "..." is empty in practice)
* SC_NGROUP * (1 << LG_QUANTUM).
*
* There are SC_NGROUP of these size classes, so we can regard it as a sort of
* pseudo-group, even though it spans multiple powers of 2, is divided
* differently, and both starts and ends on a power of 2 (as opposed to just
* ending). SC_NGROUP is itself a power of two, so the first group after the
* pseudo-group has the power-of-two base SC_NGROUP * (1 << LG_QUANTUM), for a
* lg_base of LG_QUANTUM + SC_LG_NGROUP. We can divide this base into SC_NGROUP
* sizes without violating our LG_QUANTUM requirements, so we can safely set
* lg_delta = lg_base - SC_LG_GROUP (== LG_QUANTUM).
*
* So, in order, the size classes are:
*
* Tiny size classes:
* - Count: LG_QUANTUM - SC_LG_TINY_MIN.
* - Sizes:
* 1 << SC_LG_TINY_MIN
* 1 << (SC_LG_TINY_MIN + 1)
* 1 << (SC_LG_TINY_MIN + 2)
* ...
* 1 << (LG_QUANTUM - 1)
*
* Initial pseudo-group:
* - Count: SC_NGROUP
* - Sizes:
* 1 * (1 << LG_QUANTUM)
* 2 * (1 << LG_QUANTUM)
* 3 * (1 << LG_QUANTUM)
* ...
* SC_NGROUP * (1 << LG_QUANTUM)
*
* Regular group 0:
* - Count: SC_NGROUP
* - Sizes:
* (relative to lg_base of LG_QUANTUM + SC_LG_NGROUP and lg_delta of
* lg_base - SC_LG_NGROUP)
* (1 << lg_base) + 1 * (1 << lg_delta)
* (1 << lg_base) + 2 * (1 << lg_delta)
* (1 << lg_base) + 3 * (1 << lg_delta)
* ...
* (1 << lg_base) + SC_NGROUP * (1 << lg_delta) [ == (1 << (lg_base + 1)) ]
*
* Regular group 1:
* - Count: SC_NGROUP
* - Sizes:
* (relative to lg_base of LG_QUANTUM + SC_LG_NGROUP + 1 and lg_delta of
* lg_base - SC_LG_NGROUP)
* (1 << lg_base) + 1 * (1 << lg_delta)
* (1 << lg_base) + 2 * (1 << lg_delta)
* (1 << lg_base) + 3 * (1 << lg_delta)
* ...
* (1 << lg_base) + SC_NGROUP * (1 << lg_delta) [ == (1 << (lg_base + 1)) ]
*
* ...
*
* Regular group N:
* - Count: SC_NGROUP
* - Sizes:
* (relative to lg_base of LG_QUANTUM + SC_LG_NGROUP + N and lg_delta of
* lg_base - SC_LG_NGROUP)
* (1 << lg_base) + 1 * (1 << lg_delta)
* (1 << lg_base) + 2 * (1 << lg_delta)
* (1 << lg_base) + 3 * (1 << lg_delta)
* ...
* (1 << lg_base) + SC_NGROUP * (1 << lg_delta) [ == (1 << (lg_base + 1)) ]
*
*
* Representation of metadata:
* To make the math easy, we'll mostly work in lg quantities. We record lg_base,
* lg_delta, and ndelta (i.e. number of deltas above the base) on a
* per-size-class basis, and maintain the invariant that, across all size
* classes, size == (1 << lg_base) + ndelta * (1 << lg_delta).
*
* For regular groups (i.e. those with lg_base >= LG_QUANTUM + SC_LG_NGROUP),
* lg_delta is lg_base - SC_LG_NGROUP, and ndelta goes from 1 to SC_NGROUP.
*
* For the initial tiny size classes (if any), lg_base is lg(size class size).
* lg_delta is lg_base for the first size class, and lg_base - 1 for all
* subsequent ones. ndelta is always 0.
*
* For the pseudo-group, if there are no tiny size classes, then we set
* lg_base == LG_QUANTUM, lg_delta == LG_QUANTUM, and have ndelta range from 0
* to SC_NGROUP - 1. (Note that delta == base, so base + (SC_NGROUP - 1) * delta
* is just SC_NGROUP * base, or (1 << (SC_LG_NGROUP + LG_QUANTUM)), so we do
* indeed get a power of two that way). If there *are* tiny size classes, then
* the first size class needs to have lg_delta relative to the largest tiny size
* class. We therefore set lg_base == LG_QUANTUM - 1,
* lg_delta == LG_QUANTUM - 1, and ndelta == 1, keeping the rest of the
* pseudo-group the same.
*
*
* Other terminology:
* "Small" size classes mean those that are allocated out of bins, which is the
* same as those that are slab allocated.
* "Large" size classes are those that are not small. The cutoff for counting as
* large is page size * group size.
*/
/*
* Size class N + (1 << SC_LG_NGROUP) twice the size of size class N.
*/
#define SC_LG_NGROUP 2
#define SC_LG_TINY_MIN 3
#if SC_LG_TINY_MIN == 0
/* The div module doesn't support division by 1, which this would require. */
#error "Unsupported LG_TINY_MIN"
#endif
/*
* The definitions below are all determined by the above settings and system
* characteristics.
*/
#define SC_NGROUP (1ULL << SC_LG_NGROUP)
#define SC_PTR_BITS ((1ULL << LG_SIZEOF_PTR) * 8)
#define SC_NTINY (LG_QUANTUM - SC_LG_TINY_MIN)
#define SC_LG_TINY_MAXCLASS (LG_QUANTUM > SC_LG_TINY_MIN ? LG_QUANTUM - 1 : -1)
#define SC_NPSEUDO SC_NGROUP
#define SC_LG_FIRST_REGULAR_BASE (LG_QUANTUM + SC_LG_NGROUP)
/*
* We cap allocations to be less than 2 ** (ptr_bits - 1), so the highest base
* we need is 2 ** (ptr_bits - 2). (This also means that the last group is 1
* size class shorter than the others).
* We could probably save some space in arenas by capping this at LG_VADDR size.
*/
#define SC_LG_BASE_MAX (SC_PTR_BITS - 2)
#define SC_NREGULAR (SC_NGROUP * \
(SC_LG_BASE_MAX - SC_LG_FIRST_REGULAR_BASE + 1) - 1)
#define SC_NSIZES (SC_NTINY + SC_NPSEUDO + SC_NREGULAR)
/* The number of size classes that are a multiple of the page size. */
#define SC_NPSIZES ( \
/* Start with all the size classes. */ \
SC_NSIZES \
/* Subtract out those groups with too small a base. */ \
- (LG_PAGE - 1 - SC_LG_FIRST_REGULAR_BASE) * SC_NGROUP \
/* And the pseudo-group. */ \
- SC_NPSEUDO \
/* And the tiny group. */ \
- SC_NTINY \
/* Sizes where ndelta*delta is not a multiple of the page size. */ \
- (SC_LG_NGROUP * SC_NGROUP))
/*
* Note that the last line is computed as the sum of the second column in the
* following table:
* lg(base) | count of sizes to exclude
* ------------------------------|-----------------------------
* LG_PAGE - 1 | SC_NGROUP - 1
* LG_PAGE | SC_NGROUP - 1
* LG_PAGE + 1 | SC_NGROUP - 2
* LG_PAGE + 2 | SC_NGROUP - 4
* ... | ...
* LG_PAGE + (SC_LG_NGROUP - 1) | SC_NGROUP - (SC_NGROUP / 2)
*/
/*
* We declare a size class is binnable if size < page size * group. Or, in other
* words, lg(size) < lg(page size) + lg(group size).
*/
#define SC_NBINS ( \
/* Sub-regular size classes. */ \
SC_NTINY + SC_NPSEUDO \
/* Groups with lg_regular_min_base <= lg_base <= lg_base_max */ \
+ SC_NGROUP * (LG_PAGE + SC_LG_NGROUP - SC_LG_FIRST_REGULAR_BASE) \
/* Last SC of the last group hits the bound exactly; exclude it. */ \
- 1)
/*
* The size2index_tab lookup table uses uint8_t to encode each bin index, so we
* cannot support more than 256 small size classes.
*/
#if (SC_NBINS > 256)
# error "Too many small size classes"
#endif
/* The largest size class in the lookup table. */
#define SC_LOOKUP_MAXCLASS ((size_t)1 << 12)
/* Internal, only used for the definition of SC_SMALL_MAXCLASS. */
#define SC_SMALL_MAX_BASE ((size_t)1 << (LG_PAGE + SC_LG_NGROUP - 1))
#define SC_SMALL_MAX_DELTA ((size_t)1 << (LG_PAGE - 1))
/* The largest size class allocated out of a slab. */
#define SC_SMALL_MAXCLASS (SC_SMALL_MAX_BASE \
+ (SC_NGROUP - 1) * SC_SMALL_MAX_DELTA)
/* The smallest size class not allocated out of a slab. */
#define SC_LARGE_MINCLASS ((size_t)1ULL << (LG_PAGE + SC_LG_NGROUP))
#define SC_LG_LARGE_MINCLASS (LG_PAGE + SC_LG_NGROUP)
/* Internal; only used for the definition of SC_LARGE_MAXCLASS. */
#define SC_MAX_BASE ((size_t)1 << (SC_PTR_BITS - 2))
#define SC_MAX_DELTA ((size_t)1 << (SC_PTR_BITS - 2 - SC_LG_NGROUP))
/* The largest size class supported. */
#define SC_LARGE_MAXCLASS (SC_MAX_BASE + (SC_NGROUP - 1) * SC_MAX_DELTA)
typedef struct sc_s sc_t;
struct sc_s {
/* Size class index, or -1 if not a valid size class. */
int index;
/* Lg group base size (no deltas added). */
int lg_base;
/* Lg delta to previous size class. */
int lg_delta;
/* Delta multiplier. size == 1<<lg_base + ndelta<<lg_delta */
int ndelta;
/*
* True if the size class is a multiple of the page size, false
* otherwise.
*/
bool psz;
/*
* True if the size class is a small, bin, size class. False otherwise.
*/
bool bin;
/* The slab page count if a small bin size class, 0 otherwise. */
int pgs;
/* Same as lg_delta if a lookup table size class, 0 otherwise. */
int lg_delta_lookup;
};
typedef struct sc_data_s sc_data_t;
struct sc_data_s {
/* Number of tiny size classes. */
unsigned ntiny;
/* Number of bins supported by the lookup table. */
int nlbins;
/* Number of small size class bins. */
int nbins;
/* Number of size classes. */
int nsizes;
/* Number of bits required to store NSIZES. */
int lg_ceil_nsizes;
/* Number of size classes that are a multiple of (1U << LG_PAGE). */
unsigned npsizes;
/* Lg of maximum tiny size class (or -1, if none). */
int lg_tiny_maxclass;
/* Maximum size class included in lookup table. */
size_t lookup_maxclass;
/* Maximum small size class. */
size_t small_maxclass;
/* Lg of minimum large size class. */
int lg_large_minclass;
/* The minimum large size class. */
size_t large_minclass;
/* Maximum (large) size class. */
size_t large_maxclass;
/* True if the sc_data_t has been initialized (for debugging only). */
bool initialized;
sc_t sc[SC_NSIZES];
};
void sc_data_init(sc_data_t *data);
/*
* Updates slab sizes in [begin, end] to be pgs pages in length, if possible.
* Otherwise, does its best to accomodate the request.
*/
void sc_data_update_slab_size(sc_data_t *data, size_t begin, size_t end,
int pgs);
void sc_boot(sc_data_t *data);
#endif /* JEMALLOC_INTERNAL_SC_H */
+55
View File
@@ -0,0 +1,55 @@
#ifndef JEMALLOC_INTERNAL_SEQ_H
#define JEMALLOC_INTERNAL_SEQ_H
#include "jemalloc/internal/atomic.h"
/*
* A simple seqlock implementation.
*/
#define seq_define(type, short_type) \
typedef struct { \
atomic_zu_t seq; \
atomic_zu_t data[ \
(sizeof(type) + sizeof(size_t) - 1) / sizeof(size_t)]; \
} seq_##short_type##_t; \
\
/* \
* No internal synchronization -- the caller must ensure that there's \
* only a single writer at a time. \
*/ \
static inline void \
seq_store_##short_type(seq_##short_type##_t *dst, type *src) { \
size_t buf[sizeof(dst->data) / sizeof(size_t)]; \
buf[sizeof(buf) / sizeof(size_t) - 1] = 0; \
memcpy(buf, src, sizeof(type)); \
size_t old_seq = atomic_load_zu(&dst->seq, ATOMIC_RELAXED); \
atomic_store_zu(&dst->seq, old_seq + 1, ATOMIC_RELAXED); \
atomic_fence(ATOMIC_RELEASE); \
for (size_t i = 0; i < sizeof(buf) / sizeof(size_t); i++) { \
atomic_store_zu(&dst->data[i], buf[i], ATOMIC_RELAXED); \
} \
atomic_store_zu(&dst->seq, old_seq + 2, ATOMIC_RELEASE); \
} \
\
/* Returns whether or not the read was consistent. */ \
static inline bool \
seq_try_load_##short_type(type *dst, seq_##short_type##_t *src) { \
size_t buf[sizeof(src->data) / sizeof(size_t)]; \
size_t seq1 = atomic_load_zu(&src->seq, ATOMIC_ACQUIRE); \
if (seq1 % 2 != 0) { \
return false; \
} \
for (size_t i = 0; i < sizeof(buf) / sizeof(size_t); i++) { \
buf[i] = atomic_load_zu(&src->data[i], ATOMIC_RELAXED); \
} \
atomic_fence(ATOMIC_ACQUIRE); \
size_t seq2 = atomic_load_zu(&src->seq, ATOMIC_RELAXED); \
if (seq1 != seq2) { \
return false; \
} \
memcpy(dst, buf, sizeof(type)); \
return true; \
}
#endif /* JEMALLOC_INTERNAL_SEQ_H */
+2 -1
View File
@@ -10,7 +10,8 @@
OPTION('a', unmerged, config_stats, false) \
OPTION('b', bins, true, false) \
OPTION('l', large, true, false) \
OPTION('x', mutex, true, false)
OPTION('x', mutex, true, false) \
OPTION('e', extents, true, false)
enum {
#define OPTION(o, v, d, s) stats_print_option_num_##v,
+87 -86
View File
@@ -3,7 +3,7 @@
#include "jemalloc/internal/bit_util.h"
#include "jemalloc/internal/pages.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/util.h"
/*
@@ -26,18 +26,18 @@
* sz_pind2sz_tab encodes the same information as could be computed by
* sz_pind2sz_compute().
*/
extern size_t const sz_pind2sz_tab[NPSIZES+1];
extern size_t sz_pind2sz_tab[SC_NPSIZES + 1];
/*
* sz_index2size_tab encodes the same information as could be computed (at
* unacceptable cost in some code paths) by sz_index2size_compute().
*/
extern size_t const sz_index2size_tab[NSIZES];
extern size_t sz_index2size_tab[SC_NSIZES];
/*
* sz_size2index_tab is a compact lookup table that rounds request sizes up to
* size classes. In order to reduce cache footprint, the table is compressed,
* and all accesses are via sz_size2index().
*/
extern uint8_t const sz_size2index_tab[];
extern uint8_t sz_size2index_tab[];
static const size_t sz_large_pad =
#ifdef JEMALLOC_CACHE_OBLIVIOUS
@@ -47,49 +47,47 @@ static const size_t sz_large_pad =
#endif
;
extern void sz_boot(const sc_data_t *sc_data);
JEMALLOC_ALWAYS_INLINE pszind_t
sz_psz2ind(size_t psz) {
if (unlikely(psz > LARGE_MAXCLASS)) {
return NPSIZES;
if (unlikely(psz > SC_LARGE_MAXCLASS)) {
return SC_NPSIZES;
}
{
pszind_t x = lg_floor((psz<<1)-1);
pszind_t shift = (x < LG_SIZE_CLASS_GROUP + LG_PAGE) ? 0 : x -
(LG_SIZE_CLASS_GROUP + LG_PAGE);
pszind_t grp = shift << LG_SIZE_CLASS_GROUP;
pszind_t x = lg_floor((psz<<1)-1);
pszind_t shift = (x < SC_LG_NGROUP + LG_PAGE) ?
0 : x - (SC_LG_NGROUP + LG_PAGE);
pszind_t grp = shift << SC_LG_NGROUP;
pszind_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_PAGE + 1) ?
LG_PAGE : x - LG_SIZE_CLASS_GROUP - 1;
pszind_t lg_delta = (x < SC_LG_NGROUP + LG_PAGE + 1) ?
LG_PAGE : x - SC_LG_NGROUP - 1;
size_t delta_inverse_mask = ZU(-1) << lg_delta;
pszind_t mod = ((((psz-1) & delta_inverse_mask) >> lg_delta)) &
((ZU(1) << LG_SIZE_CLASS_GROUP) - 1);
size_t delta_inverse_mask = ZU(-1) << lg_delta;
pszind_t mod = ((((psz-1) & delta_inverse_mask) >> lg_delta)) &
((ZU(1) << SC_LG_NGROUP) - 1);
pszind_t ind = grp + mod;
return ind;
}
pszind_t ind = grp + mod;
return ind;
}
static inline size_t
sz_pind2sz_compute(pszind_t pind) {
if (unlikely(pind == NPSIZES)) {
return LARGE_MAXCLASS + PAGE;
if (unlikely(pind == SC_NPSIZES)) {
return SC_LARGE_MAXCLASS + PAGE;
}
{
size_t grp = pind >> LG_SIZE_CLASS_GROUP;
size_t mod = pind & ((ZU(1) << LG_SIZE_CLASS_GROUP) - 1);
size_t grp = pind >> SC_LG_NGROUP;
size_t mod = pind & ((ZU(1) << SC_LG_NGROUP) - 1);
size_t grp_size_mask = ~((!!grp)-1);
size_t grp_size = ((ZU(1) << (LG_PAGE +
(LG_SIZE_CLASS_GROUP-1))) << grp) & grp_size_mask;
size_t grp_size_mask = ~((!!grp)-1);
size_t grp_size = ((ZU(1) << (LG_PAGE + (SC_LG_NGROUP-1))) << grp)
& grp_size_mask;
size_t shift = (grp == 0) ? 1 : grp;
size_t lg_delta = shift + (LG_PAGE-1);
size_t mod_size = (mod+1) << lg_delta;
size_t shift = (grp == 0) ? 1 : grp;
size_t lg_delta = shift + (LG_PAGE-1);
size_t mod_size = (mod+1) << lg_delta;
size_t sz = grp_size + mod_size;
return sz;
}
size_t sz = grp_size + mod_size;
return sz;
}
static inline size_t
@@ -101,70 +99,70 @@ sz_pind2sz_lookup(pszind_t pind) {
static inline size_t
sz_pind2sz(pszind_t pind) {
assert(pind < NPSIZES+1);
assert(pind < SC_NPSIZES + 1);
return sz_pind2sz_lookup(pind);
}
static inline size_t
sz_psz2u(size_t psz) {
if (unlikely(psz > LARGE_MAXCLASS)) {
return LARGE_MAXCLASS + PAGE;
}
{
size_t x = lg_floor((psz<<1)-1);
size_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_PAGE + 1) ?
LG_PAGE : x - LG_SIZE_CLASS_GROUP - 1;
size_t delta = ZU(1) << lg_delta;
size_t delta_mask = delta - 1;
size_t usize = (psz + delta_mask) & ~delta_mask;
return usize;
if (unlikely(psz > SC_LARGE_MAXCLASS)) {
return SC_LARGE_MAXCLASS + PAGE;
}
size_t x = lg_floor((psz<<1)-1);
size_t lg_delta = (x < SC_LG_NGROUP + LG_PAGE + 1) ?
LG_PAGE : x - SC_LG_NGROUP - 1;
size_t delta = ZU(1) << lg_delta;
size_t delta_mask = delta - 1;
size_t usize = (psz + delta_mask) & ~delta_mask;
return usize;
}
static inline szind_t
sz_size2index_compute(size_t size) {
if (unlikely(size > LARGE_MAXCLASS)) {
return NSIZES;
if (unlikely(size > SC_LARGE_MAXCLASS)) {
return SC_NSIZES;
}
#if (NTBINS != 0)
if (size <= (ZU(1) << LG_TINY_MAXCLASS)) {
szind_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1;
if (size == 0) {
return 0;
}
#if (SC_NTINY != 0)
if (size <= (ZU(1) << SC_LG_TINY_MAXCLASS)) {
szind_t lg_tmin = SC_LG_TINY_MAXCLASS - SC_NTINY + 1;
szind_t lg_ceil = lg_floor(pow2_ceil_zu(size));
return (lg_ceil < lg_tmin ? 0 : lg_ceil - lg_tmin);
}
#endif
{
szind_t x = lg_floor((size<<1)-1);
szind_t shift = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM) ? 0 :
x - (LG_SIZE_CLASS_GROUP + LG_QUANTUM);
szind_t grp = shift << LG_SIZE_CLASS_GROUP;
szind_t shift = (x < SC_LG_NGROUP + LG_QUANTUM) ? 0 :
x - (SC_LG_NGROUP + LG_QUANTUM);
szind_t grp = shift << SC_LG_NGROUP;
szind_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM + 1)
? LG_QUANTUM : x - LG_SIZE_CLASS_GROUP - 1;
szind_t lg_delta = (x < SC_LG_NGROUP + LG_QUANTUM + 1)
? LG_QUANTUM : x - SC_LG_NGROUP - 1;
size_t delta_inverse_mask = ZU(-1) << lg_delta;
szind_t mod = ((((size-1) & delta_inverse_mask) >> lg_delta)) &
((ZU(1) << LG_SIZE_CLASS_GROUP) - 1);
((ZU(1) << SC_LG_NGROUP) - 1);
szind_t index = NTBINS + grp + mod;
szind_t index = SC_NTINY + grp + mod;
return index;
}
}
JEMALLOC_ALWAYS_INLINE szind_t
sz_size2index_lookup(size_t size) {
assert(size <= LOOKUP_MAXCLASS);
{
szind_t ret = (sz_size2index_tab[(size-1) >> LG_TINY_MIN]);
assert(ret == sz_size2index_compute(size));
return ret;
}
assert(size <= SC_LOOKUP_MAXCLASS);
szind_t ret = (sz_size2index_tab[(size + (ZU(1) << SC_LG_TINY_MIN) - 1)
>> SC_LG_TINY_MIN]);
assert(ret == sz_size2index_compute(size));
return ret;
}
JEMALLOC_ALWAYS_INLINE szind_t
sz_size2index(size_t size) {
assert(size > 0);
if (likely(size <= LOOKUP_MAXCLASS)) {
if (likely(size <= SC_LOOKUP_MAXCLASS)) {
return sz_size2index_lookup(size);
}
return sz_size2index_compute(size);
@@ -172,20 +170,20 @@ sz_size2index(size_t size) {
static inline size_t
sz_index2size_compute(szind_t index) {
#if (NTBINS > 0)
if (index < NTBINS) {
return (ZU(1) << (LG_TINY_MAXCLASS - NTBINS + 1 + index));
#if (SC_NTINY > 0)
if (index < SC_NTINY) {
return (ZU(1) << (SC_LG_TINY_MAXCLASS - SC_NTINY + 1 + index));
}
#endif
{
size_t reduced_index = index - NTBINS;
size_t grp = reduced_index >> LG_SIZE_CLASS_GROUP;
size_t mod = reduced_index & ((ZU(1) << LG_SIZE_CLASS_GROUP) -
size_t reduced_index = index - SC_NTINY;
size_t grp = reduced_index >> SC_LG_NGROUP;
size_t mod = reduced_index & ((ZU(1) << SC_LG_NGROUP) -
1);
size_t grp_size_mask = ~((!!grp)-1);
size_t grp_size = ((ZU(1) << (LG_QUANTUM +
(LG_SIZE_CLASS_GROUP-1))) << grp) & grp_size_mask;
(SC_LG_NGROUP-1))) << grp) & grp_size_mask;
size_t shift = (grp == 0) ? 1 : grp;
size_t lg_delta = shift + (LG_QUANTUM-1);
@@ -205,18 +203,22 @@ sz_index2size_lookup(szind_t index) {
JEMALLOC_ALWAYS_INLINE size_t
sz_index2size(szind_t index) {
assert(index < NSIZES);
assert(index < SC_NSIZES);
return sz_index2size_lookup(index);
}
JEMALLOC_ALWAYS_INLINE size_t
sz_s2u_compute(size_t size) {
if (unlikely(size > LARGE_MAXCLASS)) {
if (unlikely(size > SC_LARGE_MAXCLASS)) {
return 0;
}
#if (NTBINS > 0)
if (size <= (ZU(1) << LG_TINY_MAXCLASS)) {
size_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1;
if (size == 0) {
size++;
}
#if (SC_NTINY > 0)
if (size <= (ZU(1) << SC_LG_TINY_MAXCLASS)) {
size_t lg_tmin = SC_LG_TINY_MAXCLASS - SC_NTINY + 1;
size_t lg_ceil = lg_floor(pow2_ceil_zu(size));
return (lg_ceil < lg_tmin ? (ZU(1) << lg_tmin) :
(ZU(1) << lg_ceil));
@@ -224,8 +226,8 @@ sz_s2u_compute(size_t size) {
#endif
{
size_t x = lg_floor((size<<1)-1);
size_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM + 1)
? LG_QUANTUM : x - LG_SIZE_CLASS_GROUP - 1;
size_t lg_delta = (x < SC_LG_NGROUP + LG_QUANTUM + 1)
? LG_QUANTUM : x - SC_LG_NGROUP - 1;
size_t delta = ZU(1) << lg_delta;
size_t delta_mask = delta - 1;
size_t usize = (size + delta_mask) & ~delta_mask;
@@ -247,8 +249,7 @@ sz_s2u_lookup(size_t size) {
*/
JEMALLOC_ALWAYS_INLINE size_t
sz_s2u(size_t size) {
assert(size > 0);
if (likely(size <= LOOKUP_MAXCLASS)) {
if (likely(size <= SC_LOOKUP_MAXCLASS)) {
return sz_s2u_lookup(size);
}
return sz_s2u_compute(size);
@@ -265,7 +266,7 @@ sz_sa2u(size_t size, size_t alignment) {
assert(alignment != 0 && ((alignment - 1) & alignment) == 0);
/* Try for a small size class. */
if (size <= SMALL_MAXCLASS && alignment < PAGE) {
if (size <= SC_SMALL_MAXCLASS && alignment < PAGE) {
/*
* Round size up to the nearest multiple of alignment.
*
@@ -281,20 +282,20 @@ sz_sa2u(size_t size, size_t alignment) {
* 192 | 11000000 | 64
*/
usize = sz_s2u(ALIGNMENT_CEILING(size, alignment));
if (usize < LARGE_MINCLASS) {
if (usize < SC_LARGE_MINCLASS) {
return usize;
}
}
/* Large size class. Beware of overflow. */
if (unlikely(alignment > LARGE_MAXCLASS)) {
if (unlikely(alignment > SC_LARGE_MAXCLASS)) {
return 0;
}
/* Make sure result is a large size class. */
if (size <= LARGE_MINCLASS) {
usize = LARGE_MINCLASS;
if (size <= SC_LARGE_MINCLASS) {
usize = SC_LARGE_MINCLASS;
} else {
usize = sz_s2u(size);
if (usize < size) {
+1 -3
View File
@@ -1,15 +1,13 @@
#ifndef JEMALLOC_INTERNAL_TCACHE_EXTERNS_H
#define JEMALLOC_INTERNAL_TCACHE_EXTERNS_H
#include "jemalloc/internal/size_classes.h"
extern bool opt_tcache;
extern ssize_t opt_lg_tcache_max;
extern cache_bin_info_t *tcache_bin_info;
/*
* Number of tcache bins. There are NBINS small-object bins, plus 0 or more
* Number of tcache bins. There are SC_NBINS small-object bins, plus 0 or more
* large-object bins.
*/
extern unsigned nhbins;
+14 -10
View File
@@ -3,7 +3,7 @@
#include "jemalloc/internal/bin.h"
#include "jemalloc/internal/jemalloc_internal_types.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/sz.h"
#include "jemalloc/internal/ticker.h"
#include "jemalloc/internal/util.h"
@@ -40,13 +40,13 @@ tcache_event(tsd_t *tsd, tcache_t *tcache) {
JEMALLOC_ALWAYS_INLINE void *
tcache_alloc_small(tsd_t *tsd, arena_t *arena, tcache_t *tcache,
UNUSED size_t size, szind_t binind, bool zero, bool slow_path) {
size_t size, szind_t binind, bool zero, bool slow_path) {
void *ret;
cache_bin_t *bin;
bool tcache_success;
size_t usize JEMALLOC_CC_SILENCE_INIT(0);
assert(binind < NBINS);
assert(binind < SC_NBINS);
bin = tcache_small_bin_get(tcache, binind);
ret = cache_bin_alloc_easy(bin, &tcache_success);
assert(tcache_success == (ret != NULL));
@@ -107,7 +107,7 @@ tcache_alloc_large(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size,
cache_bin_t *bin;
bool tcache_success;
assert(binind >= NBINS &&binind < nhbins);
assert(binind >= SC_NBINS &&binind < nhbins);
bin = tcache_large_bin_get(tcache, binind);
ret = cache_bin_alloc_easy(bin, &tcache_success);
assert(tcache_success == (ret != NULL));
@@ -166,7 +166,8 @@ tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
cache_bin_t *bin;
cache_bin_info_t *bin_info;
assert(tcache_salloc(tsd_tsdn(tsd), ptr) <= SMALL_MAXCLASS);
assert(tcache_salloc(tsd_tsdn(tsd), ptr)
<= SC_SMALL_MAXCLASS);
if (slow_path && config_fill && unlikely(opt_junk_free)) {
arena_dalloc_junk_small(ptr, &bin_infos[binind]);
@@ -174,13 +175,12 @@ tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
bin = tcache_small_bin_get(tcache, binind);
bin_info = &tcache_bin_info[binind];
if (unlikely(bin->ncached == bin_info->ncached_max)) {
if (unlikely(!cache_bin_dalloc_easy(bin, bin_info, ptr))) {
tcache_bin_flush_small(tsd, tcache, bin, binind,
(bin_info->ncached_max >> 1));
bool ret = cache_bin_dalloc_easy(bin, bin_info, ptr);
assert(ret);
}
assert(bin->ncached < bin_info->ncached_max);
bin->ncached++;
*(bin->avail - bin->ncached) = ptr;
tcache_event(tsd, tcache);
}
@@ -191,7 +191,8 @@ tcache_dalloc_large(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
cache_bin_t *bin;
cache_bin_info_t *bin_info;
assert(tcache_salloc(tsd_tsdn(tsd), ptr) > SMALL_MAXCLASS);
assert(tcache_salloc(tsd_tsdn(tsd), ptr)
> SC_SMALL_MAXCLASS);
assert(tcache_salloc(tsd_tsdn(tsd), ptr) <= tcache_maxclass);
if (slow_path && config_fill && unlikely(opt_junk_free)) {
@@ -215,6 +216,9 @@ JEMALLOC_ALWAYS_INLINE tcache_t *
tcaches_get(tsd_t *tsd, unsigned ind) {
tcaches_t *elm = &tcaches[ind];
if (unlikely(elm->tcache == NULL)) {
malloc_printf("<jemalloc>: invalid tcache id (%u).\n", ind);
abort();
} else if (unlikely(elm->tcache == TCACHES_ELM_NEED_REINIT)) {
elm->tcache = tcache_create_explicit(tsd);
}
return elm->tcache;
+14 -5
View File
@@ -1,10 +1,14 @@
#ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
#define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
#include "jemalloc/internal/ql.h"
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/cache_bin.h"
#include "jemalloc/internal/ql.h"
#include "jemalloc/internal/sc.h"
#include "jemalloc/internal/ticker.h"
#include "jemalloc/internal/tsd_types.h"
/* Various uses of this struct need it to be a named type. */
typedef ql_elm(tsd_t) tsd_link_t;
struct tcache_s {
/*
@@ -21,7 +25,7 @@ struct tcache_s {
* During tcache initialization, the avail pointer in each element of
* tbins is initialized to point to the proper offset within this array.
*/
cache_bin_t bins_small[NBINS];
cache_bin_t bins_small[SC_NBINS];
/*
* This data is less hot; we can be a little less careful with our
@@ -29,6 +33,11 @@ struct tcache_s {
*/
/* Lets us track all the tcaches in an arena. */
ql_elm(tcache_t) link;
/* Logically scoped to tsd, but put here for cache layout reasons. */
ql_elm(tsd_t) tsd_link;
bool in_hook;
/*
* The descriptor lets the arena find our cache bins without seeing the
* tcache definition. This enables arenas to aggregate stats across
@@ -41,13 +50,13 @@ struct tcache_s {
/* Next bin to GC. */
szind_t next_gc_bin;
/* For small bins, fill (ncached_max >> lg_fill_div). */
uint8_t lg_fill_div[NBINS];
uint8_t lg_fill_div[SC_NBINS];
/*
* We put the cache bins for large size classes at the end of the
* struct, since some of them might not get used. This might end up
* letting us avoid touching an extra page if we don't have to.
*/
cache_bin_t bins_large[NSIZES-NBINS];
cache_bin_t bins_large[SC_NSIZES-SC_NBINS];
};
/* Linkage for list of available (previously used) explicit tcache IDs. */
+5 -2
View File
@@ -1,7 +1,7 @@
#ifndef JEMALLOC_INTERNAL_TCACHE_TYPES_H
#define JEMALLOC_INTERNAL_TCACHE_TYPES_H
#include "jemalloc/internal/size_classes.h"
#include "jemalloc/internal/sc.h"
typedef struct tcache_s tcache_t;
typedef struct tcaches_s tcaches_t;
@@ -45,7 +45,7 @@ typedef struct tcaches_s tcaches_t;
/* Number of tcache allocation/deallocation events between incremental GCs. */
#define TCACHE_GC_INCR \
((TCACHE_GC_SWEEP / NBINS) + ((TCACHE_GC_SWEEP / NBINS == 0) ? 0 : 1))
((TCACHE_GC_SWEEP / SC_NBINS) + ((TCACHE_GC_SWEEP / SC_NBINS == 0) ? 0 : 1))
/* Used in TSD static initializer only. Real init in tcache_data_init(). */
#define TCACHE_ZERO_INITIALIZER {0}
@@ -53,4 +53,7 @@ typedef struct tcaches_s tcaches_t;
/* Used in TSD static initializer only. Will be initialized to opt_tcache. */
#define TCACHE_ENABLED_ZERO_INITIALIZER false
/* Used for explicit tcache only. Means flushed but not destroyed. */
#define TCACHES_ELM_NEED_REINIT ((tcache_t *)(uintptr_t)1)
#endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef JEMALLOC_INTERNAL_TEST_HOOKS_H
#define JEMALLOC_INTERNAL_TEST_HOOKS_H
extern JEMALLOC_EXPORT void (*test_hooks_arena_new_hook)();
extern JEMALLOC_EXPORT void (*test_hooks_libc_hook)();
#define JEMALLOC_HOOK(fn, hook) ((void)(hook != NULL && (hook(), 0)), fn)
#define open JEMALLOC_HOOK(open, test_hooks_libc_hook)
#define read JEMALLOC_HOOK(read, test_hooks_libc_hook)
#define write JEMALLOC_HOOK(write, test_hooks_libc_hook)
#define readlink JEMALLOC_HOOK(readlink, test_hooks_libc_hook)
#define close JEMALLOC_HOOK(close, test_hooks_libc_hook)
#define creat JEMALLOC_HOOK(creat, test_hooks_libc_hook)
#define secure_getenv JEMALLOC_HOOK(secure_getenv, test_hooks_libc_hook)
/* Note that this is undef'd and re-define'd in src/prof.c. */
#define _Unwind_Backtrace JEMALLOC_HOOK(_Unwind_Backtrace, test_hooks_libc_hook)
#endif /* JEMALLOC_INTERNAL_TEST_HOOKS_H */
+13
View File
@@ -75,4 +75,17 @@ ticker_tick(ticker_t *ticker) {
return ticker_ticks(ticker, 1);
}
/*
* Try to tick. If ticker would fire, return true, but rely on
* slowpath to reset ticker.
*/
static inline bool
ticker_trytick(ticker_t *ticker) {
--ticker->tick;
if (unlikely(ticker->tick < 0)) {
return true;
}
return false;
}
#endif /* JEMALLOC_INTERNAL_TICKER_H */
+122 -33
View File
@@ -3,6 +3,7 @@
#include "jemalloc/internal/arena_types.h"
#include "jemalloc/internal/assert.h"
#include "jemalloc/internal/bin_types.h"
#include "jemalloc/internal/jemalloc_internal_externs.h"
#include "jemalloc/internal/prof_types.h"
#include "jemalloc/internal/ql.h"
@@ -68,17 +69,19 @@ typedef void (*test_callback_t)(int *);
O(offset_state, uint64_t, uint64_t) \
O(thread_allocated, uint64_t, uint64_t) \
O(thread_deallocated, uint64_t, uint64_t) \
O(bytes_until_sample, int64_t, int64_t) \
O(prof_tdata, prof_tdata_t *, prof_tdata_t *) \
O(rtree_ctx, rtree_ctx_t, rtree_ctx_t) \
O(iarena, arena_t *, arena_t *) \
O(arena, arena_t *, arena_t *) \
O(arenas_tdata, arena_tdata_t *, arena_tdata_t *)\
O(binshards, tsd_binshards_t, tsd_binshards_t)\
O(tcache, tcache_t, tcache_t) \
O(witness_tsd, witness_tsd_t, witness_tsdn_t) \
MALLOC_TEST_TSD
#define TSD_INITIALIZER { \
tsd_state_uninitialized, \
ATOMIC_INIT(tsd_state_uninitialized), \
TCACHE_ENABLED_ZERO_INITIALIZER, \
false, \
0, \
@@ -86,29 +89,97 @@ typedef void (*test_callback_t)(int *);
0, \
0, \
0, \
0, \
NULL, \
RTREE_CTX_ZERO_INITIALIZER, \
NULL, \
NULL, \
NULL, \
TSD_BINSHARDS_ZERO_INITIALIZER, \
TCACHE_ZERO_INITIALIZER, \
WITNESS_TSD_INITIALIZER \
MALLOC_TEST_TSD_INITIALIZER \
}
void *malloc_tsd_malloc(size_t size);
void malloc_tsd_dalloc(void *wrapper);
void malloc_tsd_cleanup_register(bool (*f)(void));
tsd_t *malloc_tsd_boot0(void);
void malloc_tsd_boot1(void);
void tsd_cleanup(void *arg);
tsd_t *tsd_fetch_slow(tsd_t *tsd, bool internal);
void tsd_state_set(tsd_t *tsd, uint8_t new_state);
void tsd_slow_update(tsd_t *tsd);
void tsd_prefork(tsd_t *tsd);
void tsd_postfork_parent(tsd_t *tsd);
void tsd_postfork_child(tsd_t *tsd);
/*
* Call ..._inc when your module wants to take all threads down the slow paths,
* and ..._dec when it no longer needs to.
*/
void tsd_global_slow_inc(tsdn_t *tsdn);
void tsd_global_slow_dec(tsdn_t *tsdn);
bool tsd_global_slow();
enum {
tsd_state_nominal = 0, /* Common case --> jnz. */
tsd_state_nominal_slow = 1, /* Initialized but on slow path. */
/* the above 2 nominal states should be lower values. */
tsd_state_nominal_max = 1, /* used for comparison only. */
tsd_state_minimal_initialized = 2,
tsd_state_purgatory = 3,
tsd_state_reincarnated = 4,
tsd_state_uninitialized = 5
/* Common case --> jnz. */
tsd_state_nominal = 0,
/* Initialized but on slow path. */
tsd_state_nominal_slow = 1,
/*
* Some thread has changed global state in such a way that all nominal
* threads need to recompute their fast / slow status the next time they
* get a chance.
*
* Any thread can change another thread's status *to* recompute, but
* threads are the only ones who can change their status *from*
* recompute.
*/
tsd_state_nominal_recompute = 2,
/*
* The above nominal states should be lower values. We use
* tsd_nominal_max to separate nominal states from threads in the
* process of being born / dying.
*/
tsd_state_nominal_max = 2,
/*
* A thread might free() during its death as its only allocator action;
* in such scenarios, we need tsd, but set up in such a way that no
* cleanup is necessary.
*/
tsd_state_minimal_initialized = 3,
/* States during which we know we're in thread death. */
tsd_state_purgatory = 4,
tsd_state_reincarnated = 5,
/*
* What it says on the tin; tsd that hasn't been initialized. Note
* that even when the tsd struct lives in TLS, when need to keep track
* of stuff like whether or not our pthread destructors have been
* scheduled, so this really truly is different than the nominal state.
*/
tsd_state_uninitialized = 6
};
/* Manually limit tsd_state_t to a single byte. */
typedef uint8_t tsd_state_t;
/*
* Some TSD accesses can only be done in a nominal state. To enforce this, we
* wrap TSD member access in a function that asserts on TSD state, and mangle
* field names to prevent touching them accidentally.
*/
#define TSD_MANGLE(n) cant_access_tsd_items_directly_use_a_getter_or_setter_##n
#ifdef JEMALLOC_U8_ATOMICS
# define tsd_state_t atomic_u8_t
# define tsd_atomic_load atomic_load_u8
# define tsd_atomic_store atomic_store_u8
# define tsd_atomic_exchange atomic_exchange_u8
#else
# define tsd_state_t atomic_u32_t
# define tsd_atomic_load atomic_load_u32
# define tsd_atomic_store atomic_store_u32
# define tsd_atomic_exchange atomic_exchange_u32
#endif
/* The actual tsd. */
struct tsd_s {
@@ -117,13 +188,29 @@ struct tsd_s {
* module. Access any thread-local state through the getters and
* setters below.
*/
tsd_state_t state;
/*
* We manually limit the state to just a single byte. Unless the 8-bit
* atomics are unavailable (which is rare).
*/
tsd_state_t state;
#define O(n, t, nt) \
t use_a_getter_or_setter_instead_##n;
t TSD_MANGLE(n);
MALLOC_TSD
#undef O
};
JEMALLOC_ALWAYS_INLINE uint8_t
tsd_state_get(tsd_t *tsd) {
/*
* This should be atomic. Unfortunately, compilers right now can't tell
* that this can be done as a memory comparison, and forces a load into
* a register that hurts fast-path performance.
*/
/* return atomic_load_u8(&tsd->state, ATOMIC_RELAXED); */
return *(uint8_t *)&tsd->state;
}
/*
* Wrapper around tsd_t that makes it possible to avoid implicit conversion
* between tsd_t and tsdn_t, where tsdn_t is "nullable" and has to be
@@ -150,15 +237,6 @@ tsdn_tsd(tsdn_t *tsdn) {
return &tsdn->tsd;
}
void *malloc_tsd_malloc(size_t size);
void malloc_tsd_dalloc(void *wrapper);
void malloc_tsd_cleanup_register(bool (*f)(void));
tsd_t *malloc_tsd_boot0(void);
void malloc_tsd_boot1(void);
void tsd_cleanup(void *arg);
tsd_t *tsd_fetch_slow(tsd_t *tsd, bool internal);
void tsd_slow_update(tsd_t *tsd);
/*
* We put the platform-specific data declarations and inlines into their own
* header files to avoid cluttering this file. They define tsd_boot0,
@@ -182,7 +260,7 @@ void tsd_slow_update(tsd_t *tsd);
#define O(n, t, nt) \
JEMALLOC_ALWAYS_INLINE t * \
tsd_##n##p_get_unsafe(tsd_t *tsd) { \
return &tsd->use_a_getter_or_setter_instead_##n; \
return &tsd->TSD_MANGLE(n); \
}
MALLOC_TSD
#undef O
@@ -191,10 +269,16 @@ MALLOC_TSD
#define O(n, t, nt) \
JEMALLOC_ALWAYS_INLINE t * \
tsd_##n##p_get(tsd_t *tsd) { \
assert(tsd->state == tsd_state_nominal || \
tsd->state == tsd_state_nominal_slow || \
tsd->state == tsd_state_reincarnated || \
tsd->state == tsd_state_minimal_initialized); \
/* \
* Because the state might change asynchronously if it's \
* nominal, we need to make sure that we only read it once. \
*/ \
uint8_t state = tsd_state_get(tsd); \
assert(state == tsd_state_nominal || \
state == tsd_state_nominal_slow || \
state == tsd_state_nominal_recompute || \
state == tsd_state_reincarnated || \
state == tsd_state_minimal_initialized); \
return tsd_##n##p_get_unsafe(tsd); \
}
MALLOC_TSD
@@ -229,8 +313,8 @@ MALLOC_TSD
#define O(n, t, nt) \
JEMALLOC_ALWAYS_INLINE void \
tsd_##n##_set(tsd_t *tsd, t val) { \
assert(tsd->state != tsd_state_reincarnated && \
tsd->state != tsd_state_minimal_initialized); \
assert(tsd_state_get(tsd) != tsd_state_reincarnated && \
tsd_state_get(tsd) != tsd_state_minimal_initialized); \
*tsd_##n##p_get(tsd) = val; \
}
MALLOC_TSD
@@ -238,13 +322,18 @@ MALLOC_TSD
JEMALLOC_ALWAYS_INLINE void
tsd_assert_fast(tsd_t *tsd) {
/*
* Note that our fastness assertion does *not* include global slowness
* counters; it's not in general possible to ensure that they won't
* change asynchronously from underneath us.
*/
assert(!malloc_slow && tsd_tcache_enabled_get(tsd) &&
tsd_reentrancy_level_get(tsd) == 0);
}
JEMALLOC_ALWAYS_INLINE bool
tsd_fast(tsd_t *tsd) {
bool fast = (tsd->state == tsd_state_nominal);
bool fast = (tsd_state_get(tsd) == tsd_state_nominal);
if (fast) {
tsd_assert_fast(tsd);
}
@@ -261,7 +350,7 @@ tsd_fetch_impl(bool init, bool minimal) {
}
assert(tsd != NULL);
if (unlikely(tsd->state != tsd_state_nominal)) {
if (unlikely(tsd_state_get(tsd) != tsd_state_nominal)) {
return tsd_fetch_slow(tsd, minimal);
}
assert(tsd_fast(tsd));
@@ -281,7 +370,7 @@ JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_internal_fetch(void) {
tsd_t *tsd = tsd_fetch_min();
/* Use reincarnated state to prevent full initialization. */
tsd->state = tsd_state_reincarnated;
tsd_state_set(tsd, tsd_state_reincarnated);
return tsd;
}
@@ -293,7 +382,7 @@ tsd_fetch(void) {
static inline bool
tsd_nominal(tsd_t *tsd) {
return (tsd->state <= tsd_state_nominal_max);
return (tsd_state_get(tsd) <= tsd_state_nominal_max);
}
JEMALLOC_ALWAYS_INLINE tsdn_t *
+6
View File
@@ -77,7 +77,10 @@ tsd_wrapper_get(bool init) {
abort();
} else {
wrapper->initialized = false;
JEMALLOC_DIAGNOSTIC_PUSH
JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
tsd_t initializer = TSD_INITIALIZER;
JEMALLOC_DIAGNOSTIC_POP
wrapper->val = initializer;
}
tsd_wrapper_set(wrapper);
@@ -107,7 +110,10 @@ tsd_boot1(void) {
tsd_boot_wrapper.initialized = false;
tsd_cleanup(&tsd_boot_wrapper.val);
wrapper->initialized = false;
JEMALLOC_DIAGNOSTIC_PUSH
JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
tsd_t initializer = TSD_INITIALIZER;
JEMALLOC_DIAGNOSTIC_POP
wrapper->val = initializer;
tsd_wrapper_set(wrapper);
}
@@ -3,8 +3,10 @@
#endif
#define JEMALLOC_INTERNAL_TSD_MALLOC_THREAD_CLEANUP_H
extern __thread tsd_t tsd_tls;
extern __thread bool tsd_initialized;
#define JEMALLOC_TSD_TYPE_ATTR(type) __thread type JEMALLOC_TLS_MODEL
extern JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls;
extern JEMALLOC_TSD_TYPE_ATTR(bool) tsd_initialized;
extern bool tsd_booted;
/* Initialization/cleanup. */
@@ -47,7 +49,6 @@ tsd_get_allocates(void) {
/* Get/set. */
JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_get(bool init) {
assert(tsd_booted);
return &tsd_tls;
}
JEMALLOC_ALWAYS_INLINE void
+4 -3
View File
@@ -3,7 +3,9 @@
#endif
#define JEMALLOC_INTERNAL_TSD_TLS_H
extern __thread tsd_t tsd_tls;
#define JEMALLOC_TSD_TYPE_ATTR(type) __thread type JEMALLOC_TLS_MODEL
extern JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls;
extern pthread_key_t tsd_tsd;
extern bool tsd_booted;
@@ -39,8 +41,7 @@ tsd_get_allocates(void) {
/* Get/set. */
JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_get(UNUSED bool init) {
assert(tsd_booted);
tsd_get(bool init) {
return &tsd_tls;
}
+14 -13
View File
@@ -27,9 +27,9 @@
#define WITNESS_RANK_PROF_BT2GCTX 6U
#define WITNESS_RANK_PROF_TDATAS 7U
#define WITNESS_RANK_PROF_TDATA 8U
#define WITNESS_RANK_PROF_GCTX 9U
#define WITNESS_RANK_BACKGROUND_THREAD 10U
#define WITNESS_RANK_PROF_LOG 9U
#define WITNESS_RANK_PROF_GCTX 10U
#define WITNESS_RANK_BACKGROUND_THREAD 11U
/*
* Used as an argument to witness_assert_depth_to_rank() in order to validate
@@ -37,18 +37,19 @@
* witness_assert_depth_to_rank() is inclusive rather than exclusive, this
* definition can have the same value as the minimally ranked core lock.
*/
#define WITNESS_RANK_CORE 11U
#define WITNESS_RANK_CORE 12U
#define WITNESS_RANK_DECAY 11U
#define WITNESS_RANK_TCACHE_QL 12U
#define WITNESS_RANK_EXTENT_GROW 13U
#define WITNESS_RANK_EXTENTS 14U
#define WITNESS_RANK_EXTENT_AVAIL 15U
#define WITNESS_RANK_DECAY 12U
#define WITNESS_RANK_TCACHE_QL 13U
#define WITNESS_RANK_EXTENT_GROW 14U
#define WITNESS_RANK_EXTENTS 15U
#define WITNESS_RANK_EXTENT_AVAIL 16U
#define WITNESS_RANK_EXTENT_POOL 16U
#define WITNESS_RANK_RTREE 17U
#define WITNESS_RANK_BASE 18U
#define WITNESS_RANK_ARENA_LARGE 19U
#define WITNESS_RANK_EXTENT_POOL 17U
#define WITNESS_RANK_RTREE 18U
#define WITNESS_RANK_BASE 19U
#define WITNESS_RANK_ARENA_LARGE 20U
#define WITNESS_RANK_HOOK 21U
#define WITNESS_RANK_LEAF 0xffffffffU
#define WITNESS_RANK_BIN WITNESS_RANK_LEAF
+3
View File
@@ -4,6 +4,9 @@
/* Defined if alloc_size attribute is supported. */
#undef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
/* Defined if format_arg(...) attribute is supported. */
#undef JEMALLOC_HAVE_ATTR_FORMAT_ARG
/* Defined if format(gnu_printf, ...) attribute is supported. */
#undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
+8 -1
View File
@@ -10,6 +10,7 @@
#define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
#define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
#define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
#define JEMALLOC_VERSION_GID_IDENT @jemalloc_version_gid@
#define MALLOCX_LG_ALIGN(la) ((int)(la))
#if LG_SIZEOF_PTR == 2
@@ -68,6 +69,7 @@
# define JEMALLOC_EXPORT __declspec(dllimport)
# endif
# endif
# define JEMALLOC_FORMAT_ARG(i)
# define JEMALLOC_FORMAT_PRINTF(s, i)
# define JEMALLOC_NOINLINE __declspec(noinline)
# ifdef __cplusplus
@@ -95,6 +97,11 @@
# ifndef JEMALLOC_EXPORT
# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
# endif
# ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG
# define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3))
# else
# define JEMALLOC_FORMAT_ARG(i)
# endif
# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
@@ -123,4 +130,4 @@
/* This version of Jemalloc, modified for Redis, has the je_get_defrag_hint()
* function. */
#define JEMALLOC_FRAG_HINT
#define JEMALLOC_FRAG_HINT
@@ -47,7 +47,7 @@
<ClCompile Include="..\..\..\..\src\extent_dss.c" />
<ClCompile Include="..\..\..\..\src\extent_mmap.c" />
<ClCompile Include="..\..\..\..\src\hash.c" />
<ClCompile Include="..\..\..\..\src\hooks.c" />
<ClCompile Include="..\..\..\..\src\hook.c" />
<ClCompile Include="..\..\..\..\src\jemalloc.c" />
<ClCompile Include="..\..\..\..\src\large.c" />
<ClCompile Include="..\..\..\..\src\log.c" />
@@ -59,12 +59,14 @@
<ClCompile Include="..\..\..\..\src\prng.c" />
<ClCompile Include="..\..\..\..\src\prof.c" />
<ClCompile Include="..\..\..\..\src\rtree.c" />
<ClCompile Include="..\..\..\..\src\sc.c" />
<ClCompile Include="..\..\..\..\src\stats.c" />
<ClCompile Include="..\..\..\..\src\sz.c" />
<ClCompile Include="..\..\..\..\src\tcache.c" />
<ClCompile Include="..\..\..\..\src\ticker.c" />
<ClCompile Include="..\..\..\..\src\tsd.c" />
<ClCompile Include="..\..\..\..\src\witness.c" />
<ClCompile Include="..\..\..\..\src\safety_check.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8D6BB292-9E1C-413D-9F98-4864BDC1514A}</ProjectGuid>
@@ -345,4 +347,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Loaded 100 of 1055 files, more files were not shown because too many files have changed in this diff. Show more