Skip to content

Abort fork on intermediate states #2043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 28, 2021
Merged

Abort fork on intermediate states #2043

merged 14 commits into from
Nov 28, 2021

Conversation

AviAvni
Copy link
Contributor

@AviAvni AviAvni commented Nov 24, 2021

No description provided.

@codecov
Copy link

codecov bot commented Nov 24, 2021

Codecov Report

Merging #2043 (4db62fc) into master (53ddab0) will increase coverage by 0.06%.
The diff coverage is 96.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2043      +/-   ##
==========================================
+ Coverage   92.77%   92.83%   +0.06%     
==========================================
  Files         247      248       +1     
  Lines       21648    21666      +18     
==========================================
+ Hits        20084    20114      +30     
+ Misses       1564     1552      -12     
Impacted Files Coverage Δ
...rc/serializers/decoders/current/v10/decode_graph.c 96.96% <ø> (-0.07%) ⬇️
src/serializers/decoders/prev/v7/decode_graph.c 96.47% <ø> (-0.09%) ⬇️
src/serializers/decoders/prev/v8/decode_graph.c 96.73% <ø> (-0.07%) ⬇️
src/serializers/decoders/prev/v9/decode_graph.c 96.93% <ø> (-0.07%) ⬇️
src/module.c 71.92% <50.00%> (-0.80%) ⬇️
src/module_event_handlers.c 97.74% <94.73%> (+8.35%) ⬆️
src/commands/cmd_debug.c 100.00% <100.00%> (ø)
src/graph/graphcontext.c 97.38% <100.00%> (-0.02%) ⬇️
src/serializers/decode_context.c 93.02% <100.00%> (+0.16%) ⬆️
src/serializers/graphcontext_type.c 89.18% <100.00%> (+5.31%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53ddab0...4db62fc. Read the comment docs.

_ResetDecodeStates();
uint count = array_len(graphs_in_keyspace);
for (size_t i = 0; i < count; i++) {
GraphContext_Delete(graphs_in_keyspace[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain how the ref count is managed in case where the original graph key is present in the key-space and when the original graph key is missing ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case when redis call the free function it supply the freed graph context
there is nothing to remove from registry and the refcount going to be decreased to -2 and to not free the graph context

@@ -34,7 +33,7 @@ static inline void _GraphContext_IncreaseRefCount(GraphContext *gc) {

static inline void _GraphContext_DecreaseRefCount(GraphContext *gc) {
// If the reference count is less than 0, the graph has been marked for deletion and no queries are active - free the graph.
if(__atomic_sub_fetch(&gc->ref_count, 1, __ATOMIC_RELAXED) < 0) {
if(__atomic_sub_fetch(&gc->ref_count, 1, __ATOMIC_RELAXED) == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add: ASSERT(gc->ref_count > -2); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before or after?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so in our case we can get to -2 but want to call free once

extern GraphContext **graphs_in_keyspace;
extern uint aux_field_counter;

static void Debug_AUX(const char *arg) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass original argv and argc you might want to pass argv+1, argc-1 as the first value AUX was consumed.


self._connection_permutation(connection_permutation, 3)

self._step(scenario[2], 3, None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove last argument, always None

@@ -16,7 +16,11 @@ void ModuleEventHandler_AUXAfterKeyspaceEvent(void);
extern GraphContext **graphs_in_keyspace;
extern uint aux_field_counter;

static void Debug_AUX(const char *arg) {
static void Debug_AUX(RedisModuleString **argv, int argc) {
if(argc < 2) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AviAvni Emit an error in this case

@swilly22 swilly22 merged commit ecd0552 into master Nov 28, 2021
@swilly22 swilly22 deleted the abort-fork-on-inter branch November 28, 2021 12:30
@swilly22
Copy link
Contributor

@AviAvni Cherry pick into 2.4

AviAvni added a commit that referenced this pull request Nov 28, 2021
* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>
swilly22 added a commit that referenced this pull request Nov 28, 2021
* Abort fork on intermediate states (#2043)

* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>

* update keys

Co-authored-by: swilly22 <[email protected]>
jeffreylovitz pushed a commit that referenced this pull request Dec 9, 2021
* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>
(cherry picked from commit ecd0552)
swilly22 pushed a commit that referenced this pull request Dec 9, 2021
* Abort fork on intermediate states (#2043)

* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>
(cherry picked from commit ecd0552)

* bump version to 2.8.7

* Test against RE version 100.0.0-2646

Co-authored-by: Avi Avni <[email protected]>
AviAvni added a commit that referenced this pull request Dec 13, 2021
* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>
swilly22 added a commit that referenced this pull request Dec 16, 2021
* index data on key load

* remove index at end

* index costruct both indices

* Abort fork on intermediate states (#2043)

* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>

* update keys

* filter index scan result when index can't be utilize properly

* fix test

* handle reset

* add more tests

* make vkey_entity_count runtime config

* address review

* add tests

* address review

* fix test

* address review

Co-authored-by: Avi Avni <[email protected]>
AviAvni added a commit that referenced this pull request Dec 19, 2021
* index data on key load

* remove index at end

* index costruct both indices

* Abort fork on intermediate states (#2043)

* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>

* update keys

* filter index scan result when index can't be utilize properly

* fix test

* handle reset

* add more tests

* make vkey_entity_count runtime config

* address review

* add tests

* address review

* fix test

* address review

Co-authored-by: Avi Avni <[email protected]>
swilly22 added a commit that referenced this pull request Dec 22, 2021
* Index on vkey (#2067)

* index data on key load

* remove index at end

* index costruct both indices

* Abort fork on intermediate states (#2043)

* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>

* update keys

* filter index scan result when index can't be utilize properly

* fix test

* handle reset

* add more tests

* make vkey_entity_count runtime config

* address review

* add tests

* address review

* fix test

* address review

Co-authored-by: Avi Avni <[email protected]>

* fix merge

* fix merge

* fix merge

* fix merge

* fix merge

* fix merge

* fix merge

* refine

* address edge index scan review

* fix checking the accuracy for index

* order by index scan results

* add comments

* clean decode_graph

* a bit more refactoring around encoder/decoder

* address encoder/decoder review

* clean

* clean decode graph schema

* address review

* remove paren

Co-authored-by: Roi Lipman <[email protected]>
Co-authored-by: swilly22 <[email protected]>
pnxguide pushed a commit to CMU-SPEED/RedisGraph that referenced this pull request Mar 22, 2023
* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>
pnxguide pushed a commit to CMU-SPEED/RedisGraph that referenced this pull request Mar 22, 2023
* Index on vkey (RedisGraph#2067)

* index data on key load

* remove index at end

* index costruct both indices

* Abort fork on intermediate states (RedisGraph#2043)

* remove currently decoding graphs

* removed AOF rewrite callback

* abort encoding if intermediate graph detected

* handle intermediate at the fork callback level

* removed currently_decoding_graphs from graphcontext

* add debug command

* clear graphs_in_keyspace in flush all

* add replication states tests

* move exit to aux save

* move exit to persistence event handler

* address review

* remove aux_field_counter

* address review

* address review

Co-authored-by: swilly22 <[email protected]>

* update keys

* filter index scan result when index can't be utilize properly

* fix test

* handle reset

* add more tests

* make vkey_entity_count runtime config

* address review

* add tests

* address review

* fix test

* address review

Co-authored-by: Avi Avni <[email protected]>

* fix merge

* fix merge

* fix merge

* fix merge

* fix merge

* fix merge

* fix merge

* refine

* address edge index scan review

* fix checking the accuracy for index

* order by index scan results

* add comments

* clean decode_graph

* a bit more refactoring around encoder/decoder

* address encoder/decoder review

* clean

* clean decode graph schema

* address review

* remove paren

Co-authored-by: Roi Lipman <[email protected]>
Co-authored-by: swilly22 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants