danielealbano / cachegrand

cachegrand - a modern data ingestion, processing and serving platform built for today's hardware
BSD 3-Clause "New" or "Revised" License
975 stars 34 forks source link

Fix hashtable locking #415

Closed danielealbano closed 1 year ago

danielealbano commented 1 year ago

This PR fixes a sneaky issue in the hashtable locking, the construct used to get the worker index only once per thread was actually being called only the very first time by only one thread causing all the other threads to have a worker_index of 0.

As consequence the locking was potentially generating overlappy transaction ids leading to a potential clash.

This behaviour was put in evidence by redis-benchmark which uses only 1 single key for all the requests unless the --threads option is passed.

The PR also changes 2 other aspects:

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03 :warning:

Comparison is base (3eb32e4) 76.83% compared to head (97ace96) 76.81%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #415 +/- ## ========================================== - Coverage 76.83% 76.81% -0.03% ========================================== Files 198 198 Lines 13584 13586 +2 ========================================== - Hits 10437 10435 -2 - Misses 3147 3151 +4 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `76.81% <100.00%> (-0.03%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/danielealbano/cachegrand/pull/415?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano) | Coverage Δ | | |---|---|---| | [src/transaction.h](https://app.codecov.io/gh/danielealbano/cachegrand/pull/415?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL3RyYW5zYWN0aW9uLmg=) | `85.71% <ø> (ø)` | | | [src/transaction.c](https://app.codecov.io/gh/danielealbano/cachegrand/pull/415?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano#diff-c3JjL3RyYW5zYWN0aW9uLmM=) | `94.44% <100.00%> (+0.33%)` | :arrow_up: | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/danielealbano/cachegrand/pull/415/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Daniele+Salvatore+Albano)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.