Skip to content

Commit f2dd523

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/ui-providers
# Conflicts: # crates/sqlbuild-python/src/bindings/_helpers/location_command/constants.rs
2 parents c2793d2 + 3ef8ece commit f2dd523

80 files changed

Lines changed: 1392 additions & 129 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.release-please-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.218.0"
2+
".": "0.219.0"
33
}

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.219.0](https://github.com/sqlstack-io/sqlbuild/compare/v0.218.0...v0.219.0) (2026-11-13)
4+
5+
6+
### Features
7+
8+
* **ui:** a static click-through DuckShop demo for the website ([#1448](https://github.com/sqlstack-io/sqlbuild/issues/1448)) ([6251280](https://github.com/sqlstack-io/sqlbuild/commit/6251280e9354adc48739a6111bf77949ca824d2e))
9+
310
## [0.218.0](https://github.com/sqlstack-io/sqlbuild/compare/v0.217.0...v0.218.0) (2026-11-13)
411

512

‎Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "Direct state history for janitor pruning that keeps the newest two rows per key. run_001 and run_002 share an hour at the keep boundary, so the tie breaks on the newer run or result id.",
3+
"runs": [["run_000", 10], ["run_001", 12], ["run_002", 12], ["run_003", 13]],
4+
"audit_binding_keys": ["orders.valid_orders", "customers.unique_ids"]
5+
}

‎benchmarks/duckshop/edge_cases/orchestration/incremental_warehouse_history.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
{"available": false, "source": "warehouse.db", "destination": "../retained-warehouse.db", "failure": "read", "tables": ["fingerprints"]},
1616
{"available": true, "source": "../retained-warehouse.db", "destination": "warehouse.db", "failure": null, "tables": ["fingerprints", "source_freshness"]}
1717
],
18+
"held_write_lock": {
19+
"duckdb": [
20+
{
21+
"held": {"failure": "busy", "tables": ["source_freshness"]},
22+
"released": {"failure": null, "tables": ["fingerprints", "source_freshness"]}
23+
}
24+
],
25+
"sqlite": []
26+
},
1827
"insert_sql": [
1928
"INSERT INTO _sqlbuild_fingerprints SELECT node_type,node_name,target_database,target_schema,target_name,'{run_id}',definition_hash,version_hash,schema_fingerprint,definition_b64,metadata_json_b64,'{observed_at}' FROM _sqlbuild_fingerprints WHERE run_id='legacy-run'",
2029
"INSERT INTO _sqlbuild_source_freshness SELECT source_name,target_database,target_schema,target_name,'{run_id}',strategy,value_kind,data_version,data_version_hash,'{observed_at}' FROM _sqlbuild_source_freshness WHERE run_id='legacy-run'"

‎clients/typescript/src/schema.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3333,7 +3333,7 @@ export interface components {
33333333
* @description Closed failure stages keep warehouse errors and credentials out of health observations.
33343334
* @enum {string}
33353335
*/
3336-
WarehouseSyncFailure: "watermark" | "read" | "delivery";
3336+
WarehouseSyncFailure: "watermark" | "read" | "delivery" | "busy";
33373337
WarehouseSyncResponse: {
33383338
applied: boolean;
33393339
};

‎crates/sqlbuild-cli/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlbuild-cli"
3-
version = "0.218.0"
3+
version = "0.219.0"
44
description = "The native `sqb` executable: reused compiles and Python-free commands served without Python, every other command handed to the Python CLI."
55
edition.workspace = true
66
license-file = "LICENSE"

‎crates/sqlbuild-cli/src/argv/command_table.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@
211211
"help": "immutable deployment image identity to pin for workers",
212212
"group": 1
213213
},
214+
{
215+
"kind": "store",
216+
"options": ["--sync-at-least-every"],
217+
"dest": "location_sync_at_least_every",
218+
"help": "for serve, sync the warehouse at least this often, such as 30m; 0 or off turns it off",
219+
"group": 1
220+
},
214221
{
215222
"kind": "store",
216223
"options": ["--run-id"],

‎crates/sqlbuild-cli/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ pub mod diff_report;
1010
pub mod dispatch;
1111
pub mod launcher;
1212
pub mod native_commands;
13-
pub(crate) mod person_login;
13+
pub mod person_login;
1414
pub mod replay;
1515
pub(crate) mod workers;

‎crates/sqlbuild-cli/src/native_commands/_helpers/execution.rs‎

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ use sqlbuild_orchestration::api::errors::ClientError;
1414
use sqlbuild_orchestration::api::main::serve_api::serve_api;
1515

1616
use crate::adhoc::main::adhoc_planner::adhoc_planner;
17+
use sqlbuild_config::project::main::load_control_config::load_control_config;
18+
use sqlbuild_config::project::main::project_config_paths::project_config_paths;
19+
use sqlbuild_config::project::main::sync_interval_seconds::sync_interval_seconds;
20+
use sqlbuild_config::project::models::ControlConfig;
1721
use sqlbuild_orchestration::api::models::{
1822
ApiAuthentication, DevelopmentScope, HumanLogin, ServerFacts,
1923
};
@@ -73,17 +77,17 @@ use crate::native_commands::_helpers::terminal::{
7377
use crate::native_commands::constants::{
7478
ADMIN_COMMAND, COLUMNS_VARIABLE, FALLBACK_COLUMNS, METADATA_OVERLAP_SECONDS,
7579
METADATA_POLL_SECONDS, METADATA_READER_CLOSE_SECONDS, METADATA_RECONCILE_SECONDS,
76-
METADATA_REPLY_BYTES, METADATA_SYNC_CHECK_SECONDS, SCHEDULER_COMMAND,
77-
UNCAUGHT_EXCEPTION_STATUS, UNKNOWN_COMMAND,
80+
METADATA_REPLY_BYTES, METADATA_SAFETY_SYNC_SECONDS, METADATA_SYNC_CHECK_SECONDS,
81+
SAFETY_SYNC_ENV, SCHEDULER_COMMAND, UNCAUGHT_EXCEPTION_STATUS, UNKNOWN_COMMAND,
7882
};
7983
use crate::native_commands::errors::PythonNeeded;
8084
use crate::native_commands::main::_run_admin::run_admin;
8185
use crate::native_commands::main::_run_control::run_control;
8286
use crate::native_commands::main::_run_cost::run_cost;
8387
use crate::native_commands::models::{
8488
CommandOutput, InstalledPackage, LocationCompileRequest, LocationCompiler,
85-
LocationMetadataPage, LocationMetadataSync, LocationServe, LostStdout, NativeCommand,
86-
NativeInvocation, ProjectLocation, ScanToken,
89+
LocationMetadataPage, LocationMetadataSync, LocationServe, LostStdout, MetadataReply,
90+
NativeCommand, NativeInvocation, ProjectLocation, ScanToken,
8791
};
8892
use crate::native_commands::types::LocationPublication;
8993
use crate::workers::main::docker_image_sources::docker_image_sources;
@@ -335,7 +339,7 @@ pub(crate) fn location_result<T: serde::de::DeserializeOwned>(
335339

336340
pub(crate) fn metadata_sync(
337341
(locations, generation): (Vec<WarehouseStateLocation>, i64),
338-
reconcile_seconds: u32,
342+
(reconcile_seconds, safety_seconds): (u32, u64),
339343
) -> LocationMetadataSync {
340344
LocationMetadataSync {
341345
locations,
@@ -355,6 +359,9 @@ pub(crate) fn metadata_sync(
355359
next_at: Instant::now(),
356360
idle: true,
357361
cycle_started_at: None,
362+
safety_seconds,
363+
safety_at: Instant::now() + Duration::from_secs(safety_seconds),
364+
busy: false,
358365
change_tokens: HashMap::new(),
359366
scan_token: None,
360367
scan_delivered: false,
@@ -483,15 +490,9 @@ pub(crate) async fn begin_after_run(
483490
Ok(due) => due,
484491
Err(error) => return (state, Err(error)),
485492
};
486-
let ran = match (state.cycle_started_at, due.runs_ended_at) {
487-
(None, _) => true,
488-
(Some(started_at), Some(ended_at)) => ended_at >= started_at,
489-
(Some(_), None) => false,
490-
};
493+
let ran = state.sync_due(due.runs_ended_at);
491494
if ran {
492-
state.idle = false;
493-
state.cycle_started_at = Some(due.now);
494-
state.next_at = Instant::now();
495+
state.begin_sync(due.now);
495496
}
496497
(state, Ok(ran))
497498
}
@@ -589,6 +590,7 @@ pub(crate) fn next_scan(mut state: LocationMetadataSync) -> LocationMetadataSync
589590
}
590591
state.idle = true;
591592
state.next_at = Instant::now();
593+
state.safety_at = Instant::now() + Duration::from_secs(state.safety_seconds);
592594
drop(write_output(&[(
593595
Stream::Stderr,
594596
"Warehouse history synchronization completed.\n",
@@ -699,16 +701,56 @@ pub(crate) fn location_options(namespace: &Namespace) -> Result<LocationServe, C
699701
"SQLBUILD_METADATA_RECONCILE_SECONDS must be a positive integer".into(),
700702
)
701703
})?;
704+
let environment = match std::env::var(SAFETY_SYNC_ENV) {
705+
Ok(value) => Some(value),
706+
Err(std::env::VarError::NotPresent) => None,
707+
Err(std::env::VarError::NotUnicode(_)) => {
708+
return Err(ControlError::Invalid(format!(
709+
"{SAFETY_SYNC_ENV} must be text"
710+
)));
711+
}
712+
};
713+
let safety_sync_seconds = safety_sync_seconds(
714+
text(namespace, "location_sync_at_least_every").as_deref(),
715+
environment.as_deref(),
716+
|| {
717+
load_control_config(&project_config_paths(&project_dir)).map_err(|failure| {
718+
failure.into_config_failure().map_or_else(
719+
|| "sqlbuild_project.toml could not be read".to_owned(),
720+
|failure| failure.render(|_| "sqlbuild_project.toml".to_owned()),
721+
)
722+
})
723+
},
724+
)
725+
.map_err(ControlError::Invalid)?;
702726
Ok(LocationServe {
703727
project_dir,
704728
server_url: text(namespace, "location_server_url").unwrap_or_default(),
705729
location_id,
706730
target,
707731
image_id: text(namespace, "location_image_id"),
708732
metadata_reconcile_seconds,
733+
safety_sync_seconds,
709734
})
710735
}
711736

737+
/// The safety sync interval from the flag, then the environment, then the project, then thirty minutes.
738+
pub(crate) fn safety_sync_seconds(
739+
flag: Option<&str>,
740+
environment: Option<&str>,
741+
project: impl FnOnce() -> Result<ControlConfig, String>,
742+
) -> Result<u64, String> {
743+
if let Some(text) = flag {
744+
return sync_interval_seconds(text).map_err(|help| format!("--sync-at-least-every {help}"));
745+
}
746+
if let Some(text) = environment.filter(|text| !text.trim().is_empty()) {
747+
return sync_interval_seconds(text).map_err(|help| format!("{SAFETY_SYNC_ENV} {help}"));
748+
}
749+
Ok(project()?
750+
.sync_at_least_every_seconds
751+
.unwrap_or(METADATA_SAFETY_SYNC_SECONDS))
752+
}
753+
712754
/// Reconcile from the server after restarts or lost acknowledgements; transient outages retry.
713755
pub(crate) async fn location_generation(
714756
options: &LocationServe,
@@ -1152,6 +1194,7 @@ pub(crate) async fn read_metadata_page(
11521194
mut state: LocationMetadataSync,
11531195
stopped: impl Future<Output = Result<(), ControlError>>,
11541196
) -> Result<Option<(LocationMetadataSync, Option<WarehouseHistoryPage>)>, ControlError> {
1197+
state.busy = false;
11551198
if let Some(statistics) = &state.statistics
11561199
&& statistics.names.is_empty()
11571200
{
@@ -1181,10 +1224,15 @@ pub(crate) async fn read_metadata_page(
11811224
Duration::from_secs(METADATA_POLL_SECONDS),
11821225
exchange_metadata_read(reader, request),
11831226
) => match result {
1184-
Ok((reader, Ok(page))) => {
1227+
Ok((reader, Ok(MetadataReply::Page(page)))) => {
11851228
state.reader = Some(reader);
11861229
Ok(Some((state, page)))
11871230
}
1231+
Ok((reader, Ok(MetadataReply::Busy))) => {
1232+
state.busy = true;
1233+
state.reader = Some(reader);
1234+
Ok(Some((state, None)))
1235+
}
11881236
Ok((reader, Err(_))) => {
11891237
stop_location_runtime(Some(reader)).await?;
11901238
Ok(Some((state, None)))
@@ -1230,10 +1278,7 @@ pub(crate) async fn close_metadata_reader(
12301278
async fn exchange_metadata_read(
12311279
mut reader: LocationCompiler,
12321280
request: Vec<u8>,
1233-
) -> (
1234-
LocationCompiler,
1235-
Result<Option<WarehouseHistoryPage>, ControlError>,
1236-
) {
1281+
) -> (LocationCompiler, Result<MetadataReply, ControlError>) {
12371282
let result = async {
12381283
reader.stdin.write_all(&request).await?;
12391284
reader.stdin.write_all(b"\n").await?;
@@ -1253,7 +1298,13 @@ async fn exchange_metadata_read(
12531298
"location reply exceeds its byte limit".into(),
12541299
));
12551300
}
1256-
serde_json::from_str(&line)
1301+
let reply: serde_json::Value = serde_json::from_str(&line)
1302+
.map_err(|_| ControlError::Invalid("invalid location reply".into()))?;
1303+
if reply.get("busy") == Some(&serde_json::Value::Bool(true)) {
1304+
return Ok(MetadataReply::Busy);
1305+
}
1306+
serde_json::from_value(reply)
1307+
.map(MetadataReply::Page)
12571308
.map_err(|_| ControlError::Invalid("invalid location reply".into()))
12581309
}
12591310
.await;

0 commit comments

Comments
 (0)