Skip to content

Commit 0268e9d

Browse files
committed
fix: don't checkpoint shard head past a transient git-read failure (CM-1318)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent 629c688 commit 0268e9d

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

  • services/apps/mailing_list_integration/src/crowdmail/worker

services/apps/mailing_list_integration/src/crowdmail/worker/list_worker.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
update_processed_heads,
1010
)
1111
from crowdmail.enums import IntegrationResultState, IntegrationResultType, ListState
12+
from crowdmail.errors import CommandExecutionError
1213
from crowdmail.logger import logger
1314
from crowdmail.models.list import MailingList
1415
from crowdmail.services.mirror.mirror_service import (
@@ -98,10 +99,25 @@ async def _process_single_list(mailing_list: MailingList):
9899
shard = shard_index(shard_path)
99100
commit_ids = await new_commits(shard_path, heads.get(shard))
100101
for git_id in commit_ids:
102+
# A git-read failure is operational/transient (disk hiccup, corrupt
103+
# mirror) — stop this shard without advancing past git_id so it's
104+
# retried next run, instead of checkpointing a message we never
105+
# actually read. A parse failure is content-level and permanent
106+
# (malformed message), so that case still advances the head below.
107+
try:
108+
message, blob_id = await asyncio.to_thread(read_email, shard_path, git_id)
109+
except CommandExecutionError as e:
110+
logger.error(
111+
"Stopping shard {} for retry after git-read failure on commit {}: {}",
112+
shard_path,
113+
git_id,
114+
repr(e),
115+
)
116+
break
117+
101118
heads[shard] = git_id
102119
dirty_heads[shard] = git_id
103120
try:
104-
message, blob_id = await asyncio.to_thread(read_email, shard_path, git_id)
105121
parsed = parse_email(
106122
message,
107123
mailing_list.source_url,

0 commit comments

Comments
 (0)