{"record":{"id":"f3e9c09a839b6eb6","repo":"microsoft/FASTER","slug":"failed-to-schedule-work","errorCode":null,"errorMessage":"Failed to schedule work: ","messagePattern":"Failed to schedule work: ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cc/src/environment/file_windows.cc","lineNumber":184,"sourceCode":"  ::CloseThreadpool(pool_);\n\n  delete callback_environment_;\n}\n\nStatus WindowsPtpThreadPool::Schedule(Task task, void* task_parameters) {\n  auto info = alloc_context<TaskInfo>(sizeof(TaskInfo));\n  if(!info.get()) return Status::OutOfMemory;\n  new(info.get()) TaskInfo();\n\n  info->task = task;\n  info->task_parameters = task_parameters;\n\n  PTP_WORK_CALLBACK ptp_callback = TaskStartSpringboard;\n  PTP_WORK work = CreateThreadpoolWork(ptp_callback, info.get(), callback_environment_);\n  if(!work) {\n    std::stringstream ss;\n    ss << \"Failed to schedule work: \" << FormatWin32AndHRESULT(::GetLastError());\n    fprintf(stderr, \"%s\\n\", ss.str().c_str());\n    return Status::Aborted;\n  }\n  SubmitThreadpoolWork(work);\n  info.release();\n\n  return Status::Ok;\n}\n\nvoid CALLBACK WindowsPtpThreadPool::TaskStartSpringboard(PTP_CALLBACK_INSTANCE instance,\n    PVOID parameter, PTP_WORK work) {\n  auto info = make_context_unique_ptr<TaskInfo>(reinterpret_cast<TaskInfo*>(parameter));\n  info->task(info->task_parameters);\n  CloseThreadpoolWork(work);\n}\n\nStatus ThreadPoolFile::Open(FileCreateDisposition create_disposition, const FileOptions& options,\n                            ThreadPoolIoHandler* handler, bool* exists) {\n  DWORD flags = FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_OVERLAPPED;","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cc/src/environment/file_windows.cc#L166-L202","documentation":"On Windows, WindowsPtpThreadPool::Schedule wraps a task with CreateThreadpoolWork to submit it to the thread pool. If that Win32 call fails, the error is formatted (with GetLastError) and printed as 'Failed to schedule work: ...' and Status::Aborted is returned to the caller.","triggerScenarios":"Calling faster K/V operations that schedule background work (checkpoint, recovery, I/O callbacks) when CreateThreadpoolWork returns NULL — typically due to Win32 resource exhaustion or an invalid callback environment.","commonSituations":"Systems under heavy thread/handle exhaustion, running on constrained Windows environments, misconfigured callback environments after initialization issues.","solutions":["Read the appended FormatWin32AndHRESULT text on stderr to identify the underlying Win32 error","Check system resource availability (handles, memory, thread pool limits)","Retry the operation; if persistent, restart the process and re-initialize FASTER","Verify the process is a supported Windows build and the thread pool environment was created correctly"],"exampleFix":"// before\nauto s = kv.ScheduleBackgroundWork(...); // assumes Ok\n// after\nStatus s = kv.Checkpoint(...);\nif (s != Status::Ok) { /* handle scheduling failure, retry */ }","handlingStrategy":"retry","validationCode":"null","typeGuard":null,"tryCatchPattern":"Status s = op();\nif (s == Status::Aborted) {\n  // inspect stderr 'Failed to schedule work: <win32 error>'\n  // wait briefly and retry, or fail the request\n}","preventionTips":["Monitor Windows handle/thread-pool resource usage","Always check returned Status instead of assuming Ok","Keep FASTER initialization on supported Windows builds"],"tags":["windows","threadpool","win32","scheduling"],"backgroundTag":"thread-interrupted","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}