Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Conversation

@louis-jan
Copy link
Contributor

@louis-jan louis-jan commented Feb 11, 2024

Description

chunked_content_provider lambda race condition issue when:

  • T1: R1 start -> create run loop lambda and request completion.
    streaming = true | serial queue busy = true.
  • T2: R1 done ->
    streaming = false | serial queue busy = false | stop = true (cancel completion request)
  • T3: R1 run loop still run ->
    recreate request completion for a completed request? -> zombie request (sus memory leak?).
  • T2: R1 completion request cancelled, R2 come -> llama.next_result error -> jump in a loop, R1 back to run loop and create new request completion ->
  • T1.5: lost connection -> R1 cancel request in progress -> R2 come & create completion -> single_queue_is_busy true, next_result error -> jump in a loop R3 come, stuck.
  1. Its better to not create completion request within lambda, should create before triggering (serially). Apply a serial queue to handle this. Can be easily replaced by Concurrent Queue with workers number = n_parallel later.

This is to make it safer by not triggering 2 lambda functions at the same time and to reduce the state complexity.

  1. Embedding request has not handled single_queue_is_busy well, line 456 and 466.
  2. Check model loaded failed but still proceed for chat/completion.

Next action:

  • Replace Serial Queue = Concurrent Queue with workers number = n_parallel
  • Wrap embedding request handler within the shared queue

Issues

@louis-jan louis-jan requested a review from tikikun February 11, 2024 13:56
@louis-jan louis-jan force-pushed the fix/lambda-race-condition-infinite-waiting branch 7 times, most recently from 8002228 to 59c1947 Compare February 12, 2024 04:04
@louis-jan louis-jan force-pushed the fix/lambda-race-condition-infinite-waiting branch from 59c1947 to c995887 Compare February 12, 2024 04:26
Copy link
Contributor

@tikikun tikikun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tikikun tikikun merged commit 9de123f into main Feb 12, 2024
@louis-jan louis-jan deleted the fix/lambda-race-condition-infinite-waiting branch February 15, 2024 09:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants