Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Enhance Error Handling and Cleanup in rotateLog for Robust WAL Rotation #1760

@ayushsatyam146

Description

@ayushsatyam146

Currently, rotateLog method returns errors for sync and csf.Close, but explicitly panics if opening a new segment file fails. This panic behavior is not good for a robust WAL system, as it can lead to application crashes and potential data inconsistency or corruption if a new segment cannot be created.

  • Figure out the critical edge cases and conditions where this method will throw error and handle them gracefully or return properly logged error messages.
  • Replace the panic during os.OpenFile failure with a graceful error return, logging the critical failure.
  • Review periodicRotateSegment: Ensure the caller of rotateLog (periodicRotateSegment) is equipped to handle the returned errors gracefully (e.g., logging, retries, or shutting down if unrecoverable).

Refer the below TODOs in the method for more context

// TODO: Ideally this function should not return any error
// Check for the conditions where it can return an error
// and handle them gracefully.
// I fear that we will need to do some cleanup operations in case of errors.
// TODO: We are panicking here because we are not handling the error
// and we want to make sure that the WAL is not corrupted.
// We need to handle this error gracefully.

Setup Instructions

  1. setup DiceDB server locally from the source - instructions
  2. setup DiceDB Go SDK locally from the source - instructions
  3. setup DiceDB CLI locally from the source - instructions
  4. refer to the Pointing to local checked-out dicedb-gosection inREADME`.

Start the DiceDB server

$ go run main.go --log-level debug

Follow the contribution guidelines

These are general guidelines to follow before you submit a patch. Please mark them as done once you complete them

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions