Skip to content
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

Use goto to cleanup error handling in readSyncBulkPayload #1332

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

enjoy-binbin
Copy link
Member

The goto error label is the same as the error return, use goto
to reduce the references.

error:
    cancelReplicationHandshake(1);
    return;

Also this can make the log printing more continuous under the
error, that is, we print the error log first, and then print
the reconnecting log at the last (in cancelReplicationHandshake).

The goto error label is the same as the error return, use goto
to reduce the references.
```
error:
    cancelReplicationHandshake(1);
    return;
```

Also this can make the log printing more continuous under the
error, that is, we print the error log first, and then print
the reconnecting log at the last (in cancelReplicationHandshake).

Signed-off-by: Binbin <binloveplay1314@qq.com>
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.69%. Comparing base (4986310) to head (f3ffeaa).
Report is 1 commits behind head on unstable.

Files with missing lines Patch % Lines
src/replication.c 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #1332   +/-   ##
=========================================
  Coverage     70.68%   70.69%           
=========================================
  Files           115      115           
  Lines         63177    63171    -6     
=========================================
- Hits          44657    44656    -1     
+ Misses        18520    18515    -5     
Files with missing lines Coverage Δ
src/replication.c 87.44% <50.00%> (+0.17%) ⬆️

... and 13 files with indirect coverage changes

---- 🚨 Try these New Features:

@enjoy-binbin
Copy link
Member Author

a test log example:

67697:S 21 Nov 2024 16:01:03.309 * Loading RDB produced by Valkey version 255.255.255
67697:S 21 Nov 2024 16:01:03.309 * RDB age 0 seconds
67697:S 21 Nov 2024 16:01:03.309 * RDB memory usage when created 1.23 Mb
67697:S 21 Nov 2024 16:01:03.309 # binbintest load error
67697:S 21 Nov 2024 16:01:03.309 # Failed trying to load the PRIMARY synchronization DB from disk, check server logs.
67697:S 21 Nov 2024 16:01:03.310 * Reconnecting to PRIMARY 127.0.0.1:6379 after failure
67697:S 21 Nov 2024 16:01:03.310 * PRIMARY <-> REPLICA sync started
67697:S 21 Nov 2024 16:01:03.310 * PRIMARY <-> REPLICA sync: Discarding the half-loaded data

the reconnecting and sync started should be after discarding one.

Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

Makes sense.

The "Reconnecting" is logged by cancelReplicationHandshake.

cancelReplicationHandshake is a no-op in some cases where we just did return before, right?

@enjoy-binbin
Copy link
Member Author

enjoy-binbin commented Nov 21, 2024

cancelReplicationHandshake is a no-op in some cases where we just did return before, right?

no, cancelReplicationHandshake is not a no-op, and we are not just did return before, we did cancelReplicationHandshake and return together before, this commit just like, adjust the code location (or order).

@zuiderkwast
Copy link
Contributor

cancelReplicationHandshake is a no-op in some cases where we just did return before, right?

no, cancelReplicationHandshake is not a no-op, and we are not just did return before, we did cancelReplicationHandshake and return together before, this commit just like, adjust the code location (or order).

Ah, I see now. Every goto error replaces cancelReplicationHandshake + return.

@enjoy-binbin enjoy-binbin merged commit f553ccb into valkey-io:unstable Nov 21, 2024
48 checks passed
@enjoy-binbin enjoy-binbin deleted the goto_cleanup branch November 21, 2024 12:01
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