Skip to content

Commit

Permalink
fix: sequence overflow when dropping a table using a message queue as…
Browse files Browse the repository at this point in the history
… WAL (apache#1550)

## Rationale
Fix the issue of sequence overflow when dropping a table using a message
queue as WAL.
close apache#1543 

## Detailed Changes
Check the maximum value of sequence to prevent overflow.

## Test Plan
CI.
  • Loading branch information
chunshao90 authored and zealchen committed Aug 8, 2024
1 parent 9ba4ccc commit fe5b4e8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/wal/src/message_queue_impl/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use std::sync::Arc;

use async_trait::async_trait;
use common_types::SequenceNumber;
use common_types::{SequenceNumber, MAX_SEQUENCE_NUMBER};
use generic_error::BoxError;
use message_queue::{kafka::kafka_impl::KafkaImpl, ConsumeIterator, MessageQueue};
use runtime::Runtime;
Expand Down Expand Up @@ -70,8 +70,13 @@ impl<M: MessageQueue> WalManager for MessageQueueImpl<M> {
location: WalLocation,
sequence_num: SequenceNumber,
) -> Result<()> {
let delete_to_sequence_num = if sequence_num < MAX_SEQUENCE_NUMBER {
sequence_num + 1
} else {
MAX_SEQUENCE_NUMBER
};
self.0
.mark_delete_to(location, sequence_num + 1)
.mark_delete_to(location, delete_to_sequence_num)
.await
.box_err()
.context(Delete)
Expand Down

0 comments on commit fe5b4e8

Please sign in to comment.