{"record":{"id":"f9229501350be8b1","repo":"microsoft/FASTER","slug":"path-filename-is-too-long","errorCode":null,"errorMessage":"Path {filename} is too long","messagePattern":"Path (.+?) is too long","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Device/LocalStorageDevice.cs","lineNumber":111,"sourceCode":"        /// <param name=\"initialLogFileHandles\">Optional set of preloaded safe file handles, which can speed up hydration of preexisting log file handles</param>\n        /// <param name=\"useIoCompletionPort\">Whether we use IO completion port with polling</param>\n        protected internal LocalStorageDevice(string filename,\n                                      bool preallocateFile = false,\n                                      bool deleteOnClose = false,\n                                      bool disableFileBuffering = true,\n                                      long capacity = Devices.CAPACITY_UNSPECIFIED,\n                                      bool recoverDevice = false,\n                                      IEnumerable<KeyValuePair<int, SafeFileHandle>> initialLogFileHandles = null,\n                                      bool useIoCompletionPort = true)\n                : base(filename, GetSectorSize(filename), capacity)\n        {\n            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))\n            {\n                throw new FasterException(\"Cannot use LocalStorageDevice from non-Windows OS platform, use ManagedLocalStorageDevice instead.\");\n            }\n\n            if (filename.Length > Native32.WIN32_MAX_PATH - 11)     // -11 to allow for \".<segment>\"\n                throw new FasterException($\"Path {filename} is too long\");\n\n            ThrottleLimit = 120;\n            this.useIoCompletionPort = useIoCompletionPort;\n            this._disposed = false;\n\n            if (useIoCompletionPort)\n            {\n                ThreadPool.GetMaxThreads(out int workerThreads, out _);\n                ioCompletionPort = Native32.CreateIoCompletionPort(new SafeFileHandle(new IntPtr(-1), false), IntPtr.Zero, UIntPtr.Zero, (uint)(workerThreads + NumCompletionThreads));\n                for (int i = 0; i < NumCompletionThreads; i++)\n                {\n                    var thread = new Thread(() => new LocalStorageDeviceCompletionWorker().Start(ioCompletionPort, _callback))\n                    {\n                        IsBackground = true\n                    };\n                    thread.Start();\n                }\n            }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Device/LocalStorageDevice.cs#L93-L129","documentation":"LocalStorageDevice on Windows opens files with Win32 APIs subject to MAX_PATH limits. Because segment ids append a \".<segment>\" suffix to the filename, the constructor reserves 11 characters and rejects any filename longer than Native32.WIN32_MAX_PATH - 11.","triggerScenarios":"new LocalStorageDevice(path, ...) where path.Length > Native32.WIN32_MAX_PATH - 11 (i.e., roughly > 249 characters on Windows).","commonSituations":"Deeply nested checkpoint/log directories in long Windows paths; user-profile-relative paths on corporate machines; building segment filenames with long prefixes.","solutions":["Shorten the base path/filename so the full path (plus segment suffix) stays under the MAX_PATH budget.","Move the log/checkpoint directory closer to the drive root (e.g., C:\\data\\).","Enable Windows long-path support (registry LongPathsEnabled + manifest longPathAware) if your build and target framework support it.","Use a junction/subst drive to map a long directory chain to a short drive letter."],"exampleFix":"// before\nvar device = new LocalStorageDevice(@\"C:\\Users\\alice\\AppData\\Local\\MyVeryLongApplicationName\\Checkpoints\\HybridLog\");\n// after\nvar device = new LocalStorageDevice(@\"C:\\data\\faster\\hlog\"); // short base path; segment suffix still fits under MAX_PATH","handlingStrategy":"validation","validationCode":"const int MaxPath = 260; if (path.Length > MaxPath - 11) throw new ArgumentException($\"Path too long: {path.Length} chars; max {MaxPath - 11} to allow segment suffix\");","typeGuard":null,"tryCatchPattern":"try { device = new LocalStorageDevice(path); } catch (FasterException e) when (e.Message.Contains(\"too long\")) { log.LogError(e, \"Log path exceeds MAX_PATH budget\"); }","preventionTips":["Keep FASTER log directories short and near the drive root.","Budget 11 extra chars for the '.<segment>' suffix when composing paths.","Enable Windows long-path support or use subst drives for deep trees."],"tags":["windows","path-length","storage-device","filesystem"],"backgroundTag":"invalid-argument-format","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"}