1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Stopped long queries, Read is_open() through TLS, Simplified answers and paging

- [server] query_time_limit (20 s by default) stops a client's query
  through SQLite's progress handler: refused with QueryTimedOut (11). A
  client closing while its query runs stops it too.
- The answer timeout in the DLL (BakaShrot_SetAnswerTimeout /
  GetAnswerTimeout, kept across connections), Python (answer_timeout)
  and C# (AnswerTimeoutMs); QueryTimedOut in every binding.
- is_open() reads what's waiting through TLS: a close_notify says
  closed, TLS's own records keep it open, unasked data or a broken
  stream close it.
- The Rust client checks an answer's type in one place (TryFrom per
  packet); Client::wait() pings while waiting (the tool's --follow).
- Pair::from(&Head), heads_after taking a Pair; simpler SyncState
  paging on both ends; the writer's redundant rollback check dropped.
- codes.rs: the bindings' error codes and copied values match Rust's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 12:17:28 +01:00
parent a6ade535d0
commit 1bae8ee182
37 changed files with 1064 additions and 264 deletions
+1
View File
@@ -33,6 +33,7 @@ synchronous = "full"
max_attachment_size = "1G" # bytes, or K M G T (1024-based); 0: none
retention_interval = "1m" # how often old messages are deleted
idle_database_connections = 8 # kept open once idle, for reads and as many for queries; closed after 1 min unused
query_time_limit = "20s" # a client's query stopped (refused) past it; keep it under the clients' answer timeout (30 s)
# How long each topic's messages are kept, from when they were first
# pushed: 100 years ("36500d") at most, or "forever". A topic takes its
+11
View File
@@ -108,6 +108,14 @@ pub struct Server {
deserialize_with = "values::idle_connections"
)]
pub idle_database_connections: usize,
/// How long a client's query may run before it's stopped and refused
/// (`QueryTimedOut`); 20 s by default. Under the clients' answer timeout
/// (30 s by default), so they get the refusal rather than give up.
#[serde(
default = "defaults::query_time_limit",
deserialize_with = "values::duration"
)]
pub query_time_limit: Duration,
}
/// How hard the database makes sure a push is on disk before answering it
@@ -267,6 +275,9 @@ mod defaults {
pub(crate) fn idle_database_connections() -> usize {
8
}
pub(crate) fn query_time_limit() -> Duration {
Duration::from_secs(20)
}
}
/// `[roles.*]`: each section's name is its role's, none twice.
+7
View File
@@ -60,6 +60,7 @@ fn defaults() {
assert_eq!(server.max_attachment_size, 1 << 30);
assert_eq!(server.retention_interval, Duration::from_secs(60));
assert_eq!(server.idle_database_connections, 8);
assert_eq!(server.query_time_limit, Duration::from_secs(20));
assert_eq!(config.retention.age("logs"), None);
assert_eq!(config.replication.retry_delay, Duration::from_secs(10));
assert_eq!(config.replication.sync_interval, Duration::from_secs(5));
@@ -77,6 +78,7 @@ synchronous = "NORMAL"
max_attachment_size = 0
retention_interval = "1h30m"
idle_database_connections = 0
query_time_limit = "2m"
[replication]
push_to = ["10.0.0.2:7000", "server-3.lan:7001", "[fd00::4]:7000"]
@@ -92,6 +94,7 @@ batch_size = 10000
assert_eq!(config.server.max_attachment_size, 0);
assert_eq!(config.server.retention_interval, Duration::from_secs(5400));
assert_eq!(config.server.idle_database_connections, 0);
assert_eq!(config.server.query_time_limit, Duration::from_secs(120));
assert_eq!(config.replication.push_to.len(), 3);
assert_eq!(config.replication.accept_from[2], "fd00::4");
assert_eq!(config.replication.retry_delay, Duration::from_secs(60));
@@ -306,6 +309,10 @@ fn refusals() {
&with("idle_database_connections = -1\n"),
"invalid value: integer `-1`",
),
(
&with("query_time_limit = \"0s\"\n"),
"'0s' isn't a duration",
),
// [retention]
(
&with("[retention]\nlogs = \"30\"\n"),