diff --git a/seaweed-block/.github/pull_request_template.md b/seaweed-block/.github/pull_request_template.md index 61589136cc..f8bd94d181 100644 --- a/seaweed-block/.github/pull_request_template.md +++ b/seaweed-block/.github/pull_request_template.md @@ -3,6 +3,7 @@ Machine/INV: / Model: Red-first: Simplest: +Time bounds: Five questions, answered in plain words before review: Serves: diff --git a/seaweed-block/docs/releases/v1.1.md b/seaweed-block/docs/releases/v1.1.md index 1c8a8e5a73..687396b197 100644 --- a/seaweed-block/docs/releases/v1.1.md +++ b/seaweed-block/docs/releases/v1.1.md @@ -49,6 +49,20 @@ These notes collect v1.1's changes as they land; v1.1 is not released. snapshots of distinct data, a default pass takes longer than the old fixed 10 minutes; it now completes while it progresses. `--deadline` optionally bounds the whole pass. +## Fixed time bounds kept in v1.1 +Every fixed time bound in `core/` and `cmd/` is listed with its class in `docs/time-bounds.tsv`, which a test keeps in +step with the code. These totals stay fixed in v1.1: the work under each was measured at the 1 TiB cap, or runs only +on a path v1.1 refuses or ships as a preview. v1.2 replaces them with progress windows. +- `sw-block chunk usage` keeps one fixed total: at the 1 TiB cap usage took 8.45 s against its 60 s default. +- Restore's metadata create (`sw-block chunk restore`, `sw-block volume restore`) keeps its 6 minute default: it took + 0.42 s at the 1 TiB cap. Attaching the restored volume and filling its data are separate operations. +- Precopy detach keeps its fixed budgets; it is refused in v1.1. +- Replication catch-up, a preview in v1.1, sets one 5 s connection deadline around the whole catch-up stream, so a + long catch-up can time out. +- A HEAD read through a chunk store remote that does not bound its own HEAD steps (one that returns the full chunk + manifest; not the default) is bounded by one fixed 2 s total. The default segmented remote bounds each fetch, and a + whole read only by its caller's context. + ## Upgrade - With `--host-limit-dir` set, the limiter's `configuration.json` in that directory records the flags it was created with, and v1.1's differ. Upgrade such a host whole: stop every process using the directory, remove diff --git a/seaweed-block/docs/time-bounds.tsv b/seaweed-block/docs/time-bounds.tsv new file mode 100644 index 0000000000..8f480bc666 --- /dev/null +++ b/seaweed-block/docs/time-bounds.tsv @@ -0,0 +1,264 @@ +# Fixed time bounds in core/ and cmd/ (non-test code). Kept in step with the code by +# internal/timebound: every bound site has one row; line numbers refresh with TIME_BOUNDS_UPDATE=1. +# A new bound names its class and model row here. Classes: per-call, no-progress-window, +# availability-contract, control-timer, pending-fix (names its fix PR or the measurement owed; none at the v1.1 tag), +# ruled-total (a fixed total accepted for v1.1 by measurement at the cap, or on a refused path). +path func kind n line class model note +cmd/blockcsi/main.go run context.WithTimeout 1 214 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockmaster/main.go run context.WithTimeout 1 380 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 1 863 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 2 870 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 3 891 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 4 933 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 5 950 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 6 999 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 7 1017 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 8 1092 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 9 1112 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 10 1124 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 11 1160 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 12 1189 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 13 1270 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 14 1313 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 15 1379 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 16 1453 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go runVolume context.WithTimeout 17 1529 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/main.go waitFaultedDurableRecovery context.WithTimeout 1 1700 per-call NONE: no model row maps this file yet one shutdown or startup step +cmd/blockvolume/process_exit.go superviseProcess time.NewTimer 1 115 availability-contract NONE: no model row maps this file yet exit drain bounded by the workspace drain timeout +cmd/blockvolume/process_exit.go finishWorkspaceLease time.After 1 250 availability-contract NONE: no model row maps this file yet lease closeout on exit, bounded +cmd/blockvolume/ready_latch.go handleReadyAssignment context.WithTimeout 1 62 per-call NONE: no model row maps this file yet one RPC or request +cmd/blockvolume/snapshot_operation_shutdown.go stopSnapshotOperationsForShutdown context.WithTimeout 1 15 per-call SnapOps.Stall one RPC or request +cmd/sparrow/main.go shutdownServer context.WithTimeout 1 326 per-call NONE: no model row maps this file yet test-harness binary: one bounded step +cmd/sparrow/main.go waitForMode time.Now().Add 1 332 per-call NONE: no model row maps this file yet test-harness binary: one bounded wait +cmd/sparrow/s5_bootstrap.go runS5Bootstrap context.WithTimeout 1 54 per-call NONE: no model row maps this file yet test-harness binary: one bounded step +cmd/sparrow/s7_restart_smoke.go runS7RestartSmoke context.WithTimeout 1 69 per-call NONE: no model row maps this file yet test-harness binary: one bounded step +cmd/sparrow/s7_restart_smoke.go runS7RestartSmoke time.Now().Add 1 84 per-call NONE: no model row maps this file yet test-harness binary: one bounded wait +cmd/sw-block/chunk.go refuseUnlessSingleFilerWithin context.WithTimeout 1 68 per-call NONE: no model row maps this file yet the single-filer start check, bounded by --timeout and by its caller's pass +cmd/sw-block/chunk.go chunkPost time.Now().Add 1 153 pending-fix NONE: no model row maps this file yet CLI chunk POST observation deadline (manual cut and its waiters); fix #964 (poll by cut id) +cmd/sw-block/chunk.go chunkPostUntil context.WithDeadline 1 168 pending-fix NONE: no model row maps this file yet CLI manual-cut observation total; fix #964 (poll by cut id) +cmd/sw-block/chunk.go chunkSnapshot time.Now().Add 1 280 control-timer NONE: no model row maps this file yet snapshot expiry: a timestamp (validity, expiry or due time), not a wait +cmd/sw-block/chunk_b.go volumeFlags.ref context.WithTimeout 1 100 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/chunk_b.go bCommand.run context.WithTimeout 1 158 pending-fix NONE: no model row maps this file yet unmeasured: applies each catalog command's own budget (its newBCommand row); open while snapshot delete and retain are unmeasured +cmd/sw-block/chunk_b.go chunkSnapshots newBCommand 1 174 per-call NONE: no model row maps this file yet lists one volume's snapshot names from one HEAD read (30 s) +cmd/sw-block/chunk_b.go snapshotDeleteFormatLevel context.WithTimeout 1 215 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/chunk_b.go chunkSnapshotDelete newBCommand 1 250 pending-fix NONE: no model row maps this file yet unmeasured: a snapshot delete stages intents across the snapshot's chunks under 30 s; a measurement at the cap or a window is owed +cmd/sw-block/chunk_b.go chunkShowContext newBCommand 1 315 per-call NONE: no model row maps this file yet one volume record and one HEAD read (30 s) +cmd/sw-block/chunk_b.go chunkUsage newBCommand 1 346 ruled-total NONE: no model row maps this file yet docs/releases/v1.1.md: "at the 1 TiB cap usage took 8.45 s against its 60 s default" +cmd/sw-block/chunk_b.go chunkRestore newBCommand 1 360 ruled-total NONE: no model row maps this file yet docs/releases/v1.1.md: "it took 0.42 s at the 1 TiB cap" +cmd/sw-block/chunk_b.go chunkRestore context.WithTimeout 1 376 ruled-total NONE: no model row maps this file yet docs/releases/v1.1.md: "it took 0.42 s at the 1 TiB cap" +cmd/sw-block/chunk_b.go chunkRelease newBCommand 1 415 per-call NONE: no model row maps this file yet releases one restore target from its source (30 s) +cmd/sw-block/chunk_b.go chunkRetain newBCommand 1 472 pending-fix NONE: no model row maps this file yet unmeasured: retain retires expired snapshots under 5 min; a measurement at the cap or a window is owed +cmd/sw-block/chunk_diag.go diagWriter.close time.NewTimer 1 68 per-call NONE: no model row maps this file yet drain of one diagnostics writer on close +cmd/sw-block/chunk_loop.go chunkPostLoop time.Now().Add 1 75 pending-fix NONE: no model row maps this file yet CLI cut retry loop's one absolute end; fix #964 +cmd/sw-block/chunk_loop.go chunkStats context.WithDeadline 1 184 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/chunk_verify.go chunkVerify context.WithTimeoutCause 1 94 availability-contract NONE: no model row maps this file yet the operator's optional --deadline (off by default), an absolute total the operator chooses +cmd/sw-block/chunk_verify.go chunkVerify watchVerifyProgress 1 97 no-progress-window NONE: no model row maps this file yet verify's --timeout: the pass ends only after that long with no object read completed (each read renews it) +cmd/sw-block/chunk_volume_delete.go chunkVolumeDelete newBCommand 1 35 no-progress-window NONE: no model row maps this file yet growing command: no total; the budget is one sweep and the no-progress window +cmd/sw-block/chunk_volume_delete.go deleteVolumeWithProgress context.WithDeadline 1 150 no-progress-window NONE: no model row maps this file yet batch deadline min(now+bound, last progress+bound): renewed by sweep progress +cmd/sw-block/chunk_volume_delete.go deleteVolumeWithProgress time.NewTimer 1 203 control-timer NONE: no model row maps this file yet poll or delay timer +cmd/sw-block/cluster_format.go runClusterFormatLevel context.WithTimeout 1 75 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/cluster_format.go runClusterFinalizeFormat context.WithTimeout 1 158 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/cluster_format.go runClusterRetireHost context.WithTimeout 1 295 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/failover.go runOpsFailover context.WithTimeout 1 102 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/log_collect.go inspectionShell.collectLogs context.WithTimeout 1 197 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go runOpsStatus context.WithTimeout 1 904 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go runOpsInventory context.WithTimeout 1 961 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go loadObservationCluster context.WithTimeout 1 1091 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go loadObservationCluster context.WithTimeout 2 1102 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go enrichLiveObservationCluster context.WithTimeout 1 1144 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go applyCleanupSummaryProjection context.WithTimeout 1 1169 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go runOpsReport context.WithTimeout 1 1448 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go runOpsReport context.WithTimeout 2 1459 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go runOpsDashboard http.Server.ReadHeaderTimeout 1 1568 per-call NONE: no model row maps this file yet one HTTP request or connection +cmd/sw-block/main.go runOpsDashboard time.NewTimer 1 1583 control-timer NONE: no model row maps this file yet poll or delay timer +cmd/sw-block/main.go runOpsDashboard context.WithTimeout 1 1593 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go loadDashboardCluster context.WithTimeout 1 1637 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go loadDashboardCluster context.WithTimeout 2 1649 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go runOpsGenerateHelmValues context.WithTimeout 1 1872 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/main.go loadObservationVolume context.WithTimeout 1 2222 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/mini.go miniRun.ready time.Now().Add 1 294 per-call NONE: no model row maps this file yet mini cluster start wait +cmd/sw-block/mini.go miniRun.ready time.After 1 317 control-timer NONE: no model row maps this file yet start-wait poll +cmd/sw-block/mini.go miniRun.stop time.After 1 346 per-call NONE: no model row maps this file yet mini cluster stop wait +cmd/sw-block/mini.go mini time.Now().Add 1 523 per-call NONE: no model row maps this file yet mini cluster resolve wait +cmd/sw-block/mini.go mini context.WithTimeout 1 525 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/mini.go mini time.After 1 540 control-timer NONE: no model row maps this file yet resolve-wait poll +cmd/sw-block/mini.go mini time.After 2 568 control-timer NONE: no model row maps this file yet resolve-wait poll +cmd/sw-block/shell.go inspectionShell.execute context.WithTimeout 1 195 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/shell_check.go inspectionShell.check context.WithTimeout 1 104 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/snapshot_operation.go chunkObserveSnapshot context.WithTimeout 1 66 per-call SnapOps.Send one CLI request (operator --timeout) +cmd/sw-block/snapshot_operation.go chunkObserveSnapshot time.NewTimer 1 113 control-timer SnapOps.Send poll or delay timer +cmd/sw-block/volume_backup.go volumeSnapshot context.WithTimeout 1 136 pending-fix RestoreCommand.Abort; RestoreCommand.AbortVerify; RestoreCommand.Run; RestoreCommand.Start a cut waiter's fixed total; fix follows the cut window of #964 (one waiter PR for snapshot, backup, plain detach and stop) +cmd/sw-block/volume_backup.go volumeSnapshot set.Timeout 1 145 pending-fix RestoreCommand.Abort; RestoreCommand.AbortVerify; RestoreCommand.Run; RestoreCommand.Start a cut waiter's fixed total; fix follows the cut window of #964 (one waiter PR for snapshot, backup, plain detach and stop) +cmd/sw-block/volume_backup.go volumeRestore context.WithTimeout 1 286 ruled-total RestoreCommand.Abort; RestoreCommand.AbortVerify; RestoreCommand.Run; RestoreCommand.Start docs/releases/v1.1.md: "it took 0.42 s at the 1 TiB cap" +cmd/sw-block/volume_backup.go volumeRestoreAbort context.WithTimeout 1 381 per-call RestoreCommand.Abort; RestoreCommand.AbortVerify; RestoreCommand.Run; RestoreCommand.Start one CLI request (operator --timeout) +cmd/sw-block/volume_create.go runOpsVolumeCreate context.WithTimeout 1 60 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/volume_resolve.go runOpsVolume context.WithTimeout 1 37 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/volume_verbs.go runVolume http.Client.Timeout 1 110 per-call NONE: no model row maps this file yet one HTTP request +cmd/sw-block/volume_verbs.go volumeStart time.Now().Add 1 281 per-call NONE: no model row maps this file yet volume start: the operator's --wait for it to serve +cmd/sw-block/volume_verbs.go volumeStart time.After 1 295 control-timer NONE: no model row maps this file yet volume start poll +cmd/sw-block/volume_verbs.go volumeCut context.WithTimeout 1 522 pending-fix NONE: no model row maps this file yet a cut waiter's fixed total; fix follows the cut window of #964 (one waiter PR for snapshot, backup, plain detach and stop) +cmd/sw-block/volume_verbs.go volumeCut set.Timeout 1 534 pending-fix NONE: no model row maps this file yet a cut waiter's fixed total; fix follows the cut window of #964 (one waiter PR for snapshot, backup, plain detach and stop) +cmd/sw-block/workspace.go runWorkspaceForceMove context.WithTimeout 1 205 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/workspace.go runWorkspaceLostRange context.WithTimeout 1 356 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/workspace_clean.go runWorkspaceCleanMove context.WithTimeout 1 60 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/workspace_revoke.go runWorkspaceRevoke context.WithTimeout 1 50 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +cmd/sw-block/workspace_show.go runWorkspaceShow context.WithTimeout 1 37 per-call NONE: no model row maps this file yet one CLI request (operator --timeout) +core/adapter/adapter.go VolumeReplicaAdapter.armFenceWatchdog time.AfterFunc 1 285 availability-contract NONE: no model row maps this file yet fence watchdog: a fence that never answers fails typed +core/adapter/adapter.go VolumeReplicaAdapter.armStartWatchdog time.AfterFunc 1 638 availability-contract NONE: no model row maps this file yet start watchdog: a start that never answers fails typed +core/auth/audit.go AuditLog.attempt time.NewTimer 1 164 per-call NONE: no model row maps this file yet one audit record write +core/auth/authtest/certs.go NewCA time.Now().Add 1 50 control-timer NONE: no model row maps this file yet test CA certificate validity: a timestamp (validity, expiry or due time), not a wait +core/auth/authtest/certs.go NewCA time.Now().Add 2 51 control-timer NONE: no model row maps this file yet test CA certificate validity: a timestamp (validity, expiry or due time), not a wait +core/auth/authtest/certs.go CA.Issue time.Now().Add 1 82 control-timer NONE: no model row maps this file yet test certificate validity: a timestamp (validity, expiry or due time), not a wait +core/authority/directive.go StaticDirective.Next time.After 1 211 control-timer NONE: no model row maps this file yet directive poll +core/authority/observation_host.go ObservationHost.run time.NewTimer 1 265 control-timer NONE: no model row maps this file yet next observation deadline +core/authority/observation_host.go ObservationHost.run time.Now().Add 1 268 control-timer NONE: no model row maps this file yet next observation time: a timestamp (validity, expiry or due time), not a wait +core/calibration/harness.go harness.waitForDecisionFinal time.Now().Add 1 105 per-call NONE: no model row maps this file yet calibration harness: one bounded wait +core/csi/controller.go ControllerServer.waitForControllerMultipathPublishContext time.NewTimer 1 157 per-call NONE: no model row maps this file yet one bounded wait +core/csi/kubernetes_metadata.go newInClusterKubernetesClient http.Client.Timeout 1 78 per-call NONE: no model row maps this file yet one HTTP request +core/csi/linux_util.go realISCSIUtil.GetDeviceByIQN time.After 1 87 per-call NONE: no model row maps this file yet one iSCSI device discovery wait +core/csi/linux_util.go realISCSIUtil.GetMultipathDeviceByIQN time.After 1 122 per-call NONE: no model row maps this file yet one multipath device discovery wait +core/csi/linux_util.go refreshMultipathMaps context.WithTimeout 1 143 per-call NONE: no model row maps this file yet one RPC or request +core/csi/linux_util.go iscsiMultipathDeviceForIQN context.WithTimeout 1 154 per-call NONE: no model row maps this file yet one RPC or request +core/csi/linux_util.go realNVMeUtil.GetDeviceByNQN time.After 1 387 per-call NONE: no model row maps this file yet one NVMe device discovery wait +core/csi/node.go NodeServer.waitForNVMePathsConnected time.NewTimer 1 699 per-call NONE: no model row maps this file yet one bounded wait +core/csi/node.go NodeServer.reportCSIReattachObserved context.WithTimeout 1 759 per-call NONE: no model row maps this file yet one RPC or request +core/csi/node.go NodeServer.waitForISCSIMultipathPublishContext time.NewTimer 1 1067 per-call NONE: no model row maps this file yet one bounded wait +core/csi/node.go NodeServer.waitForNVMeMultipathPublishContext time.NewTimer 1 1108 per-call NONE: no model row maps this file yet one bounded wait +core/frontend/chunkstore/catalog_snapshot_operation.go BCatalog.RunSnapshotDeleteOperation context.WithTimeout 1 59 per-call NONE: no model row maps this file yet one settle step after a snapshot delete +core/frontend/chunkstore/layout/delete_intent.go StageSnapshotDeletePage context.WithTimeout 1 41 per-call PageChain.CAdvance; PageChain.CApply; PageChain.CRead; PageChain.CResolve; PageChain.Resend; PageChain.Send; PageChain.WritePage; QueueCap.Consume; QueueCap.Produce; VolDelSweep.Land; VolDelSweep.Stage staging one list page: one HEAD read and one page write (ListStageRequestTimeout) +core/frontend/chunkstore/layout/delete_intent.go adoptDeleteIntentPage context.WithTimeout 1 87 per-call PageChain.CAdvance; PageChain.CApply; PageChain.CRead; PageChain.CResolve; PageChain.Resend; PageChain.Send; PageChain.WritePage; QueueCap.Consume; QueueCap.Produce; VolDelSweep.Land; VolDelSweep.Stage staging one list page: one HEAD read and one page write (ListStageRequestTimeout) +core/frontend/chunkstore/layout/list_chain.go StageListPage context.WithTimeout 1 130 per-call PageChain.CAdvance; PageChain.CRead; PageChain.CResolve; PageChain.Resend; PageChain.Send; PageChain.WritePage; QueueCap.Produce; VolDelSweep.Land; VolDelSweep.Stage staging one list page: one HEAD read and one page write (ListStageRequestTimeout) +core/frontend/chunkstore/layout_remote.go walkSegments context.WithTimeout 1 443 per-call EngineAdapter.Begin; EngineAdapter.ReadHead; EngineAdapter.SendCommit; EngineAdapter.SettleAbort; EngineAdapter.TakeAbandon; PageChain.CRead; StopAndRestart.SendCommit; StopAndRestart.SettleAbort one segment fetch (attach), with reported progress +core/frontend/chunkstore/layout_remote.go attachFetchBound context.WithTimeout 1 518 per-call EngineAdapter.Begin; EngineAdapter.ReadHead; EngineAdapter.SendCommit; EngineAdapter.SettleAbort; EngineAdapter.TakeAbandon; PageChain.CRead; StopAndRestart.SendCommit; StopAndRestart.SettleAbort one attach fetch +core/frontend/chunkstore/layout_remote.go headStep context.WithTimeout 1 740 per-call EngineAdapter.Begin; EngineAdapter.ReadHead; EngineAdapter.SendCommit; EngineAdapter.SettleAbort; EngineAdapter.TakeAbandon; PageChain.CRead; StopAndRestart.SendCommit; StopAndRestart.SettleAbort one conditional HEAD exchange +core/frontend/chunkstore/single_filer.go SWFS.CheckSingleFiler context.WithTimeout 1 45 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/chunkstore/single_filer.go SWFS.CheckSingleFiler time.After 1 68 control-timer NONE: no model row maps this file yet single-filer check retry pause +core/frontend/chunkstore/single_filer.go SWFS.singleFilerRound context.WithTimeout 1 89 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/chunkstore/single_filer.go SWFS.singleFilerRound context.WithTimeout 2 111 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/chunkstore/single_filer.go SWFS.singleFilerRound context.WithTimeout 3 119 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/chunkstore/single_filer.go SWFS.singleFilerRound context.WithTimeout 4 129 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/chunkstore/startup_head_probe.go BCatalog.cleanStartupProbes context.WithTimeout 1 60 per-call NONE: no model row maps this file yet startup probe cleanup: one bounded step each +core/frontend/chunkstore/startup_head_probe.go BCatalog.cleanStartupProbes time.NewTimer 1 83 per-call NONE: no model row maps this file yet startup probe cleanup: one bounded step each +core/frontend/chunkstore/startup_head_probe.go BCatalog.cleanStartupProbes context.WithTimeout 2 92 per-call NONE: no model row maps this file yet startup probe cleanup: one bounded step each +core/frontend/chunkstore/startup_head_probe.go BCatalog.cleanStartupProbes context.WithTimeout 3 99 per-call NONE: no model row maps this file yet startup probe cleanup: one bounded step each +core/frontend/chunkstore/startup_head_probe.go BCatalog.checkConditionalHead context.WithTimeout 1 110 per-call NONE: no model row maps this file yet one conditional HEAD probe at startup +core/frontend/chunkstore/startup_head_probe.go BCatalog.checkConditionalHead context.WithTimeout 2 129 per-call NONE: no model row maps this file yet one conditional HEAD probe at startup +core/frontend/chunkstore/swfs.go newBlobHTTPClient http.Client.Timeout 1 93 per-call VolumeCreate.Land one HTTP request +core/frontend/durable/chunk_snapshot_schedule.go DurableProvider.chunkSnapshotLoop time.NewTimer 1 288 control-timer NONE: no model row maps this file yet snapshot schedule timer +core/frontend/durable/chunk_snapshot_schedule.go DurableProvider.chunkSnapshotLoop boundedPass 1 321 pending-fix NONE: no model row maps this file yet scheduled snapshot's fixed total (two cut bounds); removed by #964 +core/frontend/durable/hold_kzhold.go DurableProvider.HoldBeforeChunkFreshRetireForTest time.Now().Add 1 21 per-call NONE: no model row maps this file yet a test seam's bounded hold +core/frontend/durable/precopy_admission.go StorageBackend.admitPrecopy context.WithDeadline 1 145 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/durable/provider.go DurableProvider.waitHealthy context.WithTimeout 1 899 per-call NONE: no model row maps this file yet one provider open, bounded by OpenTimeout +core/frontend/durable/provider.go DurableProvider.waitHealthy time.After 1 909 control-timer NONE: no model row maps this file yet health poll +core/frontend/durable/provider_chunk.go DurableProvider.chunkAuthorityWait time.After 1 360 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume attach retry pause +core/frontend/durable/provider_chunk.go DurableProvider.newChunkLayer context.WithTimeout 1 496 per-call EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume attach: one geometry check, one HEAD claim +core/frontend/durable/provider_chunk.go DurableProvider.newChunkLayer context.WithTimeout 2 515 per-call EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume attach: one geometry check, one HEAD claim +core/frontend/durable/provider_chunk.go closeBoundRemote.bind context.WithTimeout 1 718 per-call EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume one remote fetch during attach +core/frontend/durable/provider_chunk.go DurableProvider.chunkBackground time.Now().Add 1 1187 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume first maintenance attempt's due time: a timestamp (validity, expiry or due time), not a wait +core/frontend/durable/provider_chunk.go DurableProvider.chunkMaintenanceLoop time.Now().Add 1 1332 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume maintenance due time: a timestamp (validity, expiry or due time), not a wait +core/frontend/durable/provider_chunk.go DurableProvider.chunkMaintenanceLoop time.Now().Add 2 1334 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume maintenance due time: a timestamp (validity, expiry or due time), not a wait +core/frontend/durable/provider_chunk.go DurableProvider.chunkMaintenanceLoop time.NewTimer 1 1336 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume poll or delay timer +core/frontend/durable/provider_chunk.go DurableProvider.chunkMaintenanceLoop boundedPass 1 1348 per-call EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume snapshot-name probe: one bounded listing that grows with snapshot names, not with chunks +core/frontend/durable/provider_chunk.go DurableProvider.chunkMaintenanceLoop time.NewTimer 2 1419 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume poll or delay timer +core/frontend/durable/provider_chunk.go DurableProvider.chunkMaintenanceLoop boundedPass 2 1439 pending-fix EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume maintenance pass total (retention plus cleaning); fix #969 (no-progress window per object) +core/frontend/durable/provider_chunk.go boundedPass context.WithTimeout 1 1492 pending-fix EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume maintenance pass total (retention plus cleaning); fix #969 (no-progress window per object) +core/frontend/durable/provider_chunk.go DurableProvider.chunkCutContext context.WithTimeout 1 1608 pending-fix EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume the cut's fixed total around changed-chunk uploads; fix #964 (cut progress window) +core/frontend/durable/provider_chunk.go DurableProvider.detachVolume time.AfterFunc 1 1757 availability-contract EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume detach freeze and settle budget: the guest-visible freeze is bounded by contract +core/frontend/durable/provider_chunk.go DurableProvider.detachVolume time.AfterFunc 2 1770 availability-contract EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume detach freeze and settle budget: the guest-visible freeze is bounded by contract +core/frontend/durable/provider_chunk.go DurableProvider.detachVolume context.WithDeadline 1 1894 availability-contract EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume detach freeze and settle budget: the guest-visible freeze is bounded by contract +core/frontend/durable/provider_chunk.go DurableProvider.retryUnknownDetach time.After 1 1972 control-timer EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume detach retry backoff +core/frontend/durable/provider_chunk.go DurableProvider.retryUnknownDetach context.WithTimeout 1 1982 per-call EngineAdapter.SettleResume; EngineAdapter.StartStop; HolderInterface.StopBegin; StopAndRestart.SendDetach; StopAndRestart.SettleResume one detach retry attempt +core/frontend/durable/storage_adapter.go StorageBackend.admitAfterAttachUnqueued context.WithTimeout 1 767 per-call EngineAdapter.GuestWrite; HolderInterface.Write; WALHold.Resubmit one RPC or request +core/frontend/iscsi/session.go Session.collectWriteData SetReadDeadline 1 470 per-call NONE: no model row maps this file yet one connection exchange or frame +core/frontend/memback/provider.go Provider.Open time.After 1 69 control-timer NONE: no model row maps this file yet open poll +core/frontend/nbd/device_linux.go Device.waitDone time.After 1 165 per-call NONE: no model row maps this file yet one NBD device teardown wait +core/frontend/nbd/device_linux.go waitActive time.Now().Add 1 220 per-call NONE: no model row maps this file yet one NBD device activation wait +core/frontend/nvmerdma/target.go providerBackend.get context.WithTimeout 1 98 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/nvmerdma/target.go providerBackend.Read context.WithTimeout 1 144 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/nvmerdma/target.go providerBackend.Write context.WithTimeout 1 162 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/nvmerdma/target.go providerBackend.Sync context.WithTimeout 1 180 per-call NONE: no model row maps this file yet one RPC or request +core/frontend/ublk/device_linux.go openWhenPresent time.Now().Add 1 239 per-call NONE: no model row maps this file yet one ublk device open wait +core/frontend/ublk/lifecycle.go settleQueues time.NewTimer 1 44 per-call NONE: no model row maps this file yet one bounded wait +core/frontend/write_budget.go WithWriteBudget context.WithDeadline 1 21 per-call NONE: no model row maps this file yet one guest write command's budget +core/host/master/host.go New http.Server.ReadHeaderTimeout 1 418 per-call NONE: no model row maps this file yet one HTTP request or connection +core/host/master/host.go New http.Server.ReadTimeout 1 418 per-call NONE: no model row maps this file yet one HTTP request or connection +core/host/master/host.go New http.Server.WriteTimeout 1 419 per-call NONE: no model row maps this file yet one HTTP request or connection +core/host/master/host.go New http.Server.IdleTimeout 1 419 per-call NONE: no model row maps this file yet one HTTP request or connection +core/host/master/probe_round.go roundEvidenceProvider.round time.NewTimer 1 213 per-call FencingRound.Deliver; FencingRound.Open one probe round's evidence wait +core/host/master/services.go services.deleteHolderEvidence context.WithTimeout 1 1321 per-call FormatGate.Report one RPC or request +core/host/master/workspace_service.go services.AckWorkspaceRevoked context.WithTimeout 1 235 per-call FormatGate.Place; MoveAdmission.ReadForMove; StopAndRestart.ReadClean one RPC or request +core/host/master/workspace_service.go services.MoveWorkspace context.WithTimeout 1 354 per-call FormatGate.Place; MoveAdmission.ReadForMove; StopAndRestart.ReadClean one RPC or request +core/host/master/workspace_service.go services.PreviewWorkspaceMove context.WithTimeout 1 622 per-call FormatGate.Place; MoveAdmission.ReadForMove; StopAndRestart.ReadClean one RPC or request +core/host/volume/chunk_control.go chunkContext context.WithTimeout 1 522 pending-fix SnapOps.Start HTTP chunk handlers' default 5 min total (manual cut, snapshot, backup); fix #964 and its waiter follow-up +core/host/volume/chunk_control.go StatusServer.handleChunkDetach context.WithTimeout 1 711 pending-fix SnapOps.Start a cut waiter's fixed total; fix follows the cut window of #964 (one waiter PR for snapshot, backup, plain detach and stop) +core/host/volume/chunk_control.go chunkControl.snapshotOperationAttempt context.WithTimeout 1 944 per-call SnapOps.Start one RPC or request +core/host/volume/chunk_control.go chunkControl.deleteSnapshotOperation time.Now().Add 1 1077 pending-fix SnapOps.Start unmeasured: the holder's snapshot-delete resume loop (30 s) around intent preparation; a measurement at the cap or a window is owed +core/host/volume/chunk_control.go chunkControl.deleteSnapshotOperation time.After 1 1100 control-timer SnapOps.Start resume loop poll +core/host/volume/host.go Host.runRoleRetry time.After 1 550 control-timer FormatGate.Downgrade; FormatGate.Upgrade role retry delay +core/host/volume/host.go Host.runHeartbeat context.WithTimeout 1 792 per-call FormatGate.Downgrade; FormatGate.Upgrade one RPC or request +core/host/volume/host.go Host.runSubscribe time.After 1 962 control-timer FormatGate.Downgrade; FormatGate.Upgrade subscribe retry backoff +core/host/volume/peer_command_executor.go PeerCommandExecutor.afterSessionClose context.WithTimeout 1 115 per-call NONE: no model row maps this file yet one RPC or request +core/host/volume/peer_command_executor.go PeerCommandExecutor.PublishHealthy context.WithTimeout 1 197 per-call NONE: no model row maps this file yet one RPC or request +core/host/volume/probe_round.go Host.runProbeRounds time.After 1 45 control-timer FencingRound.Answer probe retry backoff +core/host/volume/probe_round.go Host.probeStreamOnce context.WithTimeout 1 76 per-call FencingRound.Answer one RPC or request +core/host/volume/status_server.go StatusServer.Start http.Server.ReadHeaderTimeout 1 422 per-call NONE: no model row maps this file yet one HTTP request or connection +core/host/volume/workspace_lease.go WorkspaceLeaseGuard.Refresh context.WithTimeout 1 258 per-call HolderInterface.Expire; MoveAdmission.StopOnExpiry; MoveAdmission.Write; SnapshotRemoval.Expire; StopAndRestart.Write one lease renewal RPC, capped at the lease end +core/host/volume/workspace_lease.go WorkspaceLeaseGuard.Refresh context.WithDeadline 1 261 per-call HolderInterface.Expire; MoveAdmission.StopOnExpiry; MoveAdmission.Write; SnapshotRemoval.Expire; StopAndRestart.Write one lease renewal RPC, capped at the lease end +core/host/volume/workspace_lease.go WorkspaceLeaseGuard.drain context.WithTimeout 1 402 availability-contract HolderInterface.Expire; MoveAdmission.StopOnExpiry; MoveAdmission.Write; SnapshotRemoval.Expire; StopAndRestart.Write lease drain on exit: bounded by the lease +core/host/volume/workspace_lease.go WorkspaceLeaseGuard.drain context.WithDeadline 1 427 availability-contract HolderInterface.Expire; MoveAdmission.StopOnExpiry; MoveAdmission.Write; SnapshotRemoval.Expire; StopAndRestart.Write lease drain on exit: bounded by the lease +core/host/volume/workspace_lease.go WorkspaceLeaseGuard.drain context.WithTimeout 2 435 availability-contract HolderInterface.Expire; MoveAdmission.StopOnExpiry; MoveAdmission.Write; SnapshotRemoval.Expire; StopAndRestart.Write lease drain on exit: bounded by the lease +core/host/volume/workspace_lease.go WorkspaceLeaseGuard.drain time.After 1 445 control-timer HolderInterface.Expire; MoveAdmission.StopOnExpiry; MoveAdmission.Write; SnapshotRemoval.Expire; StopAndRestart.Write ack retry pause +core/hostlimit/fetch.go sleepCtx time.NewTimer 1 140 control-timer NONE: no model row maps this file yet poll or delay timer +core/hostlimit/limiter.go lockGuard time.Now().Add 1 327 per-call NONE: no model row maps this file yet one wait for the host limiter's lock +core/hostlimit/limiter.go Limiter.Admit time.AfterFunc 1 489 no-progress-window NONE: no model row maps this file yet an upload slot expires only after NoProgress without progress +core/hostlimit/limiter.go Limiter.WaitUpload time.NewTimer 1 887 per-call NONE: no model row maps this file yet one bounded wait +core/hostlimit/pending.go holdSharedBounded time.Now().Add 1 45 per-call NONE: no model row maps this file yet one bounded shared hold +core/launcher/k8s_client.go NewKubernetesDeploymentClient http.Client.Timeout 1 63 per-call NONE: no model row maps this file yet one HTTP request +core/launcher/k8s_client.go NewInClusterDeploymentClient http.Client.Timeout 1 100 per-call NONE: no model row maps this file yet one HTTP request +core/ops/authority_rebuild_runtime_http.go NewHTTPAuthorityRebuildRuntime http.Client.Timeout 1 21 per-call NONE: no model row maps this file yet one HTTP request +core/ops/authority_rebuild_runtime_http.go HTTPAuthorityRebuildRuntime.ExecuteRebuild http.Client.Timeout 1 35 per-call NONE: no model row maps this file yet one HTTP request +core/ops/failback_runtime_http.go NewHTTPFailbackRuntime http.Client.Timeout 1 21 per-call NONE: no model row maps this file yet one HTTP request +core/ops/failback_runtime_http.go HTTPFailbackRuntime.ExecuteFailback http.Client.Timeout 1 35 per-call NONE: no model row maps this file yet one HTTP request +core/ops/frontend_publication_runtime_http.go NewHTTPFrontendPublicationRuntime http.Client.Timeout 1 21 per-call NONE: no model row maps this file yet one HTTP request +core/ops/frontend_publication_runtime_http.go HTTPFrontendPublicationRuntime.ExecuteFrontendPublication http.Client.Timeout 1 35 per-call NONE: no model row maps this file yet one HTTP request +core/ops/k8s_inventory.go statusAddressForKubernetesInventory time.After 1 423 per-call NONE: no model row maps this file yet one status address lookup +core/ops/k8s_inventory.go waitInventoryTCPReady time.Now().Add 1 466 per-call NONE: no model row maps this file yet one TCP readiness wait +core/ops/kubernetes_status_writer.go NewInClusterKubernetesStatusClient http.Client.Timeout 1 60 per-call NONE: no model row maps this file yet one HTTP request +core/ops/live_sources.go NewLiveVolumeStatusReportCollector http.Client.Timeout 1 38 per-call NONE: no model row maps this file yet one HTTP request +core/ops/server.go NewServer http.Server.ReadHeaderTimeout 1 39 per-call NONE: no model row maps this file yet one HTTP request or connection +core/replication/component/cluster.go Cluster.CatchUpReplica time.After 1 689 per-call NONE: no model row maps this file yet component test cluster: one catch-up wait +core/replication/component/cluster.go Cluster.WaitForConverge time.Now().Add 1 747 per-call NONE: no model row maps this file yet component test cluster: one convergence wait +core/replication/volume.go ReplicationVolume.seedNewPeerLiveCursorsLocked context.WithTimeout 1 714 per-call FencingRound.Ack; Promotion.Ack1; Promotion.Rejoin; Promotion.Write1; Promotion.Write2; ReplicationPeer.Ack; ReplicationPeer.Write one RPC or request +core/storage/chunk_cut_cow.go cutCOWWindow.acquireSaver time.NewTimer 1 403 per-call NONE: no model row maps this file yet one protected chunk's saver wait +core/storage/chunk_cut_cow.go chunkLayerImpl.fillMissing context.WithTimeout 1 603 per-call NONE: no model row maps this file yet one chunk miss fill +core/storage/chunk_head_belt.go casChunkHeadBy context.WithTimeout 1 79 per-call HolderInterface.Fence one HEAD compare-and-swap +core/storage/chunk_head_belt.go readChunkHead context.WithTimeout 1 93 ruled-total HolderInterface.Fence docs/releases/v1.1.md: "is bounded by one fixed 2 s total" +core/storage/chunk_head_belt.go readChunkHeadRoot context.WithTimeout 1 105 per-call HolderInterface.Fence one HEAD root read +core/storage/chunk_head_belt.go confirmChunkHead context.WithTimeout 1 118 ruled-total HolderInterface.Fence docs/releases/v1.1.md: "is bounded by one fixed 2 s total" +core/storage/chunk_head_belt.go confirmChunkTakeover time.NewTimer 1 171 availability-contract HolderInterface.Fence takeover confirmation window +core/storage/chunk_hydrate_all.go chunkLayerImpl.HydrateAllAt time.NewTimer 1 68 control-timer NONE: no model row maps this file yet hydration pacing and retry backoff +core/storage/chunk_hydrate_all.go chunkLayerImpl.HydrateAllAt time.NewTimer 2 104 control-timer NONE: no model row maps this file yet hydration pacing and retry backoff +core/storage/chunk_hydration.go chunkLayerImpl.hydrationWorker context.WithTimeout 1 212 per-call NONE: no model row maps this file yet one chunk fetch +core/storage/chunk_precopy.go chunkLayerImpl.precopyDetach context.WithTimeout 1 157 ruled-total NONE: no model row maps this file yet docs/releases/v1.1.md: "Precopy detach keeps its fixed budgets; it is refused in v1.1" +core/storage/chunk_precopy.go chunkLayerImpl.precopyDetach context.WithTimeout 2 203 ruled-total NONE: no model row maps this file yet docs/releases/v1.1.md: "Precopy detach keeps its fixed budgets; it is refused in v1.1" +core/storage/chunk_upgrade_pass.go upgradePass.Run time.NewTimer 1 356 control-timer NONE: no model row maps this file yet upgrade-pass pacing pause +core/storage/chunk_upload.go chunkLayerImpl.putCapturedWith context.WithTimeout 1 25 pending-fix NONE: no model row maps this file yet a 30 s total over one object's upload retries (it wraps the retry loop and its backoff); fix #964 (a per-request deadline and the cut's no-progress window) +core/storage/chunk_upload.go chunkLayerImpl.putCapturedWith time.NewTimer 1 55 control-timer NONE: no model row maps this file yet upload retry backoff +core/storage/group_commit.go GroupCommitter.Run time.NewTimer 1 81 control-timer NONE: no model row maps this file yet group commit batching delay +core/storage/wal_admission.go walAdmission.acquireContext time.NewTimer 1 128 per-call WALHold.Arrive one write's admission wait, under its command budget +core/storage/wal_admission.go walAdmission.acquireContext time.After 1 239 control-timer WALHold.Arrive admission re-check poll +core/storage/wal_write_hold.go WithWALWriteHold context.WithDeadline 1 104 availability-contract WALHold.CapAnswer; WALHold.Stall a held write's maximum hold, the guest's write budget +core/storage/walstore.go WALStore.admitExtentWrite time.After 1 1308 control-timer WALHold.Admit held extent write's hard-mark re-check +core/storage/walstore.go WALStore.tryCaptureLockWhileHeld time.Now().Add 1 1318 per-call WALHold.Admit the barrier's bounded try for its lock while the flusher hold is on +core/transport/barrier.go sendBarrierReq SetDeadline 1 146 per-call NONE: no model row maps this file yet one connection exchange or frame +core/transport/barrier.go recvBarrierResp SetDeadline 1 157 per-call NONE: no model row maps this file yet one connection exchange or frame +core/transport/catchup_sender.go BlockExecutor.doCatchUp SetDeadline 1 107 ruled-total ReplicationPeer.CatchUp docs/releases/v1.1.md: "one 5 s connection deadline around the whole catch-up stream" +core/transport/catchup_sender.go BlockExecutor.doCatchUp SetDeadline 2 191 per-call ReplicationPeer.CatchUp catch-up final barrier exchange +core/transport/executor.go BlockExecutor.Probe SetDeadline 1 750 per-call NONE: no model row maps this file yet one connection exchange or frame +core/transport/executor.go BlockExecutor.WalShipperFor SetWriteDeadline 1 968 per-call NONE: no model row maps this file yet one connection exchange or frame +core/transport/executor.go BlockExecutor.PublishRecoveryPrefix SetDeadline 1 1393 per-call NONE: no model row maps this file yet one connection exchange or frame +core/transport/rebuild_sender.go BlockExecutor.doRebuild SetDeadline 1 130 per-call ReplicationPeer.Rebuild one connection exchange or frame +core/transport/rebuild_sender.go BlockExecutor.doRebuild SetDeadline 2 146 per-call ReplicationPeer.Rebuild one connection exchange or frame +core/transport/replica.go ReplicaListener.floorAndDrain time.AfterFunc 1 884 per-call FencingRound.Recv; ReplicationPeer.CatchUp; ReplicationPeer.Rebuild; ReplicationPeer.Ship one drain wait of the replica listener +core/transport/wal_shipper.go WalShipper.DrainBacklog time.After 1 799 control-timer NONE: no model row maps this file yet idle pause between drain rounds +core/transport/wal_shipper.go WalShipper.DrainBacklog time.After 2 863 control-timer NONE: no model row maps this file yet idle pause between drain rounds diff --git a/seaweed-block/internal/timebound/registry_check_test.go b/seaweed-block/internal/timebound/registry_check_test.go new file mode 100644 index 0000000000..9e9a9b11d8 --- /dev/null +++ b/seaweed-block/internal/timebound/registry_check_test.go @@ -0,0 +1,241 @@ +package timebound + +import ( + "fmt" + "os" + "regexp" + "sort" + "strconv" + "strings" +) + +// The registry's file and its columns. +const ( + registryPath = "docs/time-bounds.tsv" + tracePath = ".github/model-code-trace.tsv" + header = "path\tfunc\tkind\tn\tline\tclass\tmodel\tnote" +) + +// The classes a bound may have. +var classes = map[string]string{ + "per-call": "one request, RPC, frame, command or chunk", + "no-progress-window": "renewed while the work progresses", + "availability-contract": "a bound promised to a guest, peer or operator", + "control-timer": "a schedule, poll, backoff or batching delay", + "pending-fix": "a fixed total around sized work; names its fix PR or the measurement owed; none may remain at the v1.1 tag", + "ruled-total": "a fixed total accepted for v1.1; cites the release-note line that states it", +} + +// unclassified marks a row the update mode added for a new site; it never passes. +const unclassified = "unclassified" + +type row struct { + site + Class, Model, Note string + lineNo int // in the registry file +} + +var ( + actionRe = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*$`) + prRe = regexp.MustCompile(`#[0-9]+\b`) + citationRe = regexp.MustCompile(`^(docs/[A-Za-z0-9_./-]+\.md): "([^"]+)"$`) + spaceRe = regexp.MustCompile(`\s+`) +) + +// parseRegistry reads the registry text: comment lines (#), the header, then one row per site. +func parseRegistry(text string) (comments []string, rows []row, err error) { + seenHeader := false + for i, line := range strings.Split(strings.ReplaceAll(text, "\r\n", "\n"), "\n") { + if line == "" { + continue + } + if strings.HasPrefix(line, "#") { + comments = append(comments, line) + continue + } + if !seenHeader { + if line != header { + return nil, nil, fmt.Errorf("%s:%d: header %q, want %q", registryPath, i+1, line, header) + } + seenHeader = true + continue + } + f := strings.Split(line, "\t") + if len(f) != 8 { + return nil, nil, fmt.Errorf("%s:%d: %d columns, want 8", registryPath, i+1, len(f)) + } + n, err1 := strconv.Atoi(f[3]) + ln, err2 := strconv.Atoi(f[4]) + if err1 != nil || err2 != nil { + return nil, nil, fmt.Errorf("%s:%d: n and line must be numbers", registryPath, i+1) + } + rows = append(rows, row{site: site{Path: f[0], Func: f[1], Kind: f[2], Ordinal: n, Line: ln}, + Class: f[5], Model: f[6], Note: f[7], lineNo: i + 1}) + } + if !seenHeader { + return nil, nil, fmt.Errorf("%s: no header", registryPath) + } + return comments, rows, nil +} + +// parseTrace reads the model-code trace: path -> its model actions. +func parseTrace(text string) map[string]map[string]bool { + out := map[string]map[string]bool{} + for _, line := range strings.Split(strings.ReplaceAll(text, "\r\n", "\n"), "\n") { + if line == "" || strings.HasPrefix(line, "#") { + continue + } + f := strings.Split(line, "\t") + if len(f) != 2 { + continue + } + if out[f[0]] == nil { + out[f[0]] = map[string]bool{} + } + out[f[0]][f[1]] = true + } + return out +} + +// check returns every problem with the registry against the scanned sites. +// readDoc returns a repository file's text (for ruled-total citations). +func check(sites []site, rows []row, trace map[string]map[string]bool, readDoc func(string) (string, error)) []string { + var problems []string + bad := func(format string, a ...any) { problems = append(problems, fmt.Sprintf(format, a...)) } + byKey := map[string]row{} + for _, r := range rows { + if _, dup := byKey[r.key()]; dup { + bad("%s:%d: duplicate row for %s", registryPath, r.lineNo, r.key()) + } + byKey[r.key()] = r + } + allActions := map[string]bool{} + for _, acts := range trace { + for a := range acts { + allActions[a] = true + } + } + seen := map[string]bool{} + for _, s := range sites { + r, ok := byKey[s.key()] + if !ok { + bad("%s:%d: %s in %s is not in %s (add a row naming its class and model row; TIME_BOUNDS_UPDATE=1 adds it as %s)", + s.Path, s.Line, s.Kind, s.Func, registryPath, unclassified) + continue + } + seen[s.key()] = true + if r.Line != s.Line { + bad("%s:%d: %s in %s is listed at line %d (refresh with TIME_BOUNDS_UPDATE=1)", s.Path, s.Line, s.Kind, s.Func, r.Line) + } + if r.Class == "per-call" && len(s.Loops) > 0 { + bad("%s:%d: per-call %s in %s, but its function then loops over chunks or objects (%s): a total around sized work is not per-call", + s.Path, s.Line, s.Kind, s.Func, strings.Join(s.Loops, "; ")) + } + } + for _, r := range rows { + where := fmt.Sprintf("%s:%d (%s %s in %s)", registryPath, r.lineNo, r.Path, r.Kind, r.Func) + if !seen[r.key()] { + bad("%s: no such bound in the code any more; remove the row", where) + } + if _, ok := classes[r.Class]; !ok { + bad("%s: class %q; want one of %s", where, r.Class, strings.Join(sortedKeys(classes), ", ")) + } + switch r.Class { + case "pending-fix": + if !prRe.MatchString(r.Note) && !strings.HasPrefix(r.Note, "unmeasured: ") { + bad("%s: a pending-fix row names its fix PR (#N), or starts \"unmeasured: \" with the measurement owed", where) + } + case "ruled-total": + m := citationRe.FindStringSubmatch(r.Note) + if m == nil { + bad(`%s: a ruled-total row cites the line that states it: docs/.md: ""`, where) + break + } + text, err := readDoc(m[1]) + if err != nil { + bad("%s: cited %s: %v", where, m[1], err) + } else if !strings.Contains(spaceRe.ReplaceAllString(text, " "), spaceRe.ReplaceAllString(m[2], " ")) { + bad("%s: %s does not say %q", where, m[1], m[2]) + } + default: + if strings.TrimSpace(r.Note) == "" { + bad("%s: the note says what the bound covers", where) + } + } + problems = append(problems, checkModel(where, r, trace, allActions)...) + } + return problems +} + +// checkModel: the model cell cites the file's model actions (Module.Action; several joined by "; "), or, for a file +// no model row maps, NONE: . +func checkModel(where string, r row, trace map[string]map[string]bool, all map[string]bool) []string { + mapped := trace[r.Path] + if strings.HasPrefix(r.Model, "NONE:") { + if mapped != nil { + return []string{fmt.Sprintf("%s: %s is mapped to model rows (%s); cite one, not NONE", where, r.Path, strings.Join(sortedKeys(mapped), "; "))} + } + if len(strings.TrimSpace(strings.TrimPrefix(r.Model, "NONE:"))) < 10 { + return []string{fmt.Sprintf("%s: NONE needs a reason of at least 10 characters", where)} + } + return nil + } + var out []string + cited := false + for _, a := range strings.Split(r.Model, ";") { + a = strings.TrimSpace(a) + switch { + case !actionRe.MatchString(a): + out = append(out, fmt.Sprintf("%s: model %q is not Module.Action", where, a)) + case !all[a]: + out = append(out, fmt.Sprintf("%s: model %q is no row of %s", where, a, tracePath)) + case mapped[a]: + cited = true + } + } + if mapped != nil && !cited && len(out) == 0 { + out = append(out, fmt.Sprintf("%s: cite one of %s's model rows (%s)", where, r.Path, strings.Join(sortedKeys(mapped), "; "))) + } + return out +} + +// update rewrites the registry for the scanned sites: listed rows keep their class, model and note with refreshed +// line numbers, rows for vanished sites are dropped, and new sites are appended as unclassified. +func update(comments []string, sites []site, rows []row, trace map[string]map[string]bool) string { + byKey := map[string]row{} + for _, r := range rows { + byKey[r.key()] = r + } + var b strings.Builder + for _, c := range comments { + b.WriteString(c + "\n") + } + b.WriteString(header + "\n") + for _, s := range sites { + r, ok := byKey[s.key()] + if !ok { + r = row{Class: unclassified, Model: "NONE: no model row maps this file yet", Note: "classify this new bound"} + if acts := trace[s.Path]; acts != nil { + r.Model = strings.Join(sortedKeys(acts), "; ") + } + } + fmt.Fprintf(&b, "%s\t%s\t%s\t%d\t%d\t%s\t%s\t%s\n", s.Path, s.Func, s.Kind, s.Ordinal, s.Line, r.Class, r.Model, r.Note) + } + return b.String() +} + +func sortedKeys[V any](m map[string]V) []string { + out := make([]string, 0, len(m)) + for k := range m { + out = append(out, k) + } + sort.Strings(out) + return out +} + +func readFile(root string) func(string) (string, error) { + return func(rel string) (string, error) { + b, err := os.ReadFile(root + "/" + rel) + return string(b), err + } +} diff --git a/seaweed-block/internal/timebound/registry_test.go b/seaweed-block/internal/timebound/registry_test.go new file mode 100644 index 0000000000..c790de0b9d --- /dev/null +++ b/seaweed-block/internal/timebound/registry_test.go @@ -0,0 +1,222 @@ +package timebound + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +func repoRoot(t *testing.T) string { + t.Helper() + dir, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + for { + if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil { + return dir + } + parent := filepath.Dir(dir) + if parent == dir { + t.Fatal("go.mod not found above the test directory") + } + dir = parent + } +} + +// Every fixed time bound in core/ and cmd/ has one row in docs/time-bounds.tsv +// naming its class and model row; a per-call bound never wraps a loop over +// chunks or objects; a pending-fix row names its fix PR and a ruled-total row +// cites the release-note line that states it. TIME_BOUNDS_UPDATE=1 refreshes +// the line numbers, drops vanished sites and appends new ones as unclassified +// (which still fails until classified). +func TestTheTimeBoundRegistryNamesEveryBound(t *testing.T) { + root := repoRoot(t) + sites, err := scan(root) + if err != nil { + t.Fatal(err) + } + raw, err := os.ReadFile(filepath.Join(root, registryPath)) + if err != nil { + t.Fatal(err) + } + comments, rows, err := parseRegistry(string(raw)) + if err != nil { + t.Fatal(err) + } + traceRaw, err := os.ReadFile(filepath.Join(root, tracePath)) + if err != nil { + t.Fatal(err) + } + trace := parseTrace(string(traceRaw)) + if os.Getenv("TIME_BOUNDS_UPDATE") == "1" { + if err := os.WriteFile(filepath.Join(root, registryPath), []byte(update(comments, sites, rows, trace)), 0o644); err != nil { + t.Fatal(err) + } + if comments, rows, err = parseRegistry(update(comments, sites, rows, trace)); err != nil { + t.Fatal(err) + } + } + counts := map[string]int{} + for _, r := range rows { + counts[r.Class]++ + } + t.Logf("%d bounds: %v", len(sites), counts) + for _, p := range check(sites, rows, trace, readFile(root)) { + t.Error(p) + } +} + +// The scanner finds every kind of bound the registry covers, in functions and +// in package-level var initializers, including a catalog command's budget; +// a time.After wait and a time.Now().Add deadline value count (one in an +// AfterFunc callback too, but not one that is a WithDeadline or SetDeadline +// deadline argument, already that call's); it +// skips a deadline clear and sees a sized loop after a bound in the same +// function, a package-level function literal's included. +func TestTheScannerFindsEveryKindOfBound(t *testing.T) { + sites, err := scanFile(filepath.Join("testdata", "bounds.go.txt"), "testdata/bounds.go") + if err != nil { + t.Fatal(err) + } + got := map[string]int{} + var loops []string + for _, s := range sites { + got[s.Func+" "+s.Kind]++ + loops = append(loops, s.Loops...) + } + want := map[string]int{ + "timeouts context.WithTimeout": 1, "timeouts context.WithDeadline": 1, "timeouts context.WithTimeoutCause": 1, + "timeouts context.WithDeadlineCause": 1, "timers time.NewTimer": 1, "timers time.AfterFunc": 1, + "timers time.After": 1, "timers time.Now().Add": 2, + "deadlines SetDeadline": 1, "deadlines SetReadDeadline": 1, "deadlines SetWriteDeadline": 1, + "httpBounds http.Client.Timeout": 1, "httpBounds http.Server.ReadHeaderTimeout": 1, + "httpBounds set.Timeout": 1, "passes boundedPass": 2, "S.sized context.WithTimeout": 1, + "var defaultClient http.Client.Timeout": 1, "var initCtx context.WithTimeout": 1, "catalog newBCommand": 1, + "var load context.WithTimeout": 1, "verify watchVerifyProgress": 1, + } + for k, n := range want { + if got[k] != n { + t.Errorf("%s: found %d, want %d", k, got[k], n) + } + } + for k, n := range got { + if want[k] == 0 { + t.Errorf("unexpected site %s (%d)", k, n) + } + } + if len(loops) != 2 || !strings.Contains(strings.Join(loops, " "), "chunks") || !strings.Contains(strings.Join(loops, " "), "objects") { + t.Errorf("sized loops after a bound: %v, want the chunk loop in S.sized and the object loop in var load's literal", loops) + } +} + +// The check fails each way a registry can drift from the code. Each case is +// one change to an otherwise passing registry. +func TestTheRegistryCheckRefusesEachDrift(t *testing.T) { + trace := map[string]map[string]bool{"core/m.go": {"Mod.Act": true}} + docs := func(p string) (string, error) { + if p == "docs/notes.md" { + return "the total took 1 s\n at the cap", nil + } + return "", os.ErrNotExist + } + baseSites := []site{ + {Path: "core/a.go", Func: "f", Kind: "context.WithTimeout", Ordinal: 1, Line: 10}, + {Path: "core/m.go", Func: "g", Kind: "time.NewTimer", Ordinal: 1, Line: 20}, + {Path: "core/a.go", Func: "h", Kind: "boundedPass", Ordinal: 1, Line: 30}, + {Path: "core/a.go", Func: "k", Kind: "context.WithTimeout", Ordinal: 1, Line: 40}, + } + baseRows := func() []row { + return []row{ + {site: baseSites[0], Class: "per-call", Model: "NONE: no model row maps this file yet", Note: "one RPC"}, + {site: baseSites[1], Class: "control-timer", Model: "Mod.Act", Note: "poll"}, + {site: baseSites[2], Class: "pending-fix", Model: "NONE: no model row maps this file yet", Note: "fix #12"}, + {site: baseSites[3], Class: "ruled-total", Model: "NONE: no model row maps this file yet", Note: `docs/notes.md: "the total took 1 s at the cap"`}, + } + } + if p := check(baseSites, baseRows(), trace, docs); len(p) != 0 { + t.Fatalf("the passing registry fails: %v", p) + } + cases := []struct { + name string + edit func(s []site, r []row) ([]site, []row) + wants string + }{ + {"a new bound with no row", func(s []site, r []row) ([]site, []row) { + return append(s, site{Path: "core/a.go", Func: "n", Kind: "time.AfterFunc", Ordinal: 1, Line: 50}), r + }, "is not in"}, + {"a package-level initializer bound with no row", func(s []site, r []row) ([]site, []row) { + return append(s, site{Path: "core/a.go", Func: "var client", Kind: "http.Client.Timeout", Ordinal: 1, Line: 5}), r + }, "is not in"}, + {"a per-call bound in an initializer's function literal around an object loop", func(s []site, r []row) ([]site, []row) { + s = append(s, site{Path: "core/a.go", Func: "var load", Kind: "context.WithTimeout", Ordinal: 1, Line: 6, Loops: []string{"8: objects"}}) + return s, append(r, row{site: s[len(s)-1], Class: "per-call", Model: "NONE: no model row maps this file yet", Note: "one step"}) + }, "loops over chunks or objects"}, + {"a time.After wait with no row", func(s []site, r []row) ([]site, []row) { + return append(s, site{Path: "core/a.go", Func: "w", Kind: "time.After", Ordinal: 1, Line: 60}), r + }, "is not in"}, + {"a loop deadline with no row", func(s []site, r []row) ([]site, []row) { + return append(s, site{Path: "core/a.go", Func: "w", Kind: "time.Now().Add", Ordinal: 1, Line: 61}), r + }, "is not in"}, + {"a callback-local deadline with no row", func(s []site, r []row) ([]site, []row) { + return append(s, site{Path: "core/a.go", Func: "t", Kind: "time.Now().Add", Ordinal: 2, Line: 62}), r + }, "is not in"}, + {"a verify window with no row", func(s []site, r []row) ([]site, []row) { + return append(s, site{Path: "cmd/v.go", Func: "chunkVerify", Kind: "watchVerifyProgress", Ordinal: 1, Line: 9}), r + }, "is not in"}, + {"a row for a vanished bound", func(s []site, r []row) ([]site, []row) { return s[1:], r }, "no such bound"}, + {"a moved bound with a stale line", func(s []site, r []row) ([]site, []row) { + s = append([]site(nil), s...) + s[0].Line = 11 + return s, r + }, "refresh with TIME_BOUNDS_UPDATE=1"}, + {"a per-call bound around a chunk loop", func(s []site, r []row) ([]site, []row) { + s = append([]site(nil), s...) + s[0].Loops = []string{"12: l.chunks"} + return s, r + }, "loops over chunks or objects"}, + {"an unknown class", func(s []site, r []row) ([]site, []row) { r[0].Class = "fast"; return s, r }, "class \"fast\""}, + {"an unclassified new row", func(s []site, r []row) ([]site, []row) { r[0].Class = unclassified; return s, r }, "class \"unclassified\""}, + {"pending-fix without a PR or the measurement owed", func(s []site, r []row) ([]site, []row) { r[2].Note = "fix soon"; return s, r }, "names its fix PR"}, + {"ruled-total without a citation", func(s []site, r []row) ([]site, []row) { r[3].Note = "measured"; return s, r }, "cites the line"}, + {"ruled-total citing words the doc lacks", func(s []site, r []row) ([]site, []row) { + r[3].Note = `docs/notes.md: "the total took 9 s"` + return s, r + }, "does not say"}, + {"NONE for a mapped file", func(s []site, r []row) ([]site, []row) { r[1].Model = "NONE: not modelled here at all"; return s, r }, "cite one, not NONE"}, + {"a model action that is no trace row", func(s []site, r []row) ([]site, []row) { r[1].Model = "Mod.Other"; return s, r }, "is no row of"}, + {"NONE without a reason", func(s []site, r []row) ([]site, []row) { r[0].Model = "NONE: x"; return s, r }, "at least 10 characters"}, + {"a row without a note", func(s []site, r []row) ([]site, []row) { r[0].Note = ""; return s, r }, "says what the bound covers"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + s, r := tc.edit(append([]site(nil), baseSites...), baseRows()) + p := check(s, r, trace, docs) + if !strings.Contains(strings.Join(p, "\n"), tc.wants) { + t.Errorf("problems %v, want one saying %q", p, tc.wants) + } + }) + } +} + +// The update mode keeps each row's class, model and note, refreshes its line, +// drops vanished sites and appends new ones as unclassified. +func TestTheRegistryUpdateKeepsClassesAndAddsNewSitesUnclassified(t *testing.T) { + old := []row{ + {site: site{Path: "core/a.go", Func: "f", Kind: "time.NewTimer", Ordinal: 1, Line: 10}, Class: "control-timer", Model: "NONE: no model row maps this file yet", Note: "poll"}, + {site: site{Path: "core/a.go", Func: "gone", Kind: "time.NewTimer", Ordinal: 1, Line: 20}, Class: "per-call", Model: "NONE: no model row maps this file yet", Note: "x"}, + } + sites := []site{ + {Path: "core/a.go", Func: "f", Kind: "time.NewTimer", Ordinal: 1, Line: 12}, + {Path: "core/a.go", Func: "new", Kind: "context.WithTimeout", Ordinal: 1, Line: 30}, + } + _, rows, err := parseRegistry(update([]string{"# c"}, sites, old, nil)) + if err != nil { + t.Fatal(err) + } + if len(rows) != 2 || rows[0].Line != 12 || rows[0].Class != "control-timer" || rows[0].Note != "poll" || + rows[1].Func != "new" || rows[1].Class != unclassified { + t.Fatalf("updated rows %+v", rows) + } +} diff --git a/seaweed-block/internal/timebound/scan_test.go b/seaweed-block/internal/timebound/scan_test.go new file mode 100644 index 0000000000..a33ee93d72 --- /dev/null +++ b/seaweed-block/internal/timebound/scan_test.go @@ -0,0 +1,320 @@ +// Package timebound keeps the registry of fixed time bounds in core/ and cmd/ +// (docs/time-bounds.tsv) in step with the code: every bound site is listed +// with its class and model row, and a per-call bound never wraps a loop over +// chunks or objects. +package timebound + +import ( + "go/ast" + "go/parser" + "go/token" + "io/fs" + "os" + "path/filepath" + "regexp" + "sort" + "strconv" + "strings" +) + +// A site is one fixed time bound in the source. +type site struct { + Path string // repository-relative, forward slashes + Func string // enclosing top-level function (Name or Recv.Name), or "var Name" for a package-level initializer + Kind string // what sets the bound (see kinds) + Ordinal int // 1-based, among the same Path, Func and Kind in source order + Line int + Loops []string // for loops after the site, in the same function, whose header names chunks or objects +} + +// key identifies a site across edits that only move it. +func (s site) key() string { + return s.Path + "\t" + s.Func + "\t" + s.Kind + "\t" + strconv.Itoa(s.Ordinal) +} + +// Package-qualified calls that set a bound, by import path. A time.Now().Add +// value is a deadline too (a loop or wait deadline), unless it lies in the +// deadline argument of a recorded WithDeadline or Set*Deadline call (then it +// is that call's deadline). One inside a callback, such as an AfterFunc's, is +// its own site. +var pkgCalls = map[string]map[string]bool{ + "context": {"WithTimeout": true, "WithDeadline": true, "WithTimeoutCause": true, "WithDeadlineCause": true}, + "time": {"NewTimer": true, "AfterFunc": true, "After": true}, +} + +// Method calls that set a connection deadline, whatever the receiver. +var deadlineMethods = map[string]bool{"SetDeadline": true, "SetReadDeadline": true, "SetWriteDeadline": true} + +// net/http struct fields that are time bounds. +var httpTimeoutFields = map[string]map[string]bool{ + "Client": {"Timeout": true}, + "Server": {"ReadTimeout": true, "ReadHeaderTimeout": true, "WriteTimeout": true, "IdleTimeout": true}, +} + +// Field names whose assignment is an http time bound (client.Timeout = d). +var assignedTimeoutFields = map[string]bool{"Timeout": true, "ReadTimeout": true, "ReadHeaderTimeout": true, "WriteTimeout": true, "IdleTimeout": true} + +// The product's own budget helpers: boundedPass bounds a whole pass, +// newBCommand gives each catalog CLI command its budget (which bCommand.run +// applies), and watchVerifyProgress enforces verify's no-progress window (its +// ticker only polls; the window is its argument). +var budgetCalls = map[string]bool{"boundedPass": true, "newBCommand": true, "watchVerifyProgress": true} + +// sizedLoop names a loop over chunks or objects: its header mentions one. +var sizedLoop = regexp.MustCompile(`(?i)chunk|object|segment|manifest|\brefs?\b|references`) + +// scan returns every bound site under core/ and cmd/ below root (non-test Go +// files, testdata excluded), sorted by path and line. +func scan(root string) ([]site, error) { + var out []site + for _, top := range []string{"core", "cmd"} { + err := filepath.WalkDir(filepath.Join(root, top), func(p string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() { + if d.Name() == "testdata" { + return filepath.SkipDir + } + return nil + } + if !strings.HasSuffix(p, ".go") || strings.HasSuffix(p, "_test.go") { + return nil + } + rel, err := filepath.Rel(root, p) + if err != nil { + return err + } + sites, err := scanFile(p, filepath.ToSlash(rel)) + if err != nil { + return err + } + out = append(out, sites...) + return nil + }) + if err != nil { + return nil, err + } + } + sort.Slice(out, func(i, j int) bool { + if out[i].Path != out[j].Path { + return out[i].Path < out[j].Path + } + return out[i].Line < out[j].Line + }) + return out, nil +} + +func scanFile(path, rel string) ([]site, error) { + src, err := os.ReadFile(path) + if err != nil { + return nil, err + } + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, path, src, parser.SkipObjectResolution) + if err != nil { + return nil, err + } + imports := map[string]string{} // local name -> import path + for _, im := range f.Imports { + p, _ := strconv.Unquote(im.Path.Value) + name := p[strings.LastIndex(p, "/")+1:] + if im.Name != nil { + name = im.Name.Name + } + imports[name] = p + } + text := func(n ast.Node) string { + return string(src[fset.Position(n.Pos()).Offset:fset.Position(n.End()).Offset]) + } + var out []site + count := map[string]int{} + add := func(fn string, kind string, n ast.Node, body *ast.BlockStmt) { + s := site{Path: rel, Func: fn, Kind: kind, Line: fset.Position(n.Pos()).Line} + k := fn + "\t" + kind + count[k]++ + s.Ordinal = count[k] + if body != nil { + ast.Inspect(body, func(m ast.Node) bool { + if m == nil || m.Pos() <= n.Pos() { + return true + } + var header string + switch l := m.(type) { + case *ast.RangeStmt: + header = text(l.X) + case *ast.ForStmt: + if l.Cond != nil { + header = text(l.Cond) + } + default: + return true + } + if sizedLoop.MatchString(header) { + s.Loops = append(s.Loops, strconv.Itoa(fset.Position(m.Pos()).Line)+": "+header) + } + return true + }) + } + out = append(out, s) + } + // visit finds the bounds under root. A bound's loop check runs over its + // innermost enclosing function body: a function literal's own body, else + // the declaration's (body; nil for an initializer outside any literal). + visit := func(fn string, root ast.Node, declBody *ast.BlockStmt) { + var lits []*ast.FuncLit // enclosing function literals, innermost last + var covered []ast.Node // deadline arguments of recorded calls: a time.Now().Add inside one is that call's + ast.Inspect(root, func(n ast.Node) bool { + if n == nil { + return true + } + for len(lits) > 0 && n.Pos() >= lits[len(lits)-1].End() { + lits = lits[:len(lits)-1] // left the innermost literal + } + if lit, ok := n.(*ast.FuncLit); ok { + lits = append(lits, lit) + } + body := declBody + if len(lits) > 0 { + body = lits[len(lits)-1].Body + } + switch x := n.(type) { + case *ast.CallExpr: + switch fun := x.Fun.(type) { + case *ast.SelectorExpr: + if id, ok := fun.X.(*ast.Ident); ok { + if names := pkgCalls[imports[id.Name]]; names[fun.Sel.Name] { + add(fn, imports[id.Name]+"."+fun.Sel.Name, x, body) + if (fun.Sel.Name == "WithDeadline" || fun.Sel.Name == "WithDeadlineCause") && len(x.Args) >= 2 { + covered = append(covered, x.Args[1]) // the deadline argument only + } + return true + } + } + if deadlineMethods[fun.Sel.Name] { + if len(x.Args) == 1 && isZeroTime(x.Args[0], imports) { + return true // clears the deadline: no bound + } + add(fn, fun.Sel.Name, x, body) + for _, a := range x.Args { // the deadline argument only + covered = append(covered, a) + } + } else if fun.Sel.Name == "Add" && isTimeNow(fun.X, imports) && !inside(x, covered) { + add(fn, "time.Now().Add", x, body) // a deadline value (a loop or wait deadline) + } else if budgetCalls[fun.Sel.Name] { + add(fn, fun.Sel.Name, x, body) + } + case *ast.Ident: + if budgetCalls[fun.Name] { + add(fn, fun.Name, x, body) + } + } + case *ast.AssignStmt: + // client.Timeout = ...: an http time bound set by assignment (the field + // names are net/http's; the receiver's type is not resolved here). + for _, lhs := range x.Lhs { + if sel, ok := lhs.(*ast.SelectorExpr); ok && assignedTimeoutFields[sel.Sel.Name] { + add(fn, "set."+sel.Sel.Name, x, nil) + } + } + case *ast.CompositeLit: + sel, ok := x.Type.(*ast.SelectorExpr) + if !ok { + return true + } + id, ok := sel.X.(*ast.Ident) + if !ok || imports[id.Name] != "net/http" { + return true + } + fields := httpTimeoutFields[sel.Sel.Name] + for _, el := range x.Elts { + if kv, ok := el.(*ast.KeyValueExpr); ok { + if k, ok := kv.Key.(*ast.Ident); ok && fields[k.Name] { + add(fn, "http."+sel.Sel.Name+"."+k.Name, kv, nil) + } + } + } + } + return true + }) + } + for _, decl := range f.Decls { + switch d := decl.(type) { + case *ast.FuncDecl: + if d.Body == nil { + continue + } + fn := d.Name.Name + if d.Recv != nil && len(d.Recv.List) == 1 { + fn = recvName(d.Recv.List[0].Type) + "." + fn + } + visit(fn, d.Body, d.Body) + case *ast.GenDecl: // package-level var initializers (and any func literal in them) + if d.Tok != token.VAR { + continue + } + for _, spec := range d.Specs { + vs, ok := spec.(*ast.ValueSpec) + if !ok || len(vs.Values) == 0 || len(vs.Names) == 0 { + continue + } + for _, v := range vs.Values { + visit("var "+vs.Names[0].Name, v, nil) + } + } + } + } + return out, nil +} + +// isTimeNow reports a call of time.Now(). +func isTimeNow(e ast.Expr, imports map[string]string) bool { + c, ok := e.(*ast.CallExpr) + if !ok || len(c.Args) != 0 { + return false + } + sel, ok := c.Fun.(*ast.SelectorExpr) + if !ok || sel.Sel.Name != "Now" { + return false + } + id, ok := sel.X.(*ast.Ident) + return ok && imports[id.Name] == "time" +} + +// inside reports n lying within one of the nodes. +func inside(n ast.Node, nodes []ast.Node) bool { + for _, c := range nodes { + if n.Pos() >= c.Pos() && n.End() <= c.End() { + return true + } + } + return false +} + +// isZeroTime reports time.Time{}: a deadline argument that clears the deadline. +func isZeroTime(e ast.Expr, imports map[string]string) bool { + lit, ok := e.(*ast.CompositeLit) + if !ok || len(lit.Elts) != 0 { + return false + } + sel, ok := lit.Type.(*ast.SelectorExpr) + if !ok || sel.Sel.Name != "Time" { + return false + } + id, ok := sel.X.(*ast.Ident) + return ok && imports[id.Name] == "time" +} + +func recvName(e ast.Expr) string { + switch t := e.(type) { + case *ast.StarExpr: + return recvName(t.X) + case *ast.IndexExpr: + return recvName(t.X) + case *ast.IndexListExpr: + return recvName(t.X) + case *ast.Ident: + return t.Name + } + return "?" +} diff --git a/seaweed-block/internal/timebound/testdata/bounds.go.txt b/seaweed-block/internal/timebound/testdata/bounds.go.txt new file mode 100644 index 0000000000..71838d256f --- /dev/null +++ b/seaweed-block/internal/timebound/testdata/bounds.go.txt @@ -0,0 +1,80 @@ +package sample + +import ( + "context" + "errors" + "net" + "net/http" + "time" +) + +var defaultClient = &http.Client{Timeout: time.Second} + +var initCtx, initCancel = context.WithTimeout(context.Background(), time.Second) + +var load = func(ctx context.Context, objects []string) { + step, cancel := context.WithTimeout(ctx, time.Second) + defer cancel() + for range objects { + _ = step + } +} + +func catalog() { + newBCommand("usage", time.Minute, nil, nil) +} + +func verify(ctx context.Context, cancel context.CancelCauseFunc) { + _ = watchVerifyProgress(ctx, time.Minute, cancel) +} + +func timeouts(ctx context.Context) { + _, c1 := context.WithTimeout(ctx, time.Second) + _, c2 := context.WithDeadline(ctx, time.Now().Add(time.Second)) + _, c3 := context.WithTimeoutCause(ctx, time.Second, errors.New("x")) + _, c4 := context.WithDeadlineCause(ctx, time.Now(), errors.New("x")) + c1() + c2() + c3() + c4() +} + +func timers() { + t := time.NewTimer(time.Second) + t.Stop() + time.AfterFunc(time.Second, func() { + end := time.Now().Add(time.Minute) // a callback's own deadline: its own site + _ = end + }) + <-time.After(time.Second) + deadline := time.Now().Add(time.Second) // a loop deadline: its own site + _ = deadline +} + +func deadlines(c net.Conn) { + _ = c.SetDeadline(time.Now().Add(time.Second)) + _ = c.SetReadDeadline(time.Now().Add(time.Second)) + _ = c.SetWriteDeadline(time.Now().Add(time.Second)) + _ = c.SetDeadline(time.Time{}) // clears: not a bound +} + +func httpBounds() { + c := &http.Client{Timeout: time.Second} + _ = &http.Server{ReadHeaderTimeout: time.Second} + c.Timeout = 2 * time.Second +} + +func passes(p *P) { + boundedPass(time.Second) + p.boundedPass(time.Second) +} + +type S struct{ chunks []int } + +func (s *S) sized(ctx context.Context) { + ctx, cancel := context.WithTimeout(ctx, time.Second) + defer cancel() + for range s.chunks { + _ = ctx + } +}