mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-28 21:05:17 +02:00
improve messaging and UI around cleanup of leftover index attempts (#3247)
* improve messaging and UI around cleanup of leftover index attempts * add tag on init
This commit is contained in:
@@ -24,7 +24,7 @@ from danswer.configs.constants import POSTGRES_CELERY_WORKER_PRIMARY_APP_NAME
|
|||||||
from danswer.db.engine import get_session_with_default_tenant
|
from danswer.db.engine import get_session_with_default_tenant
|
||||||
from danswer.db.engine import SqlEngine
|
from danswer.db.engine import SqlEngine
|
||||||
from danswer.db.index_attempt import get_index_attempt
|
from danswer.db.index_attempt import get_index_attempt
|
||||||
from danswer.db.index_attempt import mark_attempt_failed
|
from danswer.db.index_attempt import mark_attempt_canceled
|
||||||
from danswer.redis.redis_connector_credential_pair import RedisConnectorCredentialPair
|
from danswer.redis.redis_connector_credential_pair import RedisConnectorCredentialPair
|
||||||
from danswer.redis.redis_connector_delete import RedisConnectorDelete
|
from danswer.redis.redis_connector_delete import RedisConnectorDelete
|
||||||
from danswer.redis.redis_connector_doc_perm_sync import RedisConnectorPermissionSync
|
from danswer.redis.redis_connector_doc_perm_sync import RedisConnectorPermissionSync
|
||||||
@@ -165,13 +165,13 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
failure_reason = (
|
failure_reason = (
|
||||||
f"Orphaned index attempt found on startup: "
|
f"Canceling leftover index attempt found on startup: "
|
||||||
f"index_attempt={attempt.id} "
|
f"index_attempt={attempt.id} "
|
||||||
f"cc_pair={attempt.connector_credential_pair_id} "
|
f"cc_pair={attempt.connector_credential_pair_id} "
|
||||||
f"search_settings={attempt.search_settings_id}"
|
f"search_settings={attempt.search_settings_id}"
|
||||||
)
|
)
|
||||||
logger.warning(failure_reason)
|
logger.warning(failure_reason)
|
||||||
mark_attempt_failed(attempt.id, db_session, failure_reason)
|
mark_attempt_canceled(attempt.id, db_session, failure_reason)
|
||||||
|
|
||||||
|
|
||||||
@worker_ready.connect
|
@worker_ready.connect
|
||||||
|
@@ -77,7 +77,7 @@ class IndexingCallback(IndexingHeartbeatInterface):
|
|||||||
self.started: datetime = datetime.now(timezone.utc)
|
self.started: datetime = datetime.now(timezone.utc)
|
||||||
self.redis_lock.reacquire()
|
self.redis_lock.reacquire()
|
||||||
|
|
||||||
self.last_tag: str = ""
|
self.last_tag: str = "IndexingCallback.__init__"
|
||||||
self.last_lock_reacquire: datetime = datetime.now(timezone.utc)
|
self.last_lock_reacquire: datetime = datetime.now(timezone.utc)
|
||||||
|
|
||||||
def should_stop(self) -> bool:
|
def should_stop(self) -> bool:
|
||||||
|
@@ -5,6 +5,7 @@ class IndexingStatus(str, PyEnum):
|
|||||||
NOT_STARTED = "not_started"
|
NOT_STARTED = "not_started"
|
||||||
IN_PROGRESS = "in_progress"
|
IN_PROGRESS = "in_progress"
|
||||||
SUCCESS = "success"
|
SUCCESS = "success"
|
||||||
|
CANCELED = "canceled"
|
||||||
FAILED = "failed"
|
FAILED = "failed"
|
||||||
COMPLETED_WITH_ERRORS = "completed_with_errors"
|
COMPLETED_WITH_ERRORS = "completed_with_errors"
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ class IndexingStatus(str, PyEnum):
|
|||||||
terminal_states = {
|
terminal_states = {
|
||||||
IndexingStatus.SUCCESS,
|
IndexingStatus.SUCCESS,
|
||||||
IndexingStatus.COMPLETED_WITH_ERRORS,
|
IndexingStatus.COMPLETED_WITH_ERRORS,
|
||||||
|
IndexingStatus.CANCELED,
|
||||||
IndexingStatus.FAILED,
|
IndexingStatus.FAILED,
|
||||||
}
|
}
|
||||||
return self in terminal_states
|
return self in terminal_states
|
||||||
|
@@ -225,6 +225,28 @@ def mark_attempt_partially_succeeded(
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def mark_attempt_canceled(
|
||||||
|
index_attempt_id: int,
|
||||||
|
db_session: Session,
|
||||||
|
reason: str = "Unknown",
|
||||||
|
) -> None:
|
||||||
|
try:
|
||||||
|
attempt = db_session.execute(
|
||||||
|
select(IndexAttempt)
|
||||||
|
.where(IndexAttempt.id == index_attempt_id)
|
||||||
|
.with_for_update()
|
||||||
|
).scalar_one()
|
||||||
|
|
||||||
|
if not attempt.time_started:
|
||||||
|
attempt.time_started = datetime.now(timezone.utc)
|
||||||
|
attempt.status = IndexingStatus.CANCELED
|
||||||
|
attempt.error_msg = reason
|
||||||
|
db_session.commit()
|
||||||
|
except Exception:
|
||||||
|
db_session.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def mark_attempt_failed(
|
def mark_attempt_failed(
|
||||||
index_attempt_id: int,
|
index_attempt_id: int,
|
||||||
db_session: Session,
|
db_session: Session,
|
||||||
|
@@ -68,10 +68,11 @@ export default function UpgradingPage({
|
|||||||
const statusOrder: Record<ValidStatuses, number> = useMemo(
|
const statusOrder: Record<ValidStatuses, number> = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
failed: 0,
|
failed: 0,
|
||||||
completed_with_errors: 1,
|
canceled: 1,
|
||||||
not_started: 2,
|
completed_with_errors: 2,
|
||||||
in_progress: 3,
|
not_started: 3,
|
||||||
success: 4,
|
in_progress: 4,
|
||||||
|
success: 5,
|
||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
@@ -322,7 +322,8 @@ export function IndexingAttemptsTable({ ccPair }: { ccPair: CCPairFullInfo }) {
|
|||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{indexAttempt.status === "failed" &&
|
{(indexAttempt.status === "failed" ||
|
||||||
|
indexAttempt.status === "canceled") &&
|
||||||
indexAttempt.error_msg && (
|
indexAttempt.error_msg && (
|
||||||
<Text className="flex flex-wrap whitespace-normal">
|
<Text className="flex flex-wrap whitespace-normal">
|
||||||
{indexAttempt.error_msg}
|
{indexAttempt.error_msg}
|
||||||
|
@@ -52,7 +52,7 @@ export function IndexAttemptStatus({
|
|||||||
popupContent={
|
popupContent={
|
||||||
<div className="w-64 p-2 break-words overflow-hidden whitespace-normal">
|
<div className="w-64 p-2 break-words overflow-hidden whitespace-normal">
|
||||||
The indexing attempt completed, but some errors were encountered
|
The indexing attempt completed, but some errors were encountered
|
||||||
during the rrun.
|
during the run.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Click View Errors for more details.
|
Click View Errors for more details.
|
||||||
@@ -78,6 +78,12 @@ export function IndexAttemptStatus({
|
|||||||
Scheduled
|
Scheduled
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
|
} else if (status === "canceled") {
|
||||||
|
badge = (
|
||||||
|
<Badge variant="canceled" icon={FiClock}>
|
||||||
|
Canceled
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
badge = (
|
badge = (
|
||||||
<Badge variant="outline" icon={FiMinus}>
|
<Badge variant="outline" icon={FiMinus}>
|
||||||
|
@@ -8,6 +8,8 @@ const badgeVariants = cva(
|
|||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
|
canceled:
|
||||||
|
"border-gray-200 bg-gray-50 text-gray-600 hover:bg-gray-75 dark:bg-gray-900 dark:text-neutral-50 dark:hover:bg-gray-850",
|
||||||
orange:
|
orange:
|
||||||
"border-orange-200 bg-orange-50 text-orange-600 hover:bg-orange-75 dark:bg-orange-900 dark:text-neutral-50 dark:hover:bg-orange-850",
|
"border-orange-200 bg-orange-50 text-orange-600 hover:bg-orange-75 dark:bg-orange-900 dark:text-neutral-50 dark:hover:bg-orange-850",
|
||||||
paused:
|
paused:
|
||||||
|
@@ -72,6 +72,7 @@ export type ValidInputTypes = "load_state" | "poll" | "event";
|
|||||||
export type ValidStatuses =
|
export type ValidStatuses =
|
||||||
| "success"
|
| "success"
|
||||||
| "completed_with_errors"
|
| "completed_with_errors"
|
||||||
|
| "canceled"
|
||||||
| "failed"
|
| "failed"
|
||||||
| "in_progress"
|
| "in_progress"
|
||||||
| "not_started";
|
| "not_started";
|
||||||
|
Reference in New Issue
Block a user