[{"data":1,"prerenderedAt":818},["ShallowReactive",2],{"navigation_docs":3,"-serverless-timeouts-and-retries":134,"-serverless-timeouts-and-retries-surround":813},[4,26,52,88,114],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":25},"Getting Started","i-lucide-rocket","\u002Fgetting-started","1.getting-started",[10,15,20],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-sparkles",{"title":16,"path":17,"stem":18,"icon":19},"Quickstart","\u002Fgetting-started\u002Fquickstart","1.getting-started\u002F2.quickstart","i-lucide-play",{"title":21,"path":22,"stem":23,"icon":24},"Architecture & State","\u002Fgetting-started\u002Farchitecture","1.getting-started\u002F3.architecture","i-lucide-cpu",false,{"title":27,"icon":28,"path":29,"stem":30,"children":31,"page":25},"Serverless & Edge","i-lucide-zap","\u002Fserverless","2.serverless",[32,37,42,47],{"title":33,"path":34,"stem":35,"icon":36},"Serverless Architecture","\u002Fserverless\u002Foverview","2.serverless\u002F1.overview","i-lucide-globe",{"title":38,"path":39,"stem":40,"icon":41},"Minimal Client","\u002Fserverless\u002Fminimal-client","2.serverless\u002F2.minimal-client","i-lucide-code",{"title":43,"path":44,"stem":45,"icon":46},"Execution Modes","\u002Fserverless\u002Fexecution-modes","2.serverless\u002F3.execution-modes","i-lucide-list-tree",{"title":48,"path":49,"stem":50,"icon":51},"Timeouts & Retries","\u002Fserverless\u002Ftimeouts-and-retries","2.serverless\u002F4.timeouts-and-retries","i-lucide-alert-triangle",{"title":53,"icon":54,"path":55,"stem":56,"children":57,"page":25},"API Reference","i-lucide-terminal","\u002Fapi-reference","3.api-reference",[58,63,68,73,78,83],{"title":59,"path":60,"stem":61,"icon":62},"Protocol & Authentication","\u002Fapi-reference\u002Foverview","3.api-reference\u002F1.overview","i-lucide-key",{"title":64,"path":65,"stem":66,"icon":67},"Queries","\u002Fapi-reference\u002Fqueries","3.api-reference\u002F2.queries","i-lucide-database",{"title":69,"path":70,"stem":71,"icon":72},"Transactions","\u002Fapi-reference\u002Ftransactions","3.api-reference\u002F3.transactions","i-lucide-layers",{"title":74,"path":75,"stem":76,"icon":77},"Administration","\u002Fapi-reference\u002Fadministration","3.api-reference\u002F4.administration","i-lucide-settings",{"title":79,"path":80,"stem":81,"icon":82},"Scopes & Permissions","\u002Fapi-reference\u002Fscopes-permissions","3.api-reference\u002F5.scopes-permissions","i-lucide-shield",{"title":84,"path":85,"stem":86,"icon":87},"Errors & Diagnostics","\u002Fapi-reference\u002Ferrors","3.api-reference\u002F6.errors","i-lucide-alert-circle",{"title":89,"icon":90,"path":91,"stem":92,"children":93,"page":25},"Configuration","i-lucide-sliders","\u002Fconfiguration","4.configuration",[94,99,104,109],{"title":95,"path":96,"stem":97,"icon":98},"Gateway YAML","\u002Fconfiguration\u002Fgateway-yaml","4.configuration\u002F1.gateway-yaml","i-lucide-file-code",{"title":100,"path":101,"stem":102,"icon":103},"Connection Pools","\u002Fconfiguration\u002Fconnection-pools","4.configuration\u002F2.connection-pools","i-lucide-activity",{"title":105,"path":106,"stem":107,"icon":108},"Analytics & Observability","\u002Fconfiguration\u002Fanalytics","4.configuration\u002F3.analytics","i-lucide-bar-chart",{"title":110,"path":111,"stem":112,"icon":113},"Runtime Files & State","\u002Fconfiguration\u002Fruntime-files","4.configuration\u002F4.runtime-files","i-lucide-folder",{"title":115,"icon":116,"path":117,"stem":118,"children":119,"page":25},"Operations & Security","i-lucide-shield-check","\u002Foperations","5.operations",[120,125,129],{"title":121,"path":122,"stem":123,"icon":124},"Production Deployment","\u002Foperations\u002Fdeployment","5.operations\u002F1.deployment","i-lucide-server",{"title":126,"path":127,"stem":128,"icon":116},"Security Hardening","\u002Foperations\u002Fsecurity","5.operations\u002F2.security",{"title":130,"path":131,"stem":132,"icon":133},"Development & Contributing","\u002Foperations\u002Fdevelopment","5.operations\u002F3.development","i-lucide-code-2",{"id":135,"title":48,"body":136,"description":804,"extension":805,"links":806,"meta":807,"navigation":808,"path":49,"seo":809,"stem":50,"__hash__":812},"docs\u002F2.serverless\u002F4.timeouts-and-retries.md",{"type":137,"value":138,"toc":790},"minimark",[139,144,153,156,161,164,255,260,271,273,277,280,291,295,298,337,340,357,359,363,515,530,532,539,549,665,669,705,707,711,714,786],[140,141,143],"h1",{"id":142},"timeouts-deadlines-safe-retries","Timeouts, Deadlines & Safe Retries",[145,146,147,148,152],"p",{},"Connecting stateless serverless functions to relational databases over HTTP requires careful handling of network interruptions. A failed HTTP request does ",[149,150,151],"strong",{},"not"," guarantee that PostgreSQL aborted the statement.",[154,155],"hr",{},[157,158,160],"h2",{"id":159},"the-timeout-hierarchy","The Timeout Hierarchy",[145,162,163],{},"Multiple independent timeouts govern a single query request. Always size outer timeouts slightly larger than inner timeouts:",[165,166,171],"pre",{"className":167,"code":168,"language":169,"meta":170,"style":170},"language-mermaid shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","flowchart TD\n  T1[\"Client Platform Timeout (40s - 60s)\"]\n  T2[\"Client fetch() AbortController (36s)\"]\n  T3[\"Reverse Proxy \u002F Ingress Timeout (38s)\"]\n  T4[\"Gateway Response Deadline (35s)\"]\n  T5[\"Pool Checkout Timeout (10s)\"]\n  T6[\"PostgreSQL statement_timeout (30s)\"]\n\n  T1 --> T2\n  T2 --> T3\n  T3 --> T4\n  T4 --> T5\n  T4 --> T6\n","mermaid","",[172,173,174,182,188,194,200,206,212,218,225,231,237,243,249],"code",{"__ignoreMap":170},[175,176,179],"span",{"class":177,"line":178},"line",1,[175,180,181],{},"flowchart TD\n",[175,183,185],{"class":177,"line":184},2,[175,186,187],{},"  T1[\"Client Platform Timeout (40s - 60s)\"]\n",[175,189,191],{"class":177,"line":190},3,[175,192,193],{},"  T2[\"Client fetch() AbortController (36s)\"]\n",[175,195,197],{"class":177,"line":196},4,[175,198,199],{},"  T3[\"Reverse Proxy \u002F Ingress Timeout (38s)\"]\n",[175,201,203],{"class":177,"line":202},5,[175,204,205],{},"  T4[\"Gateway Response Deadline (35s)\"]\n",[175,207,209],{"class":177,"line":208},6,[175,210,211],{},"  T5[\"Pool Checkout Timeout (10s)\"]\n",[175,213,215],{"class":177,"line":214},7,[175,216,217],{},"  T6[\"PostgreSQL statement_timeout (30s)\"]\n",[175,219,221],{"class":177,"line":220},8,[175,222,224],{"emptyLinePlaceholder":223},true,"\n",[175,226,228],{"class":177,"line":227},9,[175,229,230],{},"  T1 --> T2\n",[175,232,234],{"class":177,"line":233},10,[175,235,236],{},"  T2 --> T3\n",[175,238,240],{"class":177,"line":239},11,[175,241,242],{},"  T3 --> T4\n",[175,244,246],{"class":177,"line":245},12,[175,247,248],{},"  T4 --> T5\n",[175,250,252],{"class":177,"line":251},13,[175,253,254],{},"  T4 --> T6\n",[256,257,259],"h3",{"id":258},"why-timeouts-must-be-staggered","Why Timeouts Must Be Staggered",[145,261,262,263,266,267,270],{},"If your client ",[172,264,265],{},"fetch()"," timeout is 30 seconds, but the gateway's PostgreSQL statement timeout is 30 seconds, a client-side abort will trigger before the gateway can receive PostgreSQL's response and construct a clean error envelope. Setting the client timeout to ",[149,268,269],{},"36 seconds"," allows the gateway's 35-second deadline to return a structured error response with actionable diagnostic codes.",[154,272],{},[157,274,276],{"id":275},"the-danger-of-outcome-unknown","The Danger of \"Outcome Unknown\"",[145,278,279],{},"When an HTTP client aborts a request, or if a network disconnect occurs while a query is running:",[281,282,283,286,287,290],"warning",{},[149,284,285],{},"Aborting an HTTP request does NOT automatically cancel the server-side PostgreSQL statement.","\nPostgreSQL may continue executing the query and commit the write. Blindly retrying the request can result in ",[149,288,289],{},"duplicate inserts, double charges, or corrupt state",".",[256,292,294],{"id":293},"identifying-unknown-outcomes","Identifying Unknown Outcomes",[145,296,297],{},"The gateway explicitly surfaces when an outcome cannot be confirmed:",[299,300,301,323],"ul",{},[302,303,304,307,308,311,312,315,316,319,320,290],"li",{},[149,305,306],{},"Immediate Queries:"," Returns HTTP ",[172,309,310],{},"500"," with code ",[172,313,314],{},"QUERY_OUTCOME_UNKNOWN",". The underlying cause (such as ",[172,317,318],{},"EXECUTION_DEADLINE_EXCEEDED"," or client disconnect) is provided in ",[172,321,322],{},"error.cause",[302,324,325,328,329,332,333,336],{},[149,326,327],{},"Transactions:"," A status of ",[172,330,331],{},"\"unknown\""," indicates that ",[172,334,335],{},"COMMIT"," was issued to PostgreSQL, but the gateway lost connection before receiving the confirmation.",[145,338,339],{},"When encountering an unknown outcome:",[341,342,343,348,351,354],"ol",{},[302,344,345],{},[149,346,347],{},"Do NOT blindly retry the write.",[302,349,350],{},"Inspect application state (e.g., query by a natural unique identifier, idempotency token, or timestamp).",[302,352,353],{},"If the record already exists, treat the operation as successful.",[302,355,356],{},"If the record does not exist, safe retry can proceed.",[154,358],{},[157,360,362],{"id":361},"safe-retry-decision-tree","Safe Retry Decision Tree",[364,365,366,386],"table",{},[367,368,369],"thead",{},[370,371,372,377,380,383],"tr",{},[373,374,376],"th",{"align":375},"left","Returned Error Code",[373,378,379],{"align":375},"Phase",[373,381,382],{"align":375},"Safe to Retry?",[373,384,385],{"align":375},"Reason",[387,388,389,409,425,444,462,480,498],"tbody",{},[370,390,391,398,401,406],{},[392,393,394,397],"td",{"align":375},[172,395,396],{},"QUERY_POOL_BUSY"," (503)",[392,399,400],{"align":375},"Pre-dispatch",[392,402,403],{"align":375},[149,404,405],{},"Yes",[392,407,408],{"align":375},"Connection was never acquired; SQL never sent",[370,410,411,416,418,422],{},[392,412,413,397],{"align":375},[172,414,415],{},"QUERY_CONNECTION_LIMIT",[392,417,400],{"align":375},[392,419,420],{"align":375},[149,421,405],{},[392,423,424],{"align":375},"Global connection limit reached; SQL never sent",[370,426,427,433,436,441],{},[392,428,429,432],{"align":375},[172,430,431],{},"INVALID_QUERY_TYPE"," (400)",[392,434,435],{"align":375},"Validation",[392,437,438],{"align":375},[149,439,440],{},"No",[392,442,443],{"align":375},"Schema error; fix client request",[370,445,446,452,455,459],{},[392,447,448,451],{"align":375},[172,449,450],{},"INSUFFICIENT_PRIVILEGE"," (403)",[392,453,454],{"align":375},"PostgreSQL",[392,456,457],{"align":375},[149,458,440],{},[392,460,461],{"align":375},"Key lacks database\u002Ftable permissions",[370,463,464,469,472,477],{},[392,465,466,468],{"align":375},[172,467,314],{}," (500)",[392,470,471],{"align":375},"Post-dispatch",[392,473,474],{"align":375},[149,475,476],{},"Conditional",[392,478,479],{"align":375},"Check application state first before retrying",[370,481,482,489,492,496],{},[392,483,484,485,488],{"align":375},"Transaction ",[172,486,487],{},"unknown"," status",[392,490,491],{"align":375},"Commit phase",[392,493,494],{"align":375},[149,495,476],{},[392,497,479],{"align":375},[370,499,500,506,508,512],{},[392,501,502,505],{"align":375},[172,503,504],{},"IDEMPOTENCY_KEY_CONFLICT"," (409)",[392,507,400],{"align":375},[392,509,510],{"align":375},[149,511,440],{},[392,513,514],{"align":375},"Reusing the same key with different SQL",[516,517,518,521,522,525,526,529],"caution",{},[149,519,520],{},"Disable automatic POST retries"," in reverse proxies (such as Nginx, Envoy, AWS ALB) and HTTP client libraries (such as Axios, got, or Cloudflare Workers ",[172,523,524],{},"cf.cacheTtl","). Automatic retries should only apply to idempotent ",[172,527,528],{},"GET"," requests.",[154,531],{},[157,533,535,536],{"id":534},"idempotent-writes-with-idempotency-key","Idempotent Writes with ",[172,537,538],{},"Idempotency-Key",[145,540,541,542,545,546,548],{},"For multi-statement write transactions (",[172,543,544],{},"POST \u002Ftransaction\u002Fexecute","), always include a unique ",[172,547,538],{}," header:",[165,550,554],{"className":551,"code":552,"language":553,"meta":170,"style":170},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","curl -X POST http:\u002F\u002Flocalhost:8080\u002Ftransaction\u002Fexecute \\\n  -H 'x-api-key: \u003Capi-key>' \\\n  -H 'x-database: billing' \\\n  -H 'Idempotency-Key: ord_checkout_9182374' \\\n  -H 'content-type: application\u002Fjson' \\\n  -d '{\n    \"queries\": [\n      {\"query\": \"INSERT INTO orders (id, total) VALUES ($1, $2)\", \"parameters\": [\"ord_checkout_9182374\", 49.99]}\n    ]\n  }'\n","bash",[172,555,556,576,593,606,619,632,642,647,652,657],{"__ignoreMap":170},[175,557,558,562,566,569,572],{"class":177,"line":178},[175,559,561],{"class":560},"sBMFI","curl",[175,563,565],{"class":564},"sfazB"," -X",[175,567,568],{"class":564}," POST",[175,570,571],{"class":564}," http:\u002F\u002Flocalhost:8080\u002Ftransaction\u002Fexecute",[175,573,575],{"class":574},"sTEyZ"," \\\n",[175,577,578,581,585,588,591],{"class":177,"line":184},[175,579,580],{"class":564},"  -H",[175,582,584],{"class":583},"sMK4o"," '",[175,586,587],{"class":564},"x-api-key: \u003Capi-key>",[175,589,590],{"class":583},"'",[175,592,575],{"class":574},[175,594,595,597,599,602,604],{"class":177,"line":190},[175,596,580],{"class":564},[175,598,584],{"class":583},[175,600,601],{"class":564},"x-database: billing",[175,603,590],{"class":583},[175,605,575],{"class":574},[175,607,608,610,612,615,617],{"class":177,"line":196},[175,609,580],{"class":564},[175,611,584],{"class":583},[175,613,614],{"class":564},"Idempotency-Key: ord_checkout_9182374",[175,616,590],{"class":583},[175,618,575],{"class":574},[175,620,621,623,625,628,630],{"class":177,"line":202},[175,622,580],{"class":564},[175,624,584],{"class":583},[175,626,627],{"class":564},"content-type: application\u002Fjson",[175,629,590],{"class":583},[175,631,575],{"class":574},[175,633,634,637,639],{"class":177,"line":208},[175,635,636],{"class":564},"  -d",[175,638,584],{"class":583},[175,640,641],{"class":564},"{\n",[175,643,644],{"class":177,"line":214},[175,645,646],{"class":564},"    \"queries\": [\n",[175,648,649],{"class":177,"line":220},[175,650,651],{"class":564},"      {\"query\": \"INSERT INTO orders (id, total) VALUES ($1, $2)\", \"parameters\": [\"ord_checkout_9182374\", 49.99]}\n",[175,653,654],{"class":177,"line":227},[175,655,656],{"class":564},"    ]\n",[175,658,659,662],{"class":177,"line":233},[175,660,661],{"class":564},"  }",[175,663,664],{"class":583},"'\n",[256,666,668],{"id":667},"idempotency-mechanics","Idempotency Mechanics",[341,670,671,680,693],{},[302,672,673,676,677,290],{},[149,674,675],{},"First Submission:"," The gateway normalizes the SQL and parameters, computes a cryptographic fingerprint, and creates a record with status ",[172,678,679],{},"pending",[302,681,682,685,686,688,689,692],{},[149,683,684],{},"Replay on Network Drop:"," If the client loses connection and resubmits the exact same request with the same ",[172,687,538],{},", the gateway detects the match and returns ",[172,690,691],{},"200 OK"," with the existing transaction status without re-executing the statements.",[302,694,695,698,699,701,702,290],{},[149,696,697],{},"Conflict Detection:"," If the client reuses an ",[172,700,538],{}," with different SQL or parameters, the gateway rejects it immediately with ",[172,703,704],{},"409 IDEMPOTENCY_KEY_CONFLICT",[154,706],{},[157,708,710],{"id":709},"serverless-production-checklist","Serverless Production Checklist",[145,712,713],{},"Before rolling out serverless functions to production, verify each item:",[299,715,718,727,740,746,752,758,768,777],{"className":716},[717],"contains-task-list",[302,719,722,726],{"className":720},[721],"task-list-item",[723,724],"input",{"disabled":223,"type":725},"checkbox"," Function invocation timeout is comfortably larger than 36 seconds.",[302,728,730,732,733,735,736,739],{"className":729},[721],[723,731],{"disabled":223,"type":725}," Client ",[172,734,265],{}," uses an ",[172,737,738],{},"AbortController"," set to 36 seconds.",[302,741,743,745],{"className":742},[721],[723,744],{"disabled":223,"type":725}," Reverse proxies and HTTP clients have automatic POST retries disabled.",[302,747,749,751],{"className":748},[721],[723,750],{"disabled":223,"type":725}," Gateway base URL, database name, and API keys are stored in encrypted secret managers.",[302,753,755,757],{"className":754},[721],[723,756],{"disabled":223,"type":725}," Scoped API keys are restricted to specific tables and CRUD operations.",[302,759,761,763,764,767],{"className":760},[721],[723,762],{"disabled":223,"type":725}," All dynamic query values use ",[172,765,766],{},"$1, $2"," parameters rather than string concatenation.",[302,769,771,773,774,776],{"className":770},[721],[723,772],{"disabled":223,"type":725}," Batch write transactions provide stable ",[172,775,538],{}," headers.",[302,778,780,782,783,785],{"className":779},[721],[723,781],{"disabled":223,"type":725}," Application logic reconciles ",[172,784,314],{}," before triggering manual retries.",[787,788,789],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}",{"title":170,"searchDepth":184,"depth":184,"links":791},[792,795,798,799,803],{"id":159,"depth":184,"text":160,"children":793},[794],{"id":258,"depth":190,"text":259},{"id":275,"depth":184,"text":276,"children":796},[797],{"id":293,"depth":190,"text":294},{"id":361,"depth":184,"text":362},{"id":534,"depth":184,"text":800,"children":801},"Idempotent Writes with Idempotency-Key",[802],{"id":667,"depth":190,"text":668},{"id":709,"depth":184,"text":710},"How to safely handle deadlines, cancellations, unknown outcomes, and retries in serverless architectures.","md",null,{},{"icon":51},{"title":810,"description":811},"Timeouts & Retries · HTTP PostgreSQL Gateway","Critical guidelines for handling timeouts, QUERY_OUTCOME_UNKNOWN, transaction uncertainty, and preventing duplicate database mutations.","qw45y_58y7TWECxXkazAjKVea5tFHD1rzaOXUZjxpI8",[814,816],{"title":43,"path":44,"stem":45,"description":815,"icon":46,"children":-1},"Choose the right execution mode for your serverless and edge workloads.",{"title":59,"path":60,"stem":61,"description":817,"icon":62,"children":-1},"Base URL, authentication headers, request formatting, and serialization options.",1795399273837]