Skip to content

Commit

Permalink
fix mod func.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinaghaei committed Feb 15, 2024
1 parent 5b80a5c commit 7d3bd6a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion kafka_server/broker/file/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def append(self, key: str, value: str):
return False
return True

# self.indexer.inc_write()

def approve_appending(self):
try:
Expand Down
2 changes: 1 addition & 1 deletion kafka_server/broker/file/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def write_data(self, key: str, value: str):
with self._write_lock:
md5 = hash_md5(key)
partition_count = get_partition_count()
if int(md5, 16) % partition_count != int(self.partition) - 1:
if int(md5, 16) % partition_count != (int(self.partition) - 1 % partition_count):
raise Exception(f"key is not for this partition, fuck {md5} {key} {partition_count}")

appended = self.segment.append(key, value)
Expand Down

0 comments on commit 7d3bd6a

Please sign in to comment.