{"record":{"id":"81843eb104f6aee9","repo":"dotnet/orleans","slug":"data-too-large-to-write-to-table-size-0-maxsize","errorCode":null,"errorMessage":"Data too large to write to table. Size={0} MaxSize={1}","messagePattern":"Data too large to write to table\\. Size=(.+?) MaxSize=(.+?)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Transactions.AzureStorage/TransactionalState/StateEntity.cs","lineNumber":156,"sourceCode":"                            yield return data;\n                        }\n                    }\n                }\n            }\n        }\n\n        private object? GetPropertyOrDefault(string key)\n        {\n            this.Entity.TryGetValue(key, out var result);\n            return result;\n        }\n\n        private static void CheckMaxDataSize(int dataSize, int maxDataSize)\n        {\n            if (dataSize > maxDataSize)\n            {\n                var msg = string.Format(\"Data too large to write to table. Size={0} MaxSize={1}\", dataSize, maxDataSize);\n                throw new ArgumentOutOfRangeException(\"state\", msg);\n            }\n        }\n\n        private static IEnumerable<string> GetPropertyNames()\n        {\n            yield return STRING_DATA_PROPERTY_NAME_PREFIX;\n            for (var i = 1; i < MAX_DATA_CHUNKS_COUNT; ++i)\n            {\n                yield return STRING_DATA_PROPERTY_NAME_PREFIX + i.ToString(CultureInfo.InvariantCulture);\n            }\n        }\n    }\n}\n","sourceCodeStart":138,"sourceCodeEnd":170,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Transactions.AzureStorage/TransactionalState/StateEntity.cs#L138-L170","documentation":"Thrown by StateEntity.CheckMaxDataSize when the serialized transactional state exceeds the maximum permitted size for a single table entity (and its chunked string-data properties). Azure Table entities are limited; Orleans chunks the payload but caps total size.","triggerScenarios":"A grain's TState grows large enough that its serialized form plus chunking overhead exceeds maxDataSize at write time.","commonSituations":"Unbounded collections stored in transactional grain state; large blobs embedded in state; a grain accumulating history without compaction.","solutions":["Reduce the size of the grain state: prune collections, archive large fields to Blob Storage and store only a reference.","Split the grain so each activation holds less state.","Move large payloads out of transactional state into non-transactional storage keyed by grain id."],"exampleFix":"// before\npublic class CartState { public List<Item> Items = new(); } // grows unbounded\n\n// after\npublic class CartState { public int ItemCount; public string BlobRef; } // items archived to blob","handlingStrategy":"validation","validationCode":"if (serializedState.Length > MaxStateSize) throw new InvalidOperationException(\"grain state too large; archive to blob\");","typeGuard":null,"tryCatchPattern":"try { await storage.Store(...); }\ncatch (ArgumentOutOfRangeException ex) when (ex.Message.Contains(\"Data too large\"))\n{ /* archive payload, store reference, retry */ }","preventionTips":["Bound collections stored in transactional grain state.","Move large payloads to Blob Storage and keep only references in state."],"tags":["transactions","azure-table","size-limit","azure"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}