Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1425,25 +1425,55 @@ def recur(self, tyme, tock=0.0, **opts):


class SeekerDoer(doing.Doer):
"""Schedule bounded repair work and saved cues; Seeker owns recovery state."""

# Bound work per scheduler turn without imposing one tick per index row.
RepairBatchSize = 128

def __init__(self, seeker, cues, tock=0.0):
"""Start reconciliation before serving queries and retain the shared cue deck."""
self.seeker = seeker
self.cues = cues
self.tock = tock
super(SeekerDoer, self).__init__(tock=self.tock)
self.repair = seeker.startRepair()
super(SeekerDoer, self).__init__(tock=tock)

def recur(self, tyme=None, tock=0.0, **opts):
"""Advance a repair batch, or check one pending schema and consume one cue."""
if self.repair is not None:
try:
for _ in range(self.RepairBatchSize):
said = next(self.repair)
if said is not None:
self._report(said, self.seeker.failures.get(said))
return False
except StopIteration:
self.repair = None
except Exception as ex:
self.repair = None
self.seeker.failRepair(ex)
logger.exception("Seeker startup reconciliation failed")
return False
if (attempt := self.seeker.retry()) is not None:
self._report(*attempt)
if self.cues:
cue = self.cues.popleft()
if cue["kin"] == "saved":
creder = cue["creder"]
try:
self.seeker.index(said=creder.said)
except Exception:
self.cues.append(cue)
return False
said = cue["creder"].said
self._report(said, self.seeker.process(said))
else:
self.cues.append(cue)
return False
return False

@staticmethod
def _report(said, error):
"""Log classified failures once per attempt, retaining the original traceback."""
if error is not None:
logger.error(
"Seeker indexing failed for %s: %s",
said,
error,
exc_info=(type(error), error, error.__traceback__),
)


class ExchangeCueDoer(doing.Doer):
Expand Down
14 changes: 12 additions & 2 deletions src/keria/app/credentialing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..utils.openapi import dataclassFromFielddom
from keri.core.serdering import Protocols, Vrsn_1_0, Vrsn_2_0, SerderKERI
from ..core import httping, longrunning
from .. import keriaing
from marshmallow import fields, Schema as MarshmallowSchema
from typing import List, Dict, Any, Optional, Literal, Union
from .aiding import (
Expand Down Expand Up @@ -836,8 +837,17 @@ def on_post(req, rep):
skip = 0
limit = 25

cur = agent.seeker.find(filtr=filtr, sort=sort, skip=skip, limit=limit)
saids = [coring.Saider(qb64=said) for said in cur]
try:
cur = agent.seeker.find(filtr=filtr, sort=sort, skip=skip, limit=limit)
saids = [coring.Saider(qb64=said) for said in cur]
except keriaing.UnsupportedQueryError as ex:
raise falcon.HTTPBadRequest(
title="Unsupported credential query", description=str(ex)
)
except keriaing.IndexNotReadyError as ex:
raise falcon.HTTPServiceUnavailable(
title="Credential indexes unavailable", description=str(ex)
)
creds = agent.rgy.reger.cloneCreds(saids=saids, db=agent.hby.db)

end = skip + (len(creds) - 1) if len(creds) > 0 else 0
Expand Down
Loading
Loading