Skip to content

Commit fe5b4e8

Browse files
chunshao90zealchen
authored andcommitted
fix: sequence overflow when dropping a table using a message queue as 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.
1 parent 9ba4ccc commit fe5b4e8

File tree

1 file changed

+7
-2
lines changed
  • src/wal/src/message_queue_impl

1 file changed

+7
-2
lines changed

src/wal/src/message_queue_impl/wal.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use std::sync::Arc;
2121

2222
use async_trait::async_trait;
23-
use common_types::SequenceNumber;
23+
use common_types::{SequenceNumber, MAX_SEQUENCE_NUMBER};
2424
use generic_error::BoxError;
2525
use message_queue::{kafka::kafka_impl::KafkaImpl, ConsumeIterator, MessageQueue};
2626
use runtime::Runtime;
@@ -70,8 +70,13 @@ impl<M: MessageQueue> WalManager for MessageQueueImpl<M> {
7070
location: WalLocation,
7171
sequence_num: SequenceNumber,
7272
) -> Result<()> {
73+
let delete_to_sequence_num = if sequence_num < MAX_SEQUENCE_NUMBER {
74+
sequence_num + 1
75+
} else {
76+
MAX_SEQUENCE_NUMBER
77+
};
7378
self.0
74-
.mark_delete_to(location, sequence_num + 1)
79+
.mark_delete_to(location, delete_to_sequence_num)
7580
.await
7681
.box_err()
7782
.context(Delete)

0 commit comments

Comments
 (0)