fix: harden document pipeline concurrency and diagnostics
- docreader: serialize all pdfium access behind a global lock. pypdfium2 is process-global and not thread-safe, so concurrent PDF uploads could corrupt its shared state and deadlock the whole process (requests stuck in "Parsing document" forever). Non-PDF parsers still run concurrently. - logger: strip ANSI color escapes from file logs so on-disk logs stay plain text while stdout keeps terminal colors. - storage: log baseDir/resolvedPath on file-open failure and when the multimodal service resolves a file service, so a LOCAL_STORAGE_BASE_DIR mismatch between writer and reader is immediately visible. - docker: set TZ (default Asia/Shanghai) for the docreader container.
This commit is contained in:
@@ -120,7 +120,10 @@ func (s *localFileService) GetFile(ctx context.Context, filePath string) (io.Rea
|
||||
|
||||
file, err := os.Open(resolved)
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "Failed to open file: %v", err)
|
||||
// baseDir/resolved are logged so a storage base-dir mismatch (e.g.
|
||||
// writer and reader started with different LOCAL_STORAGE_BASE_DIR)
|
||||
// is immediately visible instead of just "no such file or directory".
|
||||
logger.Errorf(ctx, "Failed to open file: baseDir=%s resolvedPath=%s err=%v", s.baseDir, resolved, err)
|
||||
return nil, fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -510,6 +510,8 @@ func (s *ImageMultimodalService) resolveFileServiceForPayload(ctx context.Contex
|
||||
}
|
||||
|
||||
baseDir := strings.TrimSpace(os.Getenv("LOCAL_STORAGE_BASE_DIR"))
|
||||
logger.Infof(ctx, "[ImageMultimodal] resolving file service: tenant=%d provider=%q LOCAL_STORAGE_BASE_DIR=%q imageURL=%s",
|
||||
payload.TenantID, provider, baseDir, payload.ImageURL)
|
||||
fileSvc, _, svcErr := filesvc.NewFileServiceFromStorageConfig(provider, tenant.StorageEngineConfig, baseDir)
|
||||
if svcErr != nil {
|
||||
logger.Warnf(ctx, "[ImageMultimodal] resolve file service failed (falling back to default): tenant=%d provider=%s err=%v",
|
||||
|
||||
Reference in New Issue
Block a user