-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New WAL implementation with configurable variables #1356
Merged
JyotinderSingh
merged 7 commits into
DiceDB:master
from
ayushsatyam146:wal-implementation
Dec 16, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b85c2d4
added WAL implementation with configurables
ayushsatyam146 2f84bd8
fix lint
ayushsatyam146 c892936
fixes lint
ayushsatyam146 848d7ed
fixed lint
ayushsatyam146 d972a4a
fixing unit tests
ayushsatyam146 982faa4
introducing enums and removing pre allocated files
ayushsatyam146 0d30b68
fix lint
ayushsatyam146 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"log/slog" | ||
"net" | ||
"strconv" | ||
"strings" | ||
"sync/atomic" | ||
"syscall" | ||
"time" | ||
|
@@ -563,13 +564,17 @@ func (t *BaseIOThread) handleCommand(ctx context.Context, cmdMeta CmdMeta, diceD | |
} | ||
|
||
if err == nil && t.wl != nil { | ||
t.wl.LogCommand(diceDBCmd) | ||
if err := t.wl.LogCommand([]byte(fmt.Sprintf("%s %s", diceDBCmd.Cmd, strings.Join(diceDBCmd.Args, " ")))); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an enhancement we can later have modes like strict/lenient for WAL writes, this'd allow us to just err out instead of completely failing if write to WAL fails. |
||
return err | ||
} | ||
} | ||
case MultiShard, AllShard: | ||
err = t.writeResponse(ctx, cmdMeta.composeResponse(storeOp...)) | ||
|
||
if err == nil && t.wl != nil { | ||
t.wl.LogCommand(diceDBCmd) | ||
if err := t.wl.LogCommand([]byte(fmt.Sprintf("%s %s", diceDBCmd.Cmd, strings.Join(diceDBCmd.Args, " ")))); err != nil { | ||
return err | ||
} | ||
} | ||
default: | ||
slog.Error("Unknown command type", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
set -e | ||
|
||
# Define the directory where the proto file resides | ||
PROTO_DIR=$(dirname "$0") | ||
|
||
# Define the proto file and the output file | ||
PROTO_FILE="$PROTO_DIR/wal.proto" | ||
OUTPUT_DIR="." | ||
|
||
# Function to install protoc if not present | ||
install_protoc() { | ||
echo "protoc not found. Installing Protocol Buffers compiler..." | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
# MacOS installation | ||
brew install protobuf | ||
elif [[ "$(uname)" == "Linux" ]]; then | ||
# Linux installation | ||
sudo apt update && sudo apt install -y protobuf-compiler | ||
else | ||
echo "Unsupported OS. Please install 'protoc' manually." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to install the Go plugin for protoc if not present | ||
install_protoc_gen_go() { | ||
echo "protoc-gen-go not found. Installing Go plugin for protoc..." | ||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
export PATH="$PATH:$(go env GOPATH)/bin" | ||
echo "Make sure $(go env GOPATH)/bin is in your PATH." | ||
} | ||
|
||
# Check if protoc is installed, install if necessary | ||
if ! command -v protoc &>/dev/null; then | ||
install_protoc | ||
fi | ||
|
||
# Check if the Go plugin for protoc is installed, install if necessary | ||
if ! command -v protoc-gen-go &>/dev/null; then | ||
install_protoc_gen_go | ||
fi | ||
|
||
# Generate the wal.pb.go file | ||
echo "Generating wal.pb.go from wal.proto..." | ||
protoc --go_out="$OUTPUT_DIR" --go_opt=paths=source_relative "$PROTO_FILE" | ||
|
||
echo "Generation complete. File created at $OUTPUT_DIR/wal.pb.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
segment