Skip to content

feat: Task Management APIs - #1316

Merged
c-thiel merged 17 commits into
mainfrom
ct/report-execution-details
Aug 31, 2025
Merged

c-thiel merged 17 commits into
mainfrom
ct/report-execution-details

Conversation

@c-thiel

@c-thiel c-thiel commented Aug 29, 2025 •

Copy link
Copy Markdown
Member

BEGIN_COMMIT_OVERRIDE
feat: Task Management APIs

chore: Move to parallel unnests in postgres
END_COMMIT_OVERRIDE

Summary by CodeRabbit

  • New Features

    • Task management: list tasks, view task details (with attempt history), and bulk control (stop/cancel) tasks; tasks report progress and parent/child links.
  • API Changes

    • New management endpoints and Task models in OpenAPI; queue names use a typed identifier; pagination page_size is now optional with sensible defaults.
  • Migrations

    • Schema updates: added progress, execution_details, timing fields and new indexes to support task listing and history.

@coderabbitai

coderabbitai Bot commented Aug 29, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Introduces a typed TaskQueueName/TaskEntity system, new Management V1 task endpoints (list, details, control), large Postgres task implementations and SQLx descriptors (list/details/resolve/move-to-log), a migration adding runtime task fields/indexes, pagination/caching helpers, and many tests/docs updates.

Changes

Cohort / File(s) Summary
DB migration & runtime fields
crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
Adds task/task_log columns (progress, execution_details, attempt_scheduled_for, last_heartbeat_at, parent_task_id, task_created_at), reindexes, truncates task_log, and appends new api_endpoints enum values.
Management API surface & docs
crates/lakekeeper/src/api/endpoints.rs, crates/lakekeeper/src/api/management/mod.rs, crates/lakekeeper/src/api/management/v1/tasks.rs, docs/docs/api/management-open-api.yaml
Adds ListTasks, GetTaskDetails, ControlTasks endpoints, handlers, request/response models, OpenAPI schemas and wiring; exposes new public types and handler signatures.
Typed queue/task service types
crates/lakekeeper/src/service/task_queue/*, crates/lakekeeper/src/service/mod.rs
Introduces TaskQueueName, TaskEntity, TaskId/TaskAttemptId, TaskExecutionDetails, TaskConfig trait changes, and Deref/AsRef for TabularDetails.
Catalog API & caching
crates/lakekeeper/src/service/catalog.rs, crates/lakekeeper/src/service/mod.rs
Adds resolve/list/get-details task APIs, TASKS_CACHE (1h), changes resolve_table_ident/table_to_id lifetimes, and migrates queue-name signatures to TaskQueueName.
Postgres implementation — tasks module
crates/lakekeeper/src/implementations/postgres/{mod.rs,catalog.rs,tasks.rs}, crates/lakekeeper/src/implementations/postgres/tasks/*
Renames task_queues → tasks, implements list_tasks, get_task_details, resolve_tasks, typed queue-name usage, heartbeat/check changes (progress, execution_details), batch stop/cancel, insert/result types, and extensive tests.
SQLx descriptors — additions & rewrites
.sqlx/query-84fa33...json, .sqlx/query-97ee55...json, .sqlx/query-9fd8c1...json, .sqlx/query-7bae9e...json, .sqlx/query-7daec1...json, .sqlx/query-1fb053...json, .sqlx/query-883cf0...json, .sqlx/query-517181...json, .sqlx/query-284c387...json
Adds/rewrites multiple task-related SQL descriptors: list/details unions, heartbeat UPDATE...RETURNING, batch status updates, atomic move-to-log/delete+insert flows, and resolve queries.
SQLx descriptors — removals
.sqlx/query-378357...json, .sqlx/query-928930...json, .sqlx/query-b4d4c0...json, .sqlx/query-c853dd...json, .sqlx/query-cc1b53...json, .sqlx/query-94d74c...json, .sqlx/query-bbbadc...json, .sqlx/query-1782897...json
Deletes legacy move/log/delete and older archival SQL descriptors superseded by the new atomic move-to-log and batch flows.
Multi-column UNNEST refactors (SQL)
.sqlx/query-078951...json, .sqlx/query-0b6735...json, .sqlx/query-2b838d...json, .sqlx/query-6eb814...json, .sqlx/query-8cf29b...json, .sqlx/query-bf372c...json, .sqlx/query-c34538...json, .sqlx/query-c94733...json, .sqlx/query-d0b2ee...json, crates/lakekeeper/src/implementations/postgres/{endpoint_statistics/sink.rs,tabular/table/common.rs,tabular/view/mod.rs}
Rewrites many INSERT/SELECTs to use multi-column UNNEST for row-wise alignment and preserved ordering; adjusts one function signature to use PgConnection.
Pagination & token helpers
crates/lakekeeper/src/implementations/postgres/pagination.rs, crates/lakekeeper/src/config.rs, crates/lakekeeper/src/implementations/postgres/{role.rs,user.rs,warehouse.rs}
Adds TryFrom impls for PaginateToken from String/&String; adds page_size_or_pagination_default and adopts it in role/user/warehouse listing logic.
Task listing/details/resolution modules
crates/lakekeeper/src/implementations/postgres/tasks/{get_task_details.rs,list_tasks.rs,resolve_tasks.rs}
New DB-backed implementations parsing task + task_log unions, producing API task shapes, filters, pagination, and resolution across active & historical records; includes extensive tests.
Endpoint statistics & enums
crates/lakekeeper/src/implementations/postgres/endpoint_statistics/sink.rs, .sqlx/query-6eb814...json
Changes to multi-column UNNEST insert and expands allowed api_endpoints enum with the three new management task endpoints.
Tests & minor housekeeping
crates/lakekeeper/src/tests/tasks.rs, crates/io/Cargo.toml, crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs, crates/lakekeeper/src/catalog/tables.rs
Updates tests to use TaskQueueName and execution details; removes utoipa dep from crates/io; small preallocation/readability tweaks.
Utilities
crates/lakekeeper/src/utils/time_conversion.rs
Adds iso8601_option_duration_serde for Option serde and tests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant API as ManagementV1 API
  participant Auth as Authorizer
  participant Catalog
  participant PG as Postgres

  rect rgba(200,220,255,0.12)
  note over Client,API: List tasks
  Client->>API: POST /{warehouse}/task/list
  API->>Auth: authorize_list_tasks
  Auth-->>API: ok
  API->>Catalog: list_tasks(warehouse, query)
  Catalog->>PG: SQL (active_tasks ∪ log_tasks + filters)
  PG-->>Catalog: rows
  Catalog-->>API: ListTasksResponse
  API-->>Client: 200
  end

  rect rgba(200,255,200,0.12)
  note over Client,API: Get task details
  Client->>API: GET /{warehouse}/task/by-id/{task}?numAttempts=n
  API->>Auth: authorize_task_for_table_ids
  Auth-->>API: ok
  API->>Catalog: get_task_details(warehouse, task, n)
  Catalog->>PG: SQL (task ∪ task_log LIMIT n+1)
  PG-->>Catalog: attempt rows
  Catalog-->>API: GetTaskDetailsResponse | 404
  API-->>Client: 200 / 404
  end

  rect rgba(255,230,200,0.12)
  note over Client,API: Control tasks (stop/cancel)
  Client->>API: POST /{warehouse}/task/control
  API->>Auth: authorize_control_tasks (per-entity)
  Auth-->>API: ok
  API->>Catalog: resolve_tasks(warehouse?, task_ids)
  Catalog->>PG: resolve active/log tasks -> map(task -> entity, queue)
  Catalog->>PG: request_tasks_stop / move-to-log (batch SQL)
  PG-->>Catalog: ok
  Catalog-->>API: 204
  API-->>Client: 204
  end
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120+ minutes

Possibly related PRs

Suggested reviewers

  • mooori

Poem

A hop, a skip, I queue by name,
Typed carrots line the tasking lane.
I list and peek with whiskers keen,
I stop and cancel—swift and clean.
Heartbeats hum; logs keep every hop. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ct/report-execution-details

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 24

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
crates/lakekeeper/src/api/management/mod.rs (1)

1469-1499: Docstring mismatch and missing request_body for SetTaskQueueConfig

  • The summary says “Get” but this is the setter endpoint.
  • OpenAPI is missing the body schema; clients won’t see the request shape.
-    /// Get the configuration for a Task Queue.
+    /// Set the configuration for a Task Queue.
@@
-    #[utoipa::path(
-        post,
+    #[utoipa::path(
+        post,
         tag = "tasks",
         path = ManagementV1Endpoint::SetTaskQueueConfig.path(),
         params(("warehouse_id" = Uuid,)),
+        request_body = SetTaskQueueConfigRequest,
         responses(
             (status = 204, description = "Task queue config set successfully"),
             (status = "4XX", body = IcebergErrorResponse),
         )
     )]
crates/lakekeeper/src/implementations/postgres/catalog.rs (1)

796-803: Type mismatch: passing &TaskQueueName to a function taking &str (won’t compile)

set_task_queue_config(transaction, queue_name, ...) calls the Postgres impl that currently takes &str. Either pass queue_name.as_str() here or change the callee to accept &TaskQueueName (recommended for consistency with get_task_queue_config).

Minimal fix here:

-        set_task_queue_config(transaction, queue_name, warehouse_id, config).await
+        set_task_queue_config(transaction, queue_name.as_str(), warehouse_id, config).await

Or, preferred: update crates/lakekeeper/src/implementations/postgres/tasks.rs to accept &TaskQueueName:

- pub(crate) async fn set_task_queue_config(
-     transaction: &mut PgConnection,
-     queue_name: &str,
+ pub(crate) async fn set_task_queue_config(
+     transaction: &mut PgConnection,
+     queue_name: &TaskQueueName,
      warehouse_id: WarehouseId,
      config: SetTaskQueueConfigRequest,
 ) -> crate::api::Result<()> {
@@
-        queue_name,
+        queue_name.as_str(),
@@
-        e.into_error_model(format!("Failed to set task queue config for {queue_name}"))
+        e.into_error_model(format!(
+            "Failed to set task queue config for {}",
+            queue_name.as_str()
+        ))
♻️ Duplicate comments (1)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)

543-568: Remove duplicate helper function

The queue_task_helper and generate_tq_name functions are duplicated across test files. Consider extracting to a shared test module.

🧹 Nitpick comments (57)
.sqlx/query-9fd8c14811fc9e3ebcbc0c209e51dbb81ebc748c77bc911f8a58eaed953bf68c.json (2)

3-3: Skip no-op writes to reduce WAL and bloat.

Add a guard to avoid updating when the new status equals the expected current status.

-  "query": "\n        UPDATE task\n        SET status = $2\n        WHERE task_id = ANY($1) \n-            AND status = $3\n        ",
+  "query": "\n        UPDATE task\n        SET status = $2\n        WHERE task_id = ANY($1)\n+            AND $2 <> $3\n+            AND status = $3\n        ",

3-3: Large batches: consider staging-table join for better plans and lock ordering.

For thousands of IDs, a temp/UNNEST join often plans better and can enforce deterministic lock order (reducing deadlock risk when multiple updaters run).

-  "query": "\n        UPDATE task\n        SET status = $2\n        WHERE task_id = ANY($1) \n-            AND status = $3\n        ",
+  "query": "\n        UPDATE task t\n        SET status = $2\n        FROM (SELECT unnest($1::uuid[]) AS task_id) AS ids\n        WHERE t.task_id = ids.task_id\n+         AND $2 <> $3\n          AND t.status = $3\n        ",

Note: Update the Rust query and re-run cargo sqlx prepare rather than editing JSON directly.

.sqlx/query-cbd0eee2d026dba8f0bf536e2a4a189c84429054c47149ef609c11adfb0ef46a.json (2)

3-3: Option: guard against duplicate log rows

If task_log has/should have a uniqueness constraint (e.g., on (task_id) or (task_id, attempt)), add an upsert to avoid aborts under rare double-submit scenarios.

-            INSERT INTO task_log(task_id,
+            INSERT INTO task_log(task_id,
              ...
-                SELECT task_id,
+                SELECT task_id,
              ...
-                FROM task
-                WHERE task_id = $1)
+                FROM task
+                WHERE task_id = $1)
+            ON CONFLICT (task_id) DO NOTHING

If uniqueness is (task_id, attempt), adjust the conflict target accordingly.


3-3: Option: populate started_at when picked_up_at is null

For tasks never picked up, consider falling back to created_at so logs aren’t missing started_at.

-                       started_at,
-                       picked_up_at,
+                       started_at,
+                       COALESCE(picked_up_at, created_at),
.sqlx/query-b8e9688550c06e3750a16ba53fd24acddfed6c8f4a6a04d1526feaa6c359564e.json (3)

22-33: SQLx enum capture may lag future enum values

The prepared metadata lists only "tabular". If the Postgres enum gains new variants, sqlx offline checks will fail until re-prepared. Make sure migrations and cargo sqlx prepare are coupled in CI to catch drifts.


3-3: Indexing and performance note

Query shape benefits from indexes on task(task_id) and ideally a composite (warehouse_id, task_id) when the warehouse filter is active. The OR $3 pattern can reduce planner’s ability to use the equality filter—another reason to split queries.


3-3: Avoid boolean OR for optional warehouse filter to preserve index use
Both queries in resolve_tasks.rs use (warehouse_id = $2 OR $3) (warehouse_id_is_none toggle) to implement an optional filter. While functionally correct, the OR-boolean pattern can disable the warehouse_id index and may mask unintended full-scope scans if the flag is ever true. Branch in Rust instead: run one query when warehouse_id.is_some() (with WHERE warehouse_id = $1) and a simpler query when .is_none() (omitting that clause). Add an ORDER BY (e.g., task_id) if callers expect deterministic ordering for ANY($1).

.sqlx/query-f7608dcf9e0e7a140d43b6ec2a635c0c419cdee53efb4009328b8ebecf1fd57e.json (5)

3-3: Optional: avoid boolean “short-circuit” predicates that defeat indexes.

Patterns like (status = $3 OR $5) and (queue_name = $2 OR $6) can force seq scans when $5/$6 are true. Consider separate prepared statements per case or array filters (status = ANY($3[])) to keep indexable forms.

If you’d like, I can generate two/three SQLx descriptors covering the common branches to keep plans sargable.


3-3: Optional: lock-and-skip to reduce contention with workers.

If workers update/pick tasks concurrently, add FOR UPDATE SKIP LOCKED to the SELECT. Combined with DELETE … USING log, this avoids blocking and deadlocks under load.

-                        FROM task t
-                        WHERE ($5 OR status = $3) AND warehouse_id = $1 AND ($6 OR queue_name = $2)
+                        FROM task t
+                        WHERE ($5 OR status = $3) AND warehouse_id = $1 AND ($6 OR queue_name = $2)
+                        FOR UPDATE SKIP LOCKED

3-3: Optional: delete only rows that successfully logged (using ON CONFLICT … DO NOTHING + RETURNING).

If task_log has a uniqueness constraint (e.g., on task_id or (task_id, attempt)), an insert conflict currently aborts the whole statement. Using ON CONFLICT DO NOTHING and returning task_id ensures you only delete what actually got logged.

-                        INSERT INTO task_log(task_id,
+                        INSERT INTO task_log(task_id,
                          ...
-                        SELECT ...
+                        SELECT ...
+                        ON CONFLICT DO NOTHING
+                        RETURNING task_id
                     )
-                    DELETE FROM task t
-                    USING log
-                    WHERE t.task_id = log.task_id
+                    DELETE FROM task t
+                    USING log
+                    WHERE t.task_id = log.task_id

Please confirm the unique key on task_log (task_id vs (task_id, attempt)) so we can target the correct constraint if needed.


3-3: Clarify duration nullability semantics.

When picked_up_at is NULL, duration becomes NULL. If consumers expect an interval, consider COALESCE to interval '0' for scheduled-but-never-started tasks.

-                               CASE WHEN picked_up_at IS NOT NULL
-                                 THEN now() - picked_up_at
-                               END,
+                               COALESCE(now() - picked_up_at, interval '0'),

4-39: Safety check: both booleans true wipes all tasks for a warehouse.

If $5 and $6 are true, this archives and deletes every task in the warehouse. Ensure call sites set these flags intentionally and consider a guard to require at least one narrowing predicate.

I can add an additional boolean parameter (e.g., allow_full_warehouse_purge) and a WHERE guard if desired.

.sqlx/query-a055d45b5749e7c6e1fd1c90f8660f26c6436f4f5525ec3059303f925f945c64.json (4)

3-3: Fix timezone arithmetic for duration.

now() AT TIME ZONE 'UTC' - picked_up_at mixes types; use now() - picked_up_at if picked_up_at is timestamptz. If it’s timestamp, standardize the column to timestamptz.


3-3: Clarify “ignore” predicates for readability and planner friendliness.

Rewrite (status = $3 OR $6) → ($6 OR status = $3) and (queue_name = $4 OR $5) → ($5 OR queue_name = $4).

-                        WHERE (status = $3 OR $6) AND task_id = ANY($1) AND (queue_name = $4 OR $5)
+                        WHERE ($6 OR status = $3) AND task_id = ANY($1) AND ($5 OR queue_name = $4)

3-3: Consider row-level locking to avoid concurrent mutation races.

If other workers can update/delete these tasks concurrently, select via a locking CTE (SELECT ... FROM task ... FOR UPDATE) and source the insert from that CTE.


4-39: Enum and column types align
task_log.status is task_final_status, task.status is task_intermediate_status, and queue_name is text. No casts are required for correctness—adding explicit casts (e.g. $2::task_final_status, $3::task_intermediate_status, $4::text) remains an optional clarity improvement.

crates/lakekeeper/src/config.rs (1)

550-554: Delegate page_size_or_pagination_max to page_size_or_pagination_default. Both methods share identical logic; forwarding one to the other eliminates duplication and prevents future divergence.

crates/lakekeeper/src/api/management/v1/project.rs (1)

384-389: Fix stale reference: RangeSpecifier → TimeWindowSelector.

The docs point to RangeSpecifier but the type is TimeWindowSelector.

-    /// Either for a explicit range or a page token to paginate through the results. See the docs of
-    /// `RangeSpecifier` for more details.
+    /// Either for an explicit range or a page token to paginate through the results. See the docs of
+    /// `TimeWindowSelector` for more details.
crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1)

1-6: Use IF EXISTS/IF NOT EXISTS guards for resilient migrations.

Drops/creates will fail if the index doesn’t exist/already exists (common in dev/CI). Guard them.

-DROP INDEX idx_task_warehouse_id;
+DROP INDEX IF EXISTS idx_task_warehouse_id;
-DROP INDEX task_entity_type_entity_id_idx;
+DROP INDEX IF EXISTS task_entity_type_entity_id_idx;
-DROP INDEX task_warehouse_queue_name_idx;
+DROP INDEX IF EXISTS task_warehouse_queue_name_idx;
-DROP INDEX task_log_warehouse_id_idx;
+DROP INDEX IF EXISTS task_log_warehouse_id_idx;
-DROP INDEX task_log_warehouse_id_entity_id_entity_type_idx;
+DROP INDEX IF EXISTS task_log_warehouse_id_entity_id_entity_type_idx;

-CREATE INDEX task_warehouse_created_at_id_idx ON public.task (warehouse_id, created_at DESC);
+CREATE INDEX IF NOT EXISTS task_warehouse_created_at_id_idx ON public.task (warehouse_id, created_at DESC);
-CREATE INDEX task_warehouse_queue_created_at_idx ON public.task (warehouse_id, queue_name, created_at DESC);
+CREATE INDEX IF NOT EXISTS task_warehouse_queue_created_at_idx ON public.task (warehouse_id, queue_name, created_at DESC);

-CREATE INDEX task_log_warehouse_id_entity_type_entity_id_idx ON public.task_log USING btree (
+CREATE INDEX IF NOT EXISTS task_log_warehouse_id_entity_type_entity_id_idx ON public.task_log USING btree (
     warehouse_id,
     entity_id,
     entity_type,
     task_created_at DESC
 );
-CREATE INDEX task_log_warehouse_created_at_id_attempt_idx ON public.task_log (warehouse_id, task_created_at DESC);
+CREATE INDEX IF NOT EXISTS task_log_warehouse_created_at_id_attempt_idx ON public.task_log (warehouse_id, task_created_at DESC);
-CREATE INDEX task_log_warehouse_queue_created_at_idx ON public.task_log (warehouse_id, queue_name, task_created_at DESC);
+CREATE INDEX IF NOT EXISTS task_log_warehouse_queue_created_at_idx ON public.task_log (warehouse_id, queue_name, task_created_at DESC);

Also applies to: 13-16, 24-47

crates/lakekeeper/src/service/task_queue/task_registry.rs (2)

72-74: Consider returning a stable, sorted list of queue names.

Helps produce deterministic API docs and tests.

-    pub async fn queue_names(&self) -> Vec<&'static TaskQueueName> {
-        self.queues.read().await.keys().copied().collect()
-    }
+    pub async fn queue_names(&self) -> Vec<&'static TaskQueueName> {
+        let mut v: Vec<_> = self.queues.read().await.keys().copied().collect();
+        v.sort_unstable();
+        v
+    }

137-169: Guard against duplicate registrations.

Inserting blindly can overwrite an existing queue config/worker and hide misconfigurations. Return Result or log a warning on duplicates.

-    pub async fn register_queue<T: TaskConfig>(&self, task_queue: QueueRegistration) -> &Self {
+    pub async fn register_queue<T: TaskConfig>(&self, task_queue: QueueRegistration) -> &Self {
         let QueueRegistration {
             queue_name,
             worker_fn,
             num_workers,
         } = task_queue;
         let schema_validator_fn = |v| serde_json::from_value::<T>(v).map(|_| ());
         let schema_validator_fn = Arc::new(schema_validator_fn) as ValidatorFn;
         let api_config = QueueApiConfig {
             queue_name,
             utoipa_type_name: T::name().to_string().into(),
             utoipa_schema: utoipa::openapi::RefOr::Ref(utoipa::openapi::Ref::from_schema_name(
                 T::name(),
             )),
         };

-        self.registered_queues.write().await.insert(
+        if let Some(_prev) = self.registered_queues.write().await.insert(
             queue_name,
             RegisteredQueue {
                 api_config,
                 schema_validator_fn,
             },
-        );
+        ) {
+            tracing::warn!("Overwriting registration for queue `{}`", queue_name);
+        }
 
-        self.task_workers.write().await.insert(
+        if let Some(_prev) = self.task_workers.write().await.insert(
             queue_name,
             RegisteredTaskQueueWorker {
                 worker_fn,
                 num_workers,
             },
-        );
+        ) {
+            tracing::warn!("Overwriting worker for queue `{}`", queue_name);
+        }
         self
     }
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (2)

33-41: Constructor addition is good; consider using it at call sites.

Use TabularPurgePayload::new where you construct payloads (e.g., in expiration queue) for consistency.


146-148: Commit failure on read transaction: consider early return.

If committing the read transaction fails, proceeding to IO may mask DB-level issues. Optionally bail out to retry.

-    if let Err(e) = trx.commit().await {
-        tracing::warn!("Failed to commit read transaction for `{QN_STR}` before IO. {e}");
-    }
+    if let Err(e) = trx.commit().await {
+        tracing::warn!("Failed to commit read transaction for `{QN_STR}` before IO. {e}");
+        return;
+    }
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (2)

220-240: Use the new TabularPurgePayload::new constructor.

Minor readability/consistency tweak.

-                TabularPurgePayload {
-                    tabular_type: task.data.tabular_type,
-                    tabular_location,
-                },
+                TabularPurgePayload::new(tabular_location, task.data.tabular_type),

278-414: Test: replace fixed sleep with polling to reduce flakiness.

Poll until condition or timeout, instead of sleeping a fixed 1250ms.

-        tokio::time::sleep(std::time::Duration::from_millis(1250)).await;
+        let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10);
+        loop {
+            let mut trx = PostgresTransaction::begin_read(catalog_state.clone()).await.unwrap();
+            let gone = <PostgresCatalog as Catalog>::list_tabulars(
+                warehouse,
+                None,
+                ListFlags { include_active: false, include_staged: false, include_deleted: true },
+                trx.transaction(),
+                PaginationQuery::empty(),
+            )
+            .await.unwrap()
+            .remove(&tab.table_id.into())
+            .is_none();
+            trx.commit().await.unwrap();
+            if gone || std::time::Instant::now() >= deadline {
+                break;
+            }
+            tokio::time::sleep(std::time::Duration::from_millis(100)).await;
+        }
crates/lakekeeper/src/catalog/tables.rs (1)

1006-1014: AuthZ unwrapping looks correct; tiny readability tweak

into_inner() usage is correct and the permission mapping is sound. Consider avoiding shadowing and improving intent with explicit names.

Apply:

-        let (read_access, write_access) = (read_access.into_inner(), write_access.into_inner());
-
-        let storage_permissions = if write_access {
+        let can_read = read_access.into_inner();
+        let can_write = write_access.into_inner();
+
+        let storage_permissions = if can_write {
             Some(StoragePermissions::ReadWriteDelete)
-        } else if read_access {
+        } else if can_read {
             Some(StoragePermissions::Read)
         } else {
             None
         };
crates/lakekeeper/src/service/mod.rs (1)

501-507: Deref TabularDetails → TableId is fine; consider also AsRef to reduce implicit coercions

Adding AsRef makes call sites explicit without relying on multi-step Deref coercions.

Apply:

 impl Deref for TabularDetails {
     type Target = TableId;

     fn deref(&self) -> &Self::Target {
         &self.table_id
     }
 }
+
+impl AsRef<TableId> for TabularDetails {
+    fn as_ref(&self) -> &TableId {
+        &self.table_id
+    }
+}
crates/lakekeeper/src/api/management/v1/user.rs (1)

132-136: Optional page_size change looks good; fix stale doc default.

page_size is now Option and passed through—LGTM. The doc still says “Default: 100”, which can drift if the server config changes. Suggest clarifying the default source.

Apply this diff to update the comment:

 /// Signals an upper bound of the number of results that a client will receive.
-/// Default: 100
+/// Default: server-configured pagination default
 #[serde(default)]
 pub page_size: Option<i64>,

Also applies to: 146-147

crates/lakekeeper/src/catalog/namespace.rs (1)

142-148: Efficient (id, action) pairing; minor alloc nit.

Building pairs via ids.iter().map(...) is good. If the auth API ever accepts an iterator or slice, you could avoid the intermediate Vec allocation; otherwise this is fine.

crates/lakekeeper/src/api/management/v1/role.rs (1)

106-109: Optional page_size change looks good; fix stale doc default.

Same as users: page_size is now optional—LGTM. Update the doc to avoid a hard-coded “100”.

Apply this diff:

 /// Signals an upper bound of the number of results that a client will receive.
-/// Default: 100
+/// Default: server-configured pagination default
 #[serde(default)]
 pub page_size: Option<i64>,

Also applies to: 124-125

crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (1)

93-109: Clarify JoinError logging.

JoinError isn’t always a panic. Consider distinguishing e.is_panic() vs e.is_cancelled() for clearer logs.

-                Err(e) => tracing::error!(
-                    ?e,
-                    "Task queue {} worker {} panicked: {e}. {log_msg_suffix}",
-                    worker.queue_name,
-                    worker.worker_id
-                ),
+                Err(e) => {
+                    if e.is_panic() {
+                        tracing::error!(?e, "Task queue {} worker {} panicked. {log_msg_suffix}", worker.queue_name, worker.worker_id);
+                    } else if e.is_cancelled() {
+                        tracing::warn!(?e, "Task queue {} worker {} was cancelled.", worker.queue_name, worker.worker_id);
+                    } else {
+                        tracing::error!(?e, "Task queue {} worker {} failed to join. {log_msg_suffix}", worker.queue_name, worker.worker_id);
+                    }
+                }
crates/lakekeeper/src/service/authz/implementations/openfga/api.rs (1)

1382-1384: Route path param is mislabeled (table_id vs view_id).

The router path uses {table_id} for the view access endpoint; the handler extracts a ViewId and the OpenAPI uses {view_id}. Align the placeholder to avoid confusion and doc drift.

-        .route(
-            "/permissions/view/{table_id}/access",
-            get(get_view_access_by_id),
-        )
+        .route(
+            "/permissions/view/{view_id}/access",
+            get(get_view_access_by_id),
+        )
crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (1)

56-61: Micro: preallocate futures vector.

Avoid reallocations for large requests.

-    let all_allowed = futures::future::try_join_all(futs)
+    let all_allowed = futures::future::try_join_all(futs)
         .await?
         .into_iter()
         .all(MustUse::into_inner);

And above:

-    let mut futs = vec![];
+    let mut futs = Vec::with_capacity(tabs.len());
crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1)

67-83: Add negative/extra‑segment test cases.

     #[test]
     fn test_list_tasks_pagination_token_parse() {
         let token = ListTasksPaginationToken {
             task_id: Uuid::new_v4().into(),
             attempt: 3,
         };
 
         let token_str = token.to_string();
         let parsed_token = token_str.parse::<ListTasksPaginationToken>().unwrap();
         assert_eq!(token.task_id, parsed_token.task_id);
         assert_eq!(token.attempt, parsed_token.attempt);
     }
+
+    #[test]
+    fn test_list_tasks_pagination_token_rejects_negative_attempt() {
+        let id = Uuid::new_v4();
+        let s = format!("{id}:-1");
+        assert!(s.parse::<ListTasksPaginationToken>().is_err());
+    }
+
+    #[test]
+    fn test_list_tasks_pagination_token_rejects_extra_segments() {
+        let id = Uuid::new_v4();
+        let s = format!("{id}:1:extra");
+        assert!(s.parse::<ListTasksPaginationToken>().is_err());
+    }
crates/lakekeeper/src/implementations/postgres/pagination.rs (1)

49-58: Consider relaxing trait bounds and add coverage for the new impls

  • The Display bound on T isn’t used in parsing; you can drop it here to reduce constraints.
  • Add unit tests exercising PaginateToken::<T>::try_from(String) and try_from(&String) to prevent regressions (all current tests hit the &str impl).

Apply within this hunk only:

-where
-    T: FromStr + Display,
+where
+    T: FromStr,
.sqlx/query-f93b18686c039d2a54a8c87f9ba89dedd40527cce725cd835f63a1a5660c3fed.json (1)

3-3: Limit placement may underfill pages when one side is sparse

Each CTE applies LIMIT $2 then you UNION ALL and apply a final LIMIT $2. If one source is sparse, you can return fewer than $2 rows even when more exist on the other source. Consider removing the per-CTE limits or increasing them (e.g., LIMIT $2 * 2) to ensure the outer limit can be satisfied.

.sqlx/query-c84f78f4defc288ad8b0f488ac7f364dd8af7f6dd5de5407d9b8c4739b3a99d5.json (1)

3-3: Add an explicit ORDER BY for deterministic attempt ordering

The outer SELECT over combined has no ORDER BY. If the API expects attempts in a specific order (e.g., newest first), add ORDER BY attempt DESC NULLS LAST, attempt_created_at DESC NULLS LAST.

crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (3)

29-29: Use unwrap_or_else for clarity

Consider using unwrap_or_else to avoid evaluating Uuid::nil() when unnecessary.

-    let warehouse_id = warehouse_id.map_or(Uuid::nil(), |id| *id);
+    let warehouse_id = warehouse_id.map_or_else(Uuid::nil, |id| *id);

99-101: Verify the need for or_insert_with

Since the value doesn't involve computation or closures, consider using or_insert instead of or_insert_with.

-        result
-            .entry(task_id)
-            .or_insert_with(|| (entity, queue_name));
+        result
+            .entry(task_id)
+            .or_insert((entity, queue_name));

151-154: Consistent naming for test helpers

The function name uses tq_name while other test helpers use the full queue_name. Consider using consistent naming.

-    fn generate_tq_name() -> TaskQueueName {
+    fn generate_test_queue_name() -> TaskQueueName {
         TaskQueueName::from(format!("test-{}", Uuid::now_v7()))
     }
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)

76-90: Consider renaming for clarity

The function name split_task_status might be confusing as it's actually categorizing statuses into intermediate and final states.

-fn split_task_status(status: &[APITaskStatus]) -> (HashSet<TaskStatus>, HashSet<TaskOutcome>) {
+fn categorize_task_statuses(status: &[APITaskStatus]) -> (HashSet<TaskStatus>, HashSet<TaskOutcome>) {

112-119: Simplify tuple destructuring

The nested map operations could be simplified for better readability.

-    let (pagination_ts, pagination_task_id) = token // token_id is the last returned task_id.
-        .as_ref()
-        .map(
-            |PaginateToken::V1(V1PaginateToken { created_at, id }): &PaginateToken<Uuid>| {
-                (created_at, id)
-            },
-        )
-        .map_or((None, None), |(ts, task_id)| (Some(ts), Some(task_id)));
+    let (pagination_ts, pagination_task_id) = match token.as_ref() {
+        Some(PaginateToken::V1(V1PaginateToken { created_at, id })) => (Some(created_at), Some(id)),
+        None => (None, None),
+    };

343-345: Remove duplicate helper function

This generate_tq_name() helper is duplicated across multiple test files. Consider extracting it to a shared test utilities module.

crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)

152-228: Improve comment clarity

The comment on line 227 could be clearer about why we're adding 1 to the limit.

-        i32::from(num_attempts) // Plus one in query to account for no active task. We need to load one additional history entry.
+        i32::from(num_attempts) // Query limit is num_attempts + 1 to handle the case where there's an active task plus historical attempts
crates/lakekeeper/src/service/authz/implementations/openfga/mod.rs (3)

339-353: Batch-check input shape change looks good; minor polish

  • Avoid recomputing the user per item: cache once to cut string allocations.
  • The generic bound A: From<CatalogNamespaceAction> isn’t used here; consider dropping it to simplify the signature.

Apply:

-    where
-        A: From<CatalogNamespaceAction> + std::fmt::Display + Send,
+    where
+        A: std::fmt::Display + Send,
 {
-        let items: Vec<_> = namespaces_with_actions
+        let user = metadata.actor().to_openfga();
+        let items: Vec<_> = namespaces_with_actions
             .into_iter()
             .map(|(id, a)| CheckRequestTupleKey {
-                user: metadata.actor().to_openfga(),
+                user: user.clone(),
                 relation: a.to_string(),
                 object: id.to_openfga(),
             })
             .collect();

373-390: Same minor nits for tables variant

  • Cache user once.
  • Drop the unused From<CatalogTableAction> bound here.
-    where
-        A: From<CatalogTableAction> + std::fmt::Display + Send,
+    where
+        A: std::fmt::Display + Send,
 {
-        let items: Vec<_> = tables_with_actions
+        let user = metadata.actor().to_openfga();
+        let items: Vec<_> = tables_with_actions
             .into_iter()
             .map(|(id, a)| CheckRequestTupleKey {
-                user: metadata.actor().to_openfga(),
+                user: user.clone(),
                 relation: a.to_string(),
                 object: id.to_openfga(),
             })
             .collect();

410-427: Same minor nits for views variant

  • Cache user once.
  • Drop the unused From<CatalogViewAction> bound here.
-    where
-        A: From<CatalogViewAction> + std::fmt::Display + Send,
+    where
+        A: std::fmt::Display + Send,
 {
-        let items: Vec<_> = views_with_actions
+        let user = metadata.actor().to_openfga();
+        let items: Vec<_> = views_with_actions
             .into_iter()
             .map(|(id, a)| CheckRequestTupleKey {
-                user: metadata.actor().to_openfga(),
+                user: user.clone(),
                 relation: a.to_string(),
                 object: id.to_openfga(),
             })
             .collect();
crates/lakekeeper/src/api/management/mod.rs (1)

1500-1527: Nit: GET doc path constant

You reference SetTaskQueueConfig.path() for the GET doc. It’s fine functionally (same path), but consider using a GetTaskQueueConfig path constant if available for readability. If this is intentional to support the OpenAPI patching logic, ignore.

docs/docs/api/management-open-api.yaml (3)

1174-1177: Nullable integer field needs clarification.

The pageSize field now allows null values via the type array [integer, 'null']. However, this might cause confusion as the OpenAPI spec doesn't clearly distinguish between:

  • Field not provided (undefined)
  • Field explicitly set to null
  • Field set to 0

Consider documenting the behavior for null values and whether there's a meaningful difference from simply omitting the field.


1389-1392: Nullable integer field needs clarification.

Similar to the previous comment, the pageSize field allows null values. The API documentation should clarify the behavior when null is explicitly provided versus when the field is omitted.


1752-1755: Nullable integer field needs clarification.

Another instance of nullable integer for pageSize. Consider establishing a consistent pattern across all pagination parameters in the API and documenting the null behavior in a central location.

crates/lakekeeper/src/implementations/postgres/tasks.rs (4)

541-546: Clamp progress server-side to [0.0, 1.0].

Clients can submit out-of-range progress. Clamp in SQL to enforce invariant.

- r#"WITH heartbeat as (UPDATE task SET last_heartbeat_at = now(), progress = $2, execution_details = $3 WHERE task_id = $1)
+ r#"WITH heartbeat as (UPDATE task SET last_heartbeat_at = now(), progress = GREATEST(0.0, LEAST($2, 1.0)), execution_details = $3 WHERE task_id = $1)

463-505: Align set_task_queue_config with typed queue names.

Public surface elsewhere uses &TaskQueueName. Accept the same here and convert via .as_str() locally; improves consistency and avoids relying on implicit deref.

-pub(crate) async fn set_task_queue_config(
-    transaction: &mut PgConnection,
-    queue_name: &str,
+pub(crate) async fn set_task_queue_config(
+    transaction: &mut PgConnection,
+    queue_name: &TaskQueueName,
     warehouse_id: WarehouseId,
     config: SetTaskQueueConfigRequest,
 ) -> crate::api::Result<()> {
@@
-        queue_name,
+        queue_name.as_str(),
         *warehouse_id,
         serialized,
         max_time_since_last_heartbeat

302-315: Clarify retry semantics: max_retries vs max_attempts.

should_fail uses attempt >= $1. That matches “max_attempts” semantics, not “max_retries”. The naming discrepancy is confusing and can cause off-by-one mistakes at call sites.

  • Either rename the parameter to max_attempts across the surface, or
  • Keep max_retries but switch the predicate to attempt > max_retries.

I can prep a follow-up PR to propagate the rename across trait and callers.


627-637: Use .execute() instead of .fetch_all() for non-SELECT CTEs.

Both statements don’t consume returned rows; .execute() is cheaper and clearer.

-            .fetch_all(connection)
+            .execute(connection)

Also applies to: 690-696

crates/lakekeeper/src/service/catalog.rs (2)

51-64: Cache parameters OK; consider constants and weighing.

1-hour TTL and 10k capacity look fine. For clarity/tuning, consider extracting to const and optionally adding weigh-by-size if TaskQueueName growth is expected.

-            .max_capacity(10000)
+            .max_capacity(TASKS_CACHE_MAX_CAPACITY)

And define:

const TASKS_CACHE_MAX_CAPACITY: u64 = 10_000;

973-980: Heartbeat API surface looks right; consider progress clamping here too.

Mirror the DB-side clamp suggestion in the API docs or at the call site to catch obvious client mistakes early.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9f901c1 and b93bfe1.

📒 Files selected for processing (55)
  • .sqlx/query-333653f674934d91f75b067d3cfd3b4765f143ab8fd5044bdae7722f95ee4de5.json (0 hunks)
  • .sqlx/query-378357060efcef7c0478283c2243a3fe217c7a8f26eff80ada8d0b4ae5d9aea9.json (0 hunks)
  • .sqlx/query-4ece2a87dd529281b81bce92b38400f2377411db02ced2b05de183ffaea1627c.json (1 hunks)
  • .sqlx/query-605d04b9e5eab850dbd526e858561e261424c47e2a4a51c75ff16c8e68120653.json (1 hunks)
  • .sqlx/query-9289301f5b9411e12dd9b636b2ccfe5d962ee0de372efcbc89d94c24115ad7b8.json (0 hunks)
  • .sqlx/query-9fd8c14811fc9e3ebcbc0c209e51dbb81ebc748c77bc911f8a58eaed953bf68c.json (1 hunks)
  • .sqlx/query-a055d45b5749e7c6e1fd1c90f8660f26c6436f4f5525ec3059303f925f945c64.json (1 hunks)
  • .sqlx/query-b4d4c0aa23337a502efb9ab384cb30a7e856fb1fbed90ff62ee8ff965a809c59.json (0 hunks)
  • .sqlx/query-b8e9688550c06e3750a16ba53fd24acddfed6c8f4a6a04d1526feaa6c359564e.json (1 hunks)
  • .sqlx/query-bc7742ca7fc251f064aea139f6a60613d88609471c3eaf45c9f0839b5d9682aa.json (2 hunks)
  • .sqlx/query-bfbada76ae175cd38bed6193ba5a4aa9e7d6821295df46dd2a01ec5d1f06cfb9.json (2 hunks)
  • .sqlx/query-c84f78f4defc288ad8b0f488ac7f364dd8af7f6dd5de5407d9b8c4739b3a99d5.json (1 hunks)
  • .sqlx/query-c853dd4f9c736d06bf347de4f79e144ce5a5c32116fa625214ee221c448305d2.json (0 hunks)
  • .sqlx/query-ca6ad7277dc492fbb0b29dba79c8969998bab7ec3f7d15ff726e79d9926f39e2.json (1 hunks)
  • .sqlx/query-cbd0eee2d026dba8f0bf536e2a4a189c84429054c47149ef609c11adfb0ef46a.json (1 hunks)
  • .sqlx/query-cc1b5371ade0de909e5805fac938344a4423553ea975c2ccc064f754d0e85a69.json (0 hunks)
  • .sqlx/query-d99d134e006fe98804ea82b65afcb0af45732f484b9e2023848ceac4456a16e4.json (2 hunks)
  • .sqlx/query-f7608dcf9e0e7a140d43b6ec2a635c0c419cdee53efb4009328b8ebecf1fd57e.json (1 hunks)
  • .sqlx/query-f93b18686c039d2a54a8c87f9ba89dedd40527cce725cd835f63a1a5660c3fed.json (1 hunks)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1 hunks)
  • crates/lakekeeper/src/api/endpoints.rs (1 hunks)
  • crates/lakekeeper/src/api/management/mod.rs (12 hunks)
  • crates/lakekeeper/src/api/management/v1/project.rs (1 hunks)
  • crates/lakekeeper/src/api/management/v1/role.rs (2 hunks)
  • crates/lakekeeper/src/api/management/v1/tasks.rs (1 hunks)
  • crates/lakekeeper/src/api/management/v1/user.rs (2 hunks)
  • crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (18 hunks)
  • crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (2 hunks)
  • crates/lakekeeper/src/catalog/namespace.rs (3 hunks)
  • crates/lakekeeper/src/catalog/tables.rs (1 hunks)
  • crates/lakekeeper/src/catalog/tabular.rs (2 hunks)
  • crates/lakekeeper/src/config.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/catalog.rs (10 hunks)
  • crates/lakekeeper/src/implementations/postgres/mod.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/pagination.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/role.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (64 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/user.rs (1 hunks)
  • crates/lakekeeper/src/service/authz/implementations/openfga/api.rs (2 hunks)
  • crates/lakekeeper/src/service/authz/implementations/openfga/mod.rs (3 hunks)
  • crates/lakekeeper/src/service/authz/mod.rs (27 hunks)
  • crates/lakekeeper/src/service/catalog.rs (8 hunks)
  • crates/lakekeeper/src/service/mod.rs (1 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (12 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (12 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3 hunks)
  • crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (3 hunks)
  • crates/lakekeeper/src/service/task_queue/task_registry.rs (15 hunks)
  • crates/lakekeeper/src/tests/tasks.rs (6 hunks)
  • crates/lakekeeper/src/utils/time_conversion.rs (3 hunks)
  • docs/docs/api/management-open-api.yaml (15 hunks)
💤 Files with no reviewable changes (6)
  • .sqlx/query-cc1b5371ade0de909e5805fac938344a4423553ea975c2ccc064f754d0e85a69.json
  • .sqlx/query-333653f674934d91f75b067d3cfd3b4765f143ab8fd5044bdae7722f95ee4de5.json
  • .sqlx/query-9289301f5b9411e12dd9b636b2ccfe5d962ee0de372efcbc89d94c24115ad7b8.json
  • .sqlx/query-b4d4c0aa23337a502efb9ab384cb30a7e856fb1fbed90ff62ee8ff965a809c59.json
  • .sqlx/query-c853dd4f9c736d06bf347de4f79e144ce5a5c32116fa625214ee221c448305d2.json
  • .sqlx/query-378357060efcef7c0478283c2243a3fe217c7a8f26eff80ada8d0b4ae5d9aea9.json
🧰 Additional context used
🧬 Code graph analysis (21)
crates/lakekeeper/src/implementations/postgres/mod.rs (2)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1)
  • tasks (249-252)
crates/lakekeeper/src/service/task_queue/mod.rs (1)
  • tasks (312-329)
crates/lakekeeper/src/service/mod.rs (3)
crates/lakekeeper/src/config.rs (1)
  • deref (612-614)
crates/io/src/s3/s3_location.rs (1)
  • deref (215-217)
crates/lakekeeper/src/service/tabular_idents.rs (1)
  • deref (135-139)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • tasks (312-329)
  • task (377-377)
  • task (389-389)
  • record_failure (505-542)
  • record_success (548-584)
  • queue_name (98-98)
  • queue_name (262-264)
  • task_data (223-234)
  • to_uuid (167-171)
crates/lakekeeper/src/api/management/mod.rs (2)
  • from (1627-1632)
  • get_task_details (1559-1569)
crates/lakekeeper/src/api/management/v1/tasks.rs (3)
  • from (118-124)
  • from (128-134)
  • get_task_details (298-341)
crates/lakekeeper/src/implementations/postgres/tasks.rs (7)
  • from (38-42)
  • pick_task (145-236)
  • record_failure (296-427)
  • record_success (238-293)
  • setup_warehouse (798-811)
  • queue_task_batch (45-142)
  • check_and_heartbeat_task (534-557)
crates/lakekeeper/src/catalog/tabular.rs (1)
crates/lakekeeper/src/service/authz/mod.rs (1)
  • into_inner (173-175)
crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (2)
crates/lakekeeper/src/service/task_queue/mod.rs (5)
  • fmt (52-54)
  • fmt (110-112)
  • fmt (768-773)
  • Self (380-380)
  • Self (392-392)
crates/iceberg-ext/src/catalog/rest/error.rs (1)
  • bad_request (127-133)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (4)
crates/lakekeeper/src/service/catalog.rs (2)
  • resolve_tasks (838-864)
  • transaction (82-82)
crates/lakekeeper/src/service/mod.rs (9)
  • new (167-169)
  • new (234-236)
  • from (63-65)
  • from (160-162)
  • from (274-276)
  • from (338-340)
  • from (344-346)
  • from (364-366)
  • to_uuid (423-425)
crates/lakekeeper/src/service/task_queue/mod.rs (7)
  • new (59-61)
  • queue_name (98-98)
  • queue_name (262-264)
  • tasks (312-329)
  • to_uuid (167-171)
  • record_success (548-584)
  • record_failure (505-542)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
  • from (38-42)
  • queue_task_batch (45-142)
  • task_metadata (1347-1354)
  • pick_task (145-236)
  • record_success (238-293)
  • record_failure (296-427)
crates/lakekeeper/src/service/task_queue/mod.rs (7)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
  • new (130-135)
  • queue_name (325-327)
  • queue_name (337-339)
  • serde_json (143-143)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (2)
  • new (48-53)
  • queue_name (68-70)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (2)
  • new (34-39)
  • queue_name (48-50)
crates/lakekeeper/src/tests/tasks.rs (2)
  • queue_name (52-54)
  • SpecializedTask (80-82)
crates/lakekeeper/src/service/catalog.rs (2)
  • transaction (82-82)
  • check_and_heartbeat_task (974-979)
crates/lakekeeper/src/implementations/postgres/catalog.rs (1)
  • check_and_heartbeat_task (780-787)
crates/lakekeeper/src/implementations/postgres/tasks.rs (1)
  • check_and_heartbeat_task (534-557)
crates/lakekeeper/src/implementations/postgres/pagination.rs (2)
crates/lakekeeper/src/service/mod.rs (2)
  • try_from (393-403)
  • try_from (477-490)
crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1)
  • s (52-52)
crates/lakekeeper/src/service/authz/mod.rs (2)
crates/lakekeeper/src/service/authz/implementations/openfga/relations.rs (6)
  • from (76-78)
  • from (82-84)
  • from (912-914)
  • from (918-920)
  • from (1132-1134)
  • from (1138-1140)
crates/lakekeeper/src/request_metadata.rs (1)
  • user_id (64-70)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (8)
crates/lakekeeper/src/service/task_queue/mod.rs (12)
  • tasks (312-329)
  • into_string (69-71)
  • queue_name (98-98)
  • queue_name (262-264)
  • task (377-377)
  • task (389-389)
  • as_str (64-66)
  • to_uuid (167-171)
  • new (59-61)
  • record_success (548-584)
  • record_failure (505-542)
  • cancel_scheduled_tasks (340-358)
crates/iceberg-ext/src/catalog/rest/error.rs (1)
  • internal (161-172)
crates/lakekeeper/src/config.rs (6)
  • None (749-749)
  • from (569-578)
  • default (388-390)
  • default (435-437)
  • default (458-526)
  • s (324-324)
crates/lakekeeper/src/api/management/v1/tasks.rs (6)
  • from (118-124)
  • from (128-134)
  • split (139-148)
  • list_tasks (239-295)
  • entities (380-391)
  • entities (392-408)
crates/lakekeeper/src/implementations/postgres/tasks.rs (9)
  • from (38-42)
  • pick_task (145-236)
  • setup_warehouse (798-811)
  • queue_task_batch (45-142)
  • task_metadata (1347-1354)
  • generate_tq_name (747-749)
  • record_success (238-293)
  • record_failure (296-427)
  • cancel_scheduled_tasks (567-700)
crates/lakekeeper/src/service/task_queue/task_registry.rs (7)
  • queue_names (72-74)
  • is_empty (241-243)
  • queue_name (325-327)
  • queue_name (337-339)
  • serde_json (143-143)
  • default (103-105)
  • new (130-135)
crates/lakekeeper/src/implementations/postgres/pagination.rs (4)
  • try_from (44-46)
  • try_from (55-57)
  • try_from (67-109)
  • s (87-87)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (2)
  • queue_task_helper (543-568)
  • generate_tq_name (570-572)
crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (1)
crates/lakekeeper/src/service/authz/mod.rs (1)
  • into_inner (173-175)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)
crates/lakekeeper/src/tests/tasks.rs (2)
  • SpecializedTask (80-82)
  • queue_name (52-54)
crates/lakekeeper/src/catalog/io.rs (1)
  • remove_all (74-79)
crates/io/src/lib.rs (3)
  • remove_all (220-293)
  • remove_all (422-439)
  • new (125-132)
crates/lakekeeper/src/service/task_queue/mod.rs (8)
  • new (59-61)
  • Self (380-380)
  • Self (392-392)
  • queue_name (98-98)
  • queue_name (262-264)
  • task (377-377)
  • task (389-389)
  • poll_for_new_task (418-463)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (8)
  • queue_name (98-98)
  • queue_name (262-264)
  • Self (380-380)
  • Self (392-392)
  • new (59-61)
  • from (46-48)
  • from (116-118)
  • from (122-124)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (3)
  • queue_name (68-70)
  • tabular_purge_queue (220-220)
  • new (48-53)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (2)
  • queue_name (48-50)
  • new (34-39)
crates/lakekeeper/src/tests/tasks.rs (1)
  • queue_name (52-54)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (4)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
  • tabular_purge_queue (208-208)
  • new (130-135)
  • queue_name (325-327)
  • queue_name (337-339)
crates/lakekeeper/src/tests/tasks.rs (2)
  • SpecializedTask (80-82)
  • queue_name (52-54)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • new (59-61)
  • Self (380-380)
  • Self (392-392)
  • queue_name (98-98)
  • queue_name (262-264)
  • task (377-377)
  • task (389-389)
  • poll_for_new_task (418-463)
  • schedule_task (273-297)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)
  • new (34-39)
  • queue_name (48-50)
  • task (103-103)
  • task (111-111)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
crates/lakekeeper/src/api/management/mod.rs (5)
  • get_task_details (1559-1569)
  • list_tasks (1539-1546)
  • from (1627-1632)
  • get_task_queue_config (1513-1526)
  • set_task_queue_config (1482-1498)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (144-243)
crates/lakekeeper/src/service/catalog.rs (8)
  • get_task_details (911-918)
  • list_tasks (928-934)
  • resolve_tasks (838-864)
  • transaction (82-82)
  • check_and_heartbeat_task (974-979)
  • cancel_scheduled_tasks (966-971)
  • get_task_queue_config (997-1001)
  • set_task_queue_config (990-995)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (93-269)
  • tasks (249-252)
  • status (77-80)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (19-105)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • queue_name (98-98)
  • queue_name (262-264)
  • tasks (312-329)
  • max_time_since_last_heartbeat (89-91)
  • task (377-377)
  • task (389-389)
  • as_str (64-66)
  • cancel_scheduled_tasks (340-358)
  • queue_config (240-257)
crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (8)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
  • tabular_expiration_queue (188-188)
  • queue_name (325-327)
  • queue_name (337-339)
  • validate_config_fn (51-57)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (3)
  • TabularExpirationTask (80-80)
  • TabularExpirationTask (341-341)
  • queue_name (68-70)
crates/lakekeeper/src/service/task_queue/mod.rs (2)
  • queue_name (98-98)
  • queue_name (262-264)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)
  • queue_name (48-50)
crates/lakekeeper/src/api/management/mod.rs (2)
  • set_task_queue_config (1482-1498)
  • get_task_queue_config (1513-1526)
crates/lakekeeper/src/implementations/postgres/catalog.rs (2)
  • set_task_queue_config (796-803)
  • get_task_queue_config (805-811)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • set_task_queue_config (463-506)
  • get_task_queue_config (429-461)
crates/lakekeeper/src/service/catalog.rs (3)
  • set_task_queue_config (990-995)
  • transaction (82-82)
  • get_task_queue_config (997-1001)
crates/lakekeeper/src/api/management/mod.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • tasks (249-252)
  • list_tasks (93-269)
  • status (77-80)
crates/lakekeeper/src/service/task_queue/mod.rs (6)
  • tasks (312-329)
  • queue_name (98-98)
  • queue_name (262-264)
  • from (46-48)
  • from (116-118)
  • from (122-124)
crates/lakekeeper/src/api/management/v1/tasks.rs (5)
  • control_tasks (344-443)
  • get_task_details (298-341)
  • list_tasks (239-295)
  • from (118-124)
  • from (128-134)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (144-243)
crates/lakekeeper/src/service/catalog.rs (3)
  • get_task_details (911-918)
  • list_tasks (928-934)
  • set_task_queue_config (990-995)
crates/lakekeeper/src/implementations/postgres/tasks.rs (1)
  • set_task_queue_config (463-506)
crates/lakekeeper/src/api/management/v1/tasks.rs (8)
crates/lakekeeper/src/api/management/mod.rs (4)
  • from (1627-1632)
  • list_tasks (1539-1546)
  • get_task_details (1559-1569)
  • control_tasks (1584-1593)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • from (38-42)
  • cancel_scheduled_tasks (567-700)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • Self (380-380)
  • Self (392-392)
  • tasks (312-329)
  • queue_name (98-98)
  • queue_name (262-264)
  • cancel_scheduled_tasks (340-358)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (93-269)
  • entities (133-142)
  • tasks (249-252)
crates/lakekeeper/src/service/catalog.rs (8)
  • list_tasks (928-934)
  • begin_read (76-76)
  • get_task_details (911-918)
  • resolve_required_tasks (866-885)
  • begin_write (74-74)
  • stop_tasks (985-988)
  • clear_tabular_deleted_at (502-506)
  • cancel_scheduled_tasks (966-971)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (144-243)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
crates/lakekeeper/src/implementations/postgres/catalog.rs (3)
  • stop_tasks (789-794)
  • clear_tabular_deleted_at (252-263)
  • cancel_scheduled_tasks (771-778)
crates/lakekeeper/src/implementations/postgres/catalog.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (249-252)
  • list_tasks (93-269)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • tasks (312-329)
  • cancel_scheduled_tasks (340-358)
  • Self (380-380)
  • Self (392-392)
  • queue_name (98-98)
  • queue_name (262-264)
  • max_time_since_last_heartbeat (89-91)
  • record_success (548-584)
  • record_failure (505-542)
crates/lakekeeper/src/implementations/postgres/tasks.rs (8)
  • cancel_scheduled_tasks (567-700)
  • get_task_queue_config (429-461)
  • queue_task_batch (45-142)
  • request_tasks_stop (508-532)
  • set_task_queue_config (463-506)
  • pick_task (145-236)
  • record_success (238-293)
  • record_failure (296-427)
crates/lakekeeper/src/service/catalog.rs (13)
  • cancel_scheduled_tasks (966-971)
  • get_task_details (911-918)
  • get_task_queue_config (997-1001)
  • list_tasks (928-934)
  • resolve_tasks (838-864)
  • set_task_queue_config (990-995)
  • transaction (82-82)
  • resolve_tasks_impl (829-833)
  • record_task_success (887-891)
  • get_task_details_impl (902-907)
  • list_tasks_impl (921-925)
  • enqueue_tasks (942-946)
  • stop_tasks (985-988)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (144-243)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (19-105)
crates/lakekeeper/src/tests/tasks.rs (6)
crates/lakekeeper/src/service/task_queue/mod.rs (6)
  • new (59-61)
  • queue_name (98-98)
  • queue_name (262-264)
  • task (377-377)
  • task (389-389)
  • pick_new_task (365-414)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (4)
  • new (48-53)
  • queue_name (68-70)
  • task (128-128)
  • task (244-244)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)
  • new (34-39)
  • queue_name (48-50)
  • task (103-103)
  • task (111-111)
crates/lakekeeper/src/service/task_queue/task_registry.rs (3)
  • new (130-135)
  • queue_name (325-327)
  • queue_name (337-339)
crates/lakekeeper/src/implementations/postgres/catalog.rs (1)
  • pick_new_task (694-705)
crates/lakekeeper/src/service/catalog.rs (1)
  • pick_new_task (820-824)
crates/lakekeeper/src/service/catalog.rs (6)
crates/lakekeeper/src/service/task_queue/mod.rs (7)
  • tasks (312-329)
  • new (59-61)
  • Self (380-380)
  • Self (392-392)
  • pick_new_task (365-414)
  • queue_name (98-98)
  • queue_name (262-264)
crates/lakekeeper/src/implementations/postgres/catalog.rs (11)
  • resolve_table_ident (188-195)
  • pick_new_task (694-705)
  • resolve_tasks_impl (707-713)
  • record_task_success (715-721)
  • get_task_details_impl (738-745)
  • list_tasks_impl (748-754)
  • enqueue_tasks (756-769)
  • check_and_heartbeat_task (780-787)
  • stop_tasks (789-794)
  • set_task_queue_config (796-803)
  • get_task_queue_config (805-811)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (19-105)
crates/lakekeeper/src/api/management/v1/tasks.rs (2)
  • get_task_details (298-341)
  • list_tasks (239-295)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (144-243)
crates/lakekeeper/src/implementations/postgres/tasks.rs (3)
  • check_and_heartbeat_task (534-557)
  • set_task_queue_config (463-506)
  • get_task_queue_config (429-461)

Comment thread crates/lakekeeper/src/config.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
crates/lakekeeper/src/implementations/postgres/warehouse.rs (3)

680-688: Keyset pagination can skip rows with equal timestamps; add a stable tiebreaker

Current predicate uses only timestamp < token_ts; rows sharing the same timestamp can be skipped between pages. Use a secondary key (created_at) stored in the token’s id and include it in the WHERE and ORDER BY.

Apply:

@@
-    let token = page_token
-        .as_option()
-        .map(PaginateToken::try_from)
-        .transpose()?;
-
-    let (token_ts, _): (_, Option<String>) = token
-        .map(|PaginateToken::V1(V1PaginateToken { created_at, id })| (created_at, id))
-        .unzip();
+    let token = page_token
+        .as_option()
+        .map(PaginateToken::try_from)
+        .transpose()?;
+
+    // Primary cursor: timestamp; Secondary: created_at (encoded in token.id as RFC3339)
+    let (token_ts, token_created_at): (Option<chrono::DateTime<chrono::Utc>>, Option<chrono::DateTime<chrono::Utc>>) =
+        match token {
+            Some(PaginateToken::V1(V1PaginateToken { created_at, id })) => {
+                let secondary = chrono::DateTime::parse_from_rfc3339(&id)
+                    .ok()
+                    .map(|dt| dt.with_timezone(&chrono::Utc));
+                (Some(created_at), secondary)
+            }
+            None => (None, None),
+        };
@@
-    let stats = sqlx::query!(
+    let stats = sqlx::query!(
         r#"
         SELECT
             number_of_views as "number_of_views!",
             number_of_tables as "number_of_tables!",
             created_at as "created_at!",
             updated_at,
             timestamp as "timestamp!"
         FROM (
             (SELECT number_of_views, number_of_tables, created_at, updated_at, timestamp
             FROM warehouse_statistics
             WHERE warehouse_id = $1
-            AND (timestamp < $2 OR $2 IS NULL))
+            AND (
+                $2 IS NULL
+                OR timestamp < $2
+                OR (timestamp = $2 AND created_at < $3)
+            ))
 
             UNION ALL
 
             (SELECT number_of_views, number_of_tables, created_at, updated_at, timestamp
             FROM warehouse_statistics_history
             WHERE warehouse_id = $1
-            AND (timestamp < $2 OR $2 IS NULL))
+            AND (
+                $2 IS NULL
+                OR timestamp < $2
+                OR (timestamp = $2 AND created_at < $3)
+            ))
         ) AS ww
-        ORDER BY timestamp DESC
-        LIMIT $3
+        ORDER BY timestamp DESC, created_at DESC
+        LIMIT $4
         "#,
-        warehouse_ident.0,
-        token_ts,
-        page_size
+        warehouse_ident.0,
+        token_ts,
+        token_created_at,
+        page_size
     )
@@
-    let next_page_token = stats.last().map(|s| {
-        PaginateToken::V1(V1PaginateToken {
-            created_at: s.timestamp,
-            id: String::new(),
-        })
-        .to_string()
-    });
+    let next_page_token = stats.last().map(|s| {
+        PaginateToken::V1(V1PaginateToken {
+            created_at: s.timestamp,
+            // encode secondary cursor
+            id: s.created_at.to_rfc3339(),
+        })
+        .to_string()
+    });

Also applies to: 689-716, 724-730


445-451: Critical: CTE deletes tasks even when we return CONFLICT

The WITH deletes CTE runs unconditionally, so tasks are removed even if we later detect unfinished tasks and bail. This is destructive.

Remove the deletes CTE:

-    let unfinished_task_counts_per_queue = sqlx::query!(
-        r#"WITH running_tasks as (SELECT task_id, queue_name, status from task WHERE warehouse_id = $1),
-                deletes as (DELETE FROM task where warehouse_id = $1)
-            SELECT COUNT(task_id) as "task_count!", queue_name FROM running_tasks GROUP BY queue_name"#,
+    let unfinished_task_counts_per_queue = sqlx::query!(
+        r#"WITH running_tasks as (
+               SELECT task_id, queue_name, status
+               FROM task
+               WHERE warehouse_id = $1
+           )
+           SELECT COUNT(task_id) as "task_count!", queue_name
+           FROM running_tasks
+           GROUP BY queue_name"#,
         *warehouse_id,
     ).fetch_all(&mut **transaction).await.map_err(|e| e.into_error_model("Error deleting tasks for warehouse"))?;

468-468: Delete tasks only after confirming none are unfinished

Once the early-exit check passes, delete the tasks before dropping the warehouse.

Insert:

+    // Safe to delete tasks now that we confirmed none are unfinished.
+    sqlx::query!(r#"DELETE FROM task WHERE warehouse_id = $1"#, *warehouse_id)
+        .execute(&mut **transaction)
+        .await
+        .map_err(|e| e.into_error_model("Error deleting tasks for warehouse"))?;
docs/docs/api/management-open-api.yaml (2)

2245-2276: Path param ‘queue_name’ is declared but missing from the path.

Route /management/v1/{warehouse_id}/task-queue/tabular_expiration/config defines a path parameter queue_name that isn’t in the path. Either add {queue_name} to the path or drop/convert the parameter (e.g., query).

Apply one of:

  • Change path: /management/v1/{warehouse_id}/task-queue/{queue_name}/tabular_expiration/config
  • Or remove the queue_name path parameter here.

2311-2368: Same mismatch for tabular_purge config.

queue_name is a path param but isn’t in the path. Align schema with the actual route.

See previous comment for fix options; apply consistently.

crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (1)

976-1007: Validate max_seconds_since_last_heartbeat > 0 before persisting

Prevent negative/zero values early to avoid nonsensical heartbeat windows and DB churn.

         // ------------------- Business Logic -------------------
         let task_queues = context.v1_state.registered_task_queues;

         if let Some(validate_config_fn) = task_queues.validate_config_fn(queue_name).await {
             validate_config_fn(request.queue_config.0.clone()).map_err(|e| {
                 ErrorModel::bad_request(
                     format!(
                         "Failed to deserialize queue config for queue-name '{queue_name}': '{e}'"
                     ),
                     "InvalidQueueConfig",
                     Some(Box::new(e)),
                 )
             })?;
         } else {
             let mut existing_queue_names = task_queues.queue_names().await;
             existing_queue_names.sort_unstable();
             let existing_queue_names = existing_queue_names.iter().join(", ");
             return Err(ErrorModel::bad_request(
                 format!(
                     "Queue '{queue_name}' not found! Existing queues: [{existing_queue_names}]"
                 ),
                 "QueueNotFound",
                 None,
             )
             .into());
         }
+
+        // Basic sanity check for heartbeat override
+        if let Some(s) = request.max_seconds_since_last_heartbeat {
+            if s <= 0 {
+                return Err(ErrorModel::bad_request(
+                    "max_seconds_since_last_heartbeat must be greater than 0",
+                    "InvalidQueueConfig",
+                    None,
+                )
+                .into());
+            }
+        }

         let mut transaction = C::Transaction::begin_write(context.v1_state.catalog).await?;
crates/lakekeeper/src/api/management/mod.rs (1)

1469-1481: Fix doc string and document request body for SetTaskQueueConfig

The handler consumes Json but OpenAPI lacks request_body; the summary also says “Get”.

-    /// Get the configuration for a Task Queue.
+    /// Set the configuration for a Task Queue.
     ///
     /// These configurations are global per warehouse and shared across all instances of this kind of task.
     #[utoipa::path(
         post,
         tag = "tasks",
         path = ManagementV1Endpoint::SetTaskQueueConfig.path(),
         params(("warehouse_id" = Uuid,)),
+        request_body = SetTaskQueueConfigRequest,
         responses(
             (status = 204, description = "Task queue config set successfully"),
             (status = "4XX", body = IcebergErrorResponse),
         )
     )]
♻️ Duplicate comments (2)
crates/lakekeeper/src/api/management/mod.rs (2)

1528-1547: ListTasks OpenAPI now includes request_body — resolved

Request body is correctly documented.


1572-1585: ControlTasks OpenAPI now includes request_body — resolved

The payload is now documented; description mentions limits.

🧹 Nitpick comments (20)
crates/lakekeeper/src/implementations/postgres/warehouse.rs (3)

452-466: Mismatch: we say “unfinished tasks” but we count all tasks

The SELECT does not filter by status; completed/cancelled tasks will block deletion. If intent is “unfinished,” filter statuses accordingly (e.g., NOT IN [Completed, Failed, Cancelled]) or reuse the task status enum.

If you share the canonical “terminal” statuses, I can propose the exact predicate.


417-426: Minor: OR boolean short-circuit may inhibit index usage

WHERE project_id = ANY($1) OR $2 (with $2 often true) can defeat index use. Consider:

  • Build the SQL conditionally (two queries), or
  • Use COALESCE with NULL $1 and rewrite as project_id = ANY(COALESCE($1, ARRAY[]::uuid[])) when $2 is false and run a separate SELECT when $2 is true.

717-722: Optional: use streaming to cap memory for large defaults

fetch_all buffers all rows. If default page size is large, consider fetch (stream) and collect up to page_size to avoid spikes.

crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (3)

1-5: Use IF EXISTS when dropping indexes to make migration resilient across environments.

If a target has drifted or a fresh env never had these indexes, the migration will fail. Prefer IF EXISTS on DROP INDEX statements.

Apply:

-DROP INDEX idx_task_warehouse_id;
-DROP INDEX task_entity_type_entity_id_idx;
-DROP INDEX task_warehouse_queue_name_idx;
+DROP INDEX IF EXISTS idx_task_warehouse_id;
+DROP INDEX IF EXISTS task_entity_type_entity_id_idx;
+DROP INDEX IF EXISTS task_warehouse_queue_name_idx;

20-22: Same resilience for task_log index drops.

Mirror IF EXISTS for task_log index drops to avoid brittle migrations.

-DROP INDEX task_log_warehouse_id_idx;
-DROP INDEX task_log_warehouse_id_entity_id_entity_type_idx;
+DROP INDEX IF EXISTS task_log_warehouse_id_idx;
+DROP INDEX IF EXISTS task_log_warehouse_id_entity_id_entity_type_idx;

48-52: ALTER TYPE ADD VALUE inside transactional migration may fail depending on Postgres version/config.

Many setups run migrations in a transaction; ALTER TYPE ... ADD VALUE historically required autocommit. Ensure your migration runner executes these statements outside a transaction or split them into a separate, non-transactional migration.

If needed, move the three ALTER TYPE statements into a dedicated migration file configured to run without a transaction.

crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (2)

42-45: Minor: avoid temporary Vec allocation for ANY($1).

Passing a slice avoids allocating a new Vec each call.

-        &task_ids.iter().map(|id| **id).collect_vec(),
+        &task_ids.iter().map(|id| **id).collect::<Vec<_>>()[..],

Or keep TaskId as Uuid in the input to skip mapping entirely.


72-81: DISTINCT ON ordering is correct; consider documenting the intent.

ORDER BY task_id, attempt DESC guarantees the latest attempt per task. A short comment will prevent accidental future changes.

         SELECT DISTINCT ON (task_id)
@@
-        ORDER BY task_id, attempt DESC
+        -- DISTINCT ON returns the first row per task_id; order attempts DESC to pick the latest
+        ORDER BY task_id, attempt DESC
crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1)

20-38: Parser is now strict and defensive. Add negative/extra-segment tests.

Logic looks good. Add tests to lock behavior for extra “:” and negative attempts.

@@
 mod tests {
@@
     fn test_list_tasks_pagination_token_parse() {
@@
     }
+
+    #[test]
+    fn test_token_rejects_extra_segments() {
+        assert!(matches!(
+            "00000000-0000-0000-0000-000000000000:1:2".parse::<ListTasksPaginationToken>(),
+            Err(_)
+        ));
+    }
+
+    #[test]
+    fn test_token_rejects_negative_attempt() {
+        let id = Uuid::nil();
+        let s = format!("{id}:-1");
+        assert!(s.parse::<ListTasksPaginationToken>().is_err());
+    }
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)

127-141: Status split is fine; prefer owned Vecs for SQLx enum arrays.

Passing Vec<&T> may work but is brittle; pass Vec to avoid encoding surprises with enum arrays.

-    let (task_status_filter, task_log_status_filter) = split_task_status(&status_filter);
+    let (task_status_filter, task_log_status_filter) = split_task_status(&status_filter);
+    let task_status_filter_vec: Vec<TaskStatus> =
+        task_status_filter.iter().copied().collect();
+    let task_log_status_filter_vec: Vec<TaskOutcome> =
+        task_log_status_filter.iter().copied().collect();

And update bindings:

-        task_status_filter.iter().collect_vec() as Vec<_>,
-        task_log_status_filter.iter().collect_vec() as Vec<_>,
+        task_status_filter_vec,
+        task_log_status_filter_vec,

146-176: Pagination windowing per-source (active/log) is intentional; add a note.

Limiting each CTE to page_size biases toward active tasks when plentiful. If this is desired, add a comment; if not, remove per-CTE LIMITs and keep only the final LIMIT.

-            ORDER BY task_created_at DESC, task_id DESC
-            LIMIT $2
+            ORDER BY task_created_at DESC, task_id DESC
+            LIMIT $2 -- Limit within active tasks to prefer active over historical
@@
-            ORDER BY task_created_at DESC, task_id DESC, attempt DESC
-            LIMIT $2
+            ORDER BY task_created_at DESC, task_id DESC, attempt DESC
+            LIMIT $2 -- Limit within historical tasks

If equal treatment across sources is desired, drop the per-CTE LIMITs and rely on the final LIMIT.


146-166: Use created_at alias consistently in ORDER BY.

You order by task_created_at but the WHERE uses raw created_at/task_created_at. It’s correct; just add a brief comment to avoid future mismatches.

-            ORDER BY task_created_at DESC, task_id DESC
+            -- Use the unified alias to order across sources
+            ORDER BY task_created_at DESC, task_id DESC
docs/docs/api/management-open-api.yaml (1)

2376-2478: New Tasks endpoints look consistent; consider adding 401/403 responses for auth failures.

Other management endpoints commonly document 4XX. Adding explicit 401/403 improves client expectations.

Add 401/403 with IcebergErrorResponse for the three tasks endpoints.

crates/lakekeeper/src/service/task_queue/mod.rs (2)

34-73: Provide AsRef for TaskQueueName

Deref works, but AsRef makes API ergonomics and trait bounds simpler.

 impl TaskQueueName {
@@
 }
 
+impl AsRef<str> for TaskQueueName {
+    fn as_ref(&self) -> &str {
+        &self.0
+    }
+}

465-506: Clamp progress to [0.0, 1.0] before heartbeat

Prevents accidental negative or >1.0 progress being stored.

     pub async fn heartbeat<C: Catalog>(
         &self,
         transaction: <C::Transaction as Transaction<C::State>>::Transaction<'_>,
-        progress: f32,
+        mut progress: f32,
         execution_details: Option<E>,
     ) -> Result<TaskCheckState, ErrorModel> {
+        progress = progress.clamp(0.0, 1.0);
crates/lakekeeper/src/implementations/postgres/catalog.rs (1)

804-812: Prefer passing typed queue_name all the way down

Catalog takes &TaskQueueName; the DB layer’s set_task_queue_config still accepts &str. Consider standardizing on &TaskQueueName in tasks.rs for consistency and fewer conversions.

crates/lakekeeper/src/implementations/postgres/tasks.rs (2)

471-476: Standardize set_task_queue_config to take &TaskQueueName

Aligns with get_task_queue_config and upstream calls; use as_str() at the SQL edge.

-pub(crate) async fn set_task_queue_config(
-    transaction: &mut PgConnection,
-    queue_name: &str,
+pub(crate) async fn set_task_queue_config(
+    transaction: &mut PgConnection,
+    queue_name: &TaskQueueName,
     warehouse_id: WarehouseId,
     config: SetTaskQueueConfigRequest,
 ) -> crate::api::Result<()> {
@@
     sqlx::query!(
@@
-        queue_name,
+        queue_name.as_str(),
         *warehouse_id,
         serialized,
         max_time_since_last_heartbeat

Also applies to: 501-505


645-655: Use execute() instead of fetch_all() for non-returning CTE + DELETE

These statements don’t return rows; execute() avoids building Vecs and reduces overhead.

-            .fetch_all(connection)
+            .execute(connection)
             .await
@@
-            .fetch_all(connection)
+            .execute(connection)
             .await

Also applies to: 709-715

crates/lakekeeper/src/service/catalog.rs (2)

1-5: MSRV check: std::sync::LazyLock requires a recent Rust

LazyLock stabilized in recent Rust. Verify your MSRV or switch to once_cell::sync::Lazy to avoid build breaks on older toolchains.

Would you like me to prep a fallback patch using once_cell::sync::Lazy?


51-64: Tasks cache: good addition; consider configurability and invalidation hooks

  • Make TTL/capacity configurable (env/CONFIG) to tune under different workloads.
  • Invalidate entries on task state changes (success/failure/stop/cancel) to reduce stale reads, not just TTL.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b93bfe1 and dec2baa.

📒 Files selected for processing (14)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1 hunks)
  • crates/lakekeeper/src/api/management/mod.rs (12 hunks)
  • crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (16 hunks)
  • crates/lakekeeper/src/config.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/catalog.rs (9 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (62 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/warehouse.rs (1 hunks)
  • crates/lakekeeper/src/service/catalog.rs (8 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (12 hunks)
  • docs/docs/api/management-open-api.yaml (15 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
  • crates/lakekeeper/src/config.rs
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs
  • crates/lakekeeper/src/implementations/postgres/catalog.rs
  • crates/lakekeeper/src/implementations/postgres/tasks.rs
📚 Learning: 2025-08-30T10:23:41.114Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

Applied to files:

  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
📚 Learning: 2025-08-30T10:27:47.855Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:44-47
Timestamp: 2025-08-30T10:27:47.855Z
Learning: The task_log table has a composite primary key on (task_id, attempt), not just task_id alone. With limited attempts per task_id, no additional indexing on task_id is needed as confirmed by c-thiel.

Applied to files:

  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
📚 Learning: 2025-08-30T10:27:47.855Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:44-47
Timestamp: 2025-08-30T10:27:47.855Z
Learning: In the task_log table, task_id is the primary key with limited occurrences per task_id, so additional indexing on task_id is unnecessary as confirmed by c-thiel.

Applied to files:

  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
🧬 Code graph analysis (9)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (15)
  • tasks (312-329)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • into_string (69-71)
  • queue_name (98-98)
  • queue_name (262-264)
  • task (377-377)
  • task (389-389)
  • as_str (64-66)
  • to_uuid (167-171)
  • new (59-61)
  • record_success (554-590)
  • record_failure (511-548)
  • cancel_scheduled_tasks (340-358)
crates/lakekeeper/src/implementations/postgres/tasks.rs (8)
  • from (38-42)
  • pick_task (145-236)
  • setup_warehouse (817-830)
  • queue_task_batch (45-142)
  • task_metadata (1367-1374)
  • record_success (238-296)
  • record_failure (299-435)
  • cancel_scheduled_tasks (584-719)
crates/lakekeeper/src/api/management/v1/tasks.rs (6)
  • from (118-124)
  • from (128-134)
  • split (139-148)
  • list_tasks (239-295)
  • entities (380-391)
  • entities (392-408)
crates/lakekeeper/src/implementations/postgres/pagination.rs (4)
  • try_from (44-46)
  • try_from (55-57)
  • try_from (67-109)
  • s (87-87)
crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (2)
crates/lakekeeper/src/service/task_queue/mod.rs (5)
  • fmt (52-54)
  • fmt (110-112)
  • fmt (774-779)
  • Self (380-380)
  • Self (392-392)
crates/iceberg-ext/src/catalog/rest/error.rs (1)
  • bad_request (127-133)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (3)
crates/lakekeeper/src/service/catalog.rs (2)
  • resolve_tasks (838-864)
  • transaction (82-82)
crates/lakekeeper/src/service/task_queue/mod.rs (10)
  • new (59-61)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • queue_name (98-98)
  • queue_name (262-264)
  • tasks (312-329)
  • to_uuid (167-171)
  • record_success (554-590)
  • record_failure (511-548)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
  • from (38-42)
  • queue_task_batch (45-142)
  • task_metadata (1367-1374)
  • pick_task (145-236)
  • record_success (238-296)
  • record_failure (299-435)
crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (7)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
  • tabular_expiration_queue (188-188)
  • queue_name (325-327)
  • queue_name (337-339)
  • validate_config_fn (51-57)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
crates/lakekeeper/src/service/task_queue/mod.rs (2)
  • queue_name (98-98)
  • queue_name (262-264)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)
  • queue_name (48-50)
crates/lakekeeper/src/api/management/mod.rs (2)
  • set_task_queue_config (1482-1498)
  • get_task_queue_config (1513-1526)
crates/lakekeeper/src/implementations/postgres/catalog.rs (2)
  • set_task_queue_config (804-811)
  • get_task_queue_config (813-819)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • set_task_queue_config (471-514)
  • get_task_queue_config (437-469)
crates/lakekeeper/src/implementations/postgres/catalog.rs (5)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (248-251)
  • list_tasks (92-268)
crates/lakekeeper/src/implementations/postgres/tasks.rs (9)
  • cancel_scheduled_tasks (584-719)
  • check_and_heartbeat_task (542-574)
  • get_task_queue_config (437-469)
  • queue_task_batch (45-142)
  • request_tasks_stop (516-540)
  • set_task_queue_config (471-514)
  • pick_task (145-236)
  • record_success (238-296)
  • record_failure (299-435)
crates/lakekeeper/src/service/catalog.rs (16)
  • cancel_scheduled_tasks (966-971)
  • check_and_heartbeat_task (974-989)
  • get_task_details (911-918)
  • get_task_queue_config (1016-1020)
  • list_tasks (928-934)
  • resolve_tasks (838-864)
  • set_task_queue_config (1009-1014)
  • resolve_table_ident (420-425)
  • transaction (82-82)
  • resolve_tasks_impl (829-833)
  • record_task_success (887-891)
  • get_task_details_impl (902-907)
  • list_tasks_impl (921-925)
  • enqueue_tasks (942-946)
  • check_and_heartbeat_task_impl (992-998)
  • stop_tasks (1004-1007)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
crates/lakekeeper/src/api/management/mod.rs (5)
  • get_task_details (1560-1570)
  • list_tasks (1540-1547)
  • from (1629-1634)
  • get_task_queue_config (1513-1526)
  • set_task_queue_config (1482-1498)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/catalog.rs (8)
  • get_task_details (911-918)
  • list_tasks (928-934)
  • resolve_tasks (838-864)
  • transaction (82-82)
  • check_and_heartbeat_task (974-989)
  • cancel_scheduled_tasks (966-971)
  • get_task_queue_config (1016-1020)
  • set_task_queue_config (1009-1014)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (92-268)
  • tasks (248-251)
  • status (76-79)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/service/task_queue/mod.rs (12)
  • queue_name (98-98)
  • queue_name (262-264)
  • tasks (312-329)
  • max_time_since_last_heartbeat (89-91)
  • task (377-377)
  • task (389-389)
  • as_str (64-66)
  • cancel_scheduled_tasks (340-358)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • queue_config (240-257)
crates/lakekeeper/src/api/management/mod.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • tasks (248-251)
  • list_tasks (92-268)
  • status (76-79)
crates/lakekeeper/src/api/management/v1/tasks.rs (5)
  • control_tasks (344-443)
  • get_task_details (298-341)
  • list_tasks (239-295)
  • from (118-124)
  • from (128-134)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/catalog.rs (3)
  • get_task_details (911-918)
  • list_tasks (928-934)
  • set_task_queue_config (1009-1014)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • set_task_queue_config (471-514)
  • from (38-42)
crates/lakekeeper/src/service/mod.rs (7)
  • from (63-65)
  • from (160-162)
  • from (274-276)
  • from (338-340)
  • from (344-346)
  • from (364-366)
  • from (385-387)
crates/lakekeeper/src/service/catalog.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (248-251)
  • list_tasks (92-268)
crates/lakekeeper/src/service/task_queue/mod.rs (7)
  • tasks (312-329)
  • new (59-61)
  • Self (380-380)
  • Self (392-392)
  • pick_new_task (365-414)
  • queue_name (98-98)
  • queue_name (262-264)
crates/lakekeeper/src/implementations/postgres/catalog.rs (11)
  • resolve_table_ident (188-195)
  • pick_new_task (694-705)
  • resolve_tasks_impl (707-713)
  • record_task_success (715-721)
  • get_task_details_impl (738-745)
  • list_tasks_impl (748-754)
  • enqueue_tasks (756-769)
  • check_and_heartbeat_task_impl (780-795)
  • stop_tasks (797-802)
  • set_task_queue_config (804-811)
  • get_task_queue_config (813-819)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks.rs (3)
  • check_and_heartbeat_task (542-574)
  • set_task_queue_config (471-514)
  • get_task_queue_config (437-469)
crates/lakekeeper/src/service/task_queue/mod.rs (5)
crates/lakekeeper/src/service/mod.rs (18)
  • deref (213-215)
  • deref (268-270)
  • deref (282-284)
  • deref (311-313)
  • deref (358-360)
  • deref (436-438)
  • deref (504-506)
  • from (63-65)
  • from (160-162)
  • from (274-276)
  • from (338-340)
  • from (344-346)
  • from (364-366)
  • from (385-387)
  • from (442-444)
  • from (469-471)
  • new (167-169)
  • new (234-236)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
  • new (130-135)
  • queue_name (325-327)
  • queue_name (337-339)
  • serde_json (143-143)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • from (38-42)
  • check_and_heartbeat_task (542-574)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (2)
  • new (48-53)
  • queue_name (68-70)
crates/lakekeeper/src/service/catalog.rs (2)
  • transaction (82-82)
  • check_and_heartbeat_task (974-989)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
🔇 Additional comments (13)
crates/lakekeeper/src/implementations/postgres/warehouse.rs (1)

678-678: Guard default page size and update docs

  • Verify pagination_size_default ≤ pagination_size_max (or add a clamp) so the “default” page size can never exceed the hard max.
  • Update OpenAPI schema and endpoint docs for all calls now using page_size_or_pagination_default (user, role, tasks, warehouse) to reflect the new default.
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)

40-46: Boolean short-circuiting pattern LGTM.

(warehouse_id = $2 OR $3) is a clean way to toggle the warehouse filter. No changes needed.

crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (2)

52-54: Pagination: Option looks good

Passing page_size through as Option aligns with PaginationQuery; tests reflect this.

Also applies to: 64-65


1064-1066: OpenAPI exposure of TaskQueueName as String: good

Schema override prevents leaking the newtype in API contracts.

crates/lakekeeper/src/api/management/mod.rs (2)

1504-1512: Path reuse for GET/POST is fine; just ensure it’s intentional

Both GET and POST reference the same ManagementV1Endpoint path. Confirm this matches how api_doc patches per-queue schemas.


1896-1904: New task routes wired into v1 router — good integration

Endpoints are registered and namespaced consistently.

crates/lakekeeper/src/service/task_queue/mod.rs (1)

198-216: NotActive semantics are explicit — nice

The new state and helpers clearly communicate stop/report behavior.

crates/lakekeeper/src/implementations/postgres/tasks.rs (1)

169-176: Task picking SQL and updates look solid

UTC casts removed, stale re-pick logic retained by design, and attempt/progress fields updated atomically.

Also applies to: 181-186, 228-233

crates/lakekeeper/src/service/catalog.rs (5)

420-426: resolve_table_ident: lifetime-friendly API looks correct

Signature and return type upgrade to TabularDetails is sound and aligns with the Postgres impl.


432-438: table_to_id wrapper: concise and correct

Delegation to resolve_table_ident and mapping to TableId reads well.


900-919: get_task_details wrappers: interface looks consistent

Thin wrappers keep the trait clean and defer to backend impls.


943-960: enqueue_task(s): static queue name contract is clear

Using &'static TaskQueueName enforces typed, constant queues at compile time. Good choice.


1009-1021: Remove unnecessary conversion suggestion
&TaskQueueName auto‐derefs to &str via its Deref<Target=str> impl, so no explicit .as_str() or signature change is needed.

Likely an incorrect or invalid review comment.

Comment thread docs/docs/api/management-open-api.yaml Resolved
Comment thread docs/docs/api/management-open-api.yaml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

♻️ Duplicate comments (1)
crates/lakekeeper/src/service/catalog.rs (1)

848-884: Warehouse-aware cache fix: LGTM

Cache hits are now filtered by warehouse_id and short-circuit when all IDs are satisfied. This addresses the cross-warehouse leak raised earlier.

🧹 Nitpick comments (22)
.sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json (2)

3-3: Return an explicit outcome for observability.

Currently no rows/values are returned. Returning the updated task_id or updated status helps callers verify success and aids metrics.

Example:

-upd AS ( UPDATE ... RETURNING t.task_id, t.status )
-SELECT 1;
+upd AS ( UPDATE ... RETURNING t.task_id, t.status )
+SELECT * FROM upd;

3-3: Minor: prefer statement_timestamp() if you want wall time during long transactions.

now() is transaction-timestamp; for long-running transactions duration may be skewed. Use statement_timestamp() for more precise elapsed time.

- now() - picked_up_at,
+ statement_timestamp() - picked_up_at,
.sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json (5)

3-3: Confirm unconditional DELETE semantics (idempotency vs. safety).

The DELETE runs even if the INSERT does nothing (e.g., ON CONFLICT or no matching task). If that’s intended for idempotent archival, all good; otherwise, make the delete contingent on a successful insert to avoid accidental loss.

 WITH history as (
   INSERT INTO task_log( ... )
   SELECT ... FROM task WHERE task_id = $1
   ON CONFLICT (task_id, attempt) DO NOTHING
   RETURNING task_id
 )
-DELETE FROM task
-WHERE task_id = $1
+DELETE FROM task
+WHERE task_id IN (SELECT task_id FROM history)

3-3: Consider row-level locking to avoid concurrent archiving races.

Two concurrent calls could both attempt to archive the same task. A FOR UPDATE on the source row makes the flow clearer and avoids last-moment mutations slipping in.

-                FROM task WHERE task_id = $1
+                FROM task WHERE task_id = $1 FOR UPDATE

3-3: Duration source: prefer statement_timestamp() over now().

now() is transaction-start; use statement_timestamp() (or clock_timestamp()) to reflect the actual statement time.

-                    now() - picked_up_at,
+                    statement_timestamp() - picked_up_at,

3-3: Null picked_up_at → NULL duration: confirm desired.

If picked_up_at can be NULL (e.g., never started, then cancelled), duration will be NULL. If that’s undesired, coalesce to 0 interval.

-                    statement_timestamp() - picked_up_at,
+                    COALESCE(statement_timestamp() - picked_up_at, interval '0'),

3-3: Minor: CTE name is unused; either reference it or keep as-is.

Using the history CTE only to chain the DELETE is fine; if you want stricter coupling, use USING history in DELETE (equivalent to the first suggestion).

-DELETE FROM task
-WHERE task_id = $1
+DELETE FROM task USING history
+WHERE task.task_id = history.task_id
.sqlx/query-5bd47311d02686a600bca9b1b7950e6d9319e12d86a73749fc985727a7a0c8dd.json (3)

3-3: Consider whether idempotent re-finalization should update existing log rows

Current ON CONFLICT DO NOTHING preserves the first archived row and ignores newer message/status/duration. If “last write wins” is preferable, switch to ON CONFLICT (task_id, attempt) DO UPDATE for selected fields (e.g., message, status, duration, last_heartbeat_at).

Example (adjust to policy):

... ON CONFLICT (task_id, attempt) DO UPDATE
SET message = EXCLUDED.message,
    status = EXCLUDED.status,
    duration = EXCLUDED.duration,
    last_heartbeat_at = EXCLUDED.last_heartbeat_at

3-3: Use statement/clock timestamp for accurate duration

now() equals transaction_timestamp(); in long transactions duration may skew. Prefer statement_timestamp() or clock_timestamp() to reflect end-of-task wall time.

- duration,
- now() - picked_up_at,
+ duration,
+ clock_timestamp() - picked_up_at,

3-3: Handle NULL picked_up_at to avoid NULL duration for never-started tasks

If a task is cancelled/failed before pickup, started_at and duration become NULL. If that’s undesirable, guard with CASE/COALESCE.

started_at,
CASE
  WHEN picked_up_at IS NOT NULL THEN clock_timestamp() - picked_up_at
  ELSE interval '0'
END AS duration,
.sqlx/query-91e9aa5a3d2c935592a0d727c81978edb0bf5270ed4cb5e58cbdeb5dea88e2e7.json (2)

3-3: Picker resets progress/execution_details on repick

Resetting progress and execution_details to NULL/0.0 on repick is acceptable if you intend to start a fresh attempt. Verify UI/metrics expectations.

If you want to preserve last attempt’s execution_details for diagnostics, move them to task_log before resetting.


3-3: Add supportive indexes for the new predicate

Queue-scoped predicate will benefit from a composite/partial index.

Suggested indexes (apply via migration):

-- Per-queue ready tasks
CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_task_queue_ready
ON task (queue_name, scheduled_for)
WHERE status = 'scheduled';

-- Reconciliation by stale heartbeat
CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_task_queue_stale
ON task (queue_name, last_heartbeat_at)
WHERE status IN ('running','should-stop');
.sqlx/query-db0cade087c39f5c03c2d3760817db1993c130a4934c4298eb882296565659aa.json (2)

1-41: Idempotent cleanup looks good; consider exposing affected counts

Insert with ON CONFLICT DO NOTHING + subsequent delete by ids is idempotent. Consider RETURNING counts for observability.

-DELETE FROM task t
+DELETE FROM task t
 WHERE (status = $3 OR $6) AND (queue_name = $4 OR $5)
 AND task_id = ANY($1)
+RETURNING 1

Aggregate rows affected at the caller.


1-41: Boolean “OR $5/$6” bypasses are fine but can hinder planning

Given you also filter by task_id list, impact is small. Keep an eye on plans if lists get large.

.sqlx/query-84fa33a8bb91efbd266364275dfd29ce699bd88257a104b0fdb5b76d1ca48ad2.json (2)

3-3: Ensure deterministic attempt ordering in combined result

Add an explicit ORDER BY on the outer SELECT so parsing doesn’t rely on input order from UNION ALL.

-        )) as combined
+        )) as combined
+        ORDER BY attempt DESC

3-3: Duration source: consider clock_timestamp() over now()

If long transactions are possible, now() is transaction-timestamp; clock_timestamp() gives wall-clock. Low impact but more precise for “running for X” displays.

-            case when picked_up_at is not null
-                then now() - picked_up_at
+            case when picked_up_at is not null
+                then clock_timestamp() - picked_up_at
                 else null
             end as duration,
crates/lakekeeper/src/service/catalog.rs (2)

51-64: Cache policy: prefer time-to-idle for hot-set stability

Using a fixed TTL via custom Expiry evicts entries even if hot. Consider TTI to keep frequently used task metadata resident.

-static TASKS_CACHE: LazyLock<moka::future::Cache<TaskId, (TaskEntity, TaskQueueName)>> =
-    LazyLock::new(|| {
-        moka::future::Cache::builder()
-            .max_capacity(10000)
-            .expire_after(TasksCacheExpiry)
-            .build()
-    });
+static TASKS_CACHE: LazyLock<moka::future::Cache<TaskId, (TaskEntity, TaskQueueName)>> =
+    LazyLock::new(|| {
+        moka::future::Cache::builder()
+            .max_capacity(10_000)
+            .time_to_idle(Duration::from_secs(60 * 60))
+            .build()
+    });

57-64: Add simple cache hit/miss metrics

Expose TASKS_CACHE hit/miss counters via tracing or metrics to validate benefit and tune capacity/TTL.

.sqlx/query-517181ff739fbdba147bb183aa2d0bc0d2e206686ca4bf15a31d5b5a37728c9a.json (1)

3-3: Optional: index to support ORDER BY attempt DESC

If not present, consider an index on task_log(task_id, attempt DESC) to keep this path fast at scale.

.sqlx/query-349bddee3dedc684d6df1ecbeeddef922d00a12eb388fa490fd20e7fd5d8d1c9.json (1)

3-3: Minor: prefer statement_timestamp() and consider supporting indexes

  • Consider statement_timestamp() over now() for clearer snapshot semantics in duration calc.
  • Since predicates can devolve to OR true ($5/$6), plan quality may vary. If not already present, composite indexes like:
    • task(warehouse_id, status, queue_name, created_at DESC, task_id DESC)
    • task_log(warehouse_id, status, task_created_at DESC, task_id, attempt DESC)
      can help.
.sqlx/query-25bbbb61acaff2e216a0fddbc16846066c9da47ade638198dac8e0b4be91f962.json (1)

3-3: Optional: tighten DISTINCT ON key to task_id only

If task_created_at is immutable per task, DISTINCT ON (task_id) plus ORDER BY task_id, attempt DESC may be sufficient and cheaper. If not guaranteed, ignore.

crates/lakekeeper/src/api/management/v1/tasks.rs (1)

380-392: Slight simplification of queue-name equality checks

You can compare by reference consistently (no need for &* / move):

-                if queue_name == &*TABULAR_EXPIRATION_QUEUE_NAME {
+                if queue_name == TABULAR_EXPIRATION_QUEUE_NAME {
...
-                    if queue_name == *TABULAR_EXPIRATION_QUEUE_NAME {
+                    if &queue_name == TABULAR_EXPIRATION_QUEUE_NAME {

Also applies to: 399-406

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dec2baa and bb242af.

📒 Files selected for processing (18)
  • .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json (1 hunks)
  • .sqlx/query-25bbbb61acaff2e216a0fddbc16846066c9da47ade638198dac8e0b4be91f962.json (1 hunks)
  • .sqlx/query-349bddee3dedc684d6df1ecbeeddef922d00a12eb388fa490fd20e7fd5d8d1c9.json (1 hunks)
  • .sqlx/query-3f118743d59e0e035f57c9106816533c092fead83b8420cdab3149b040664910.json (1 hunks)
  • .sqlx/query-4b50d3e32f0c04a20c82ed3dd5c93fd5bb2ebaf4e10a15cd387987423c7b6d1c.json (1 hunks)
  • .sqlx/query-517181ff739fbdba147bb183aa2d0bc0d2e206686ca4bf15a31d5b5a37728c9a.json (1 hunks)
  • .sqlx/query-5bd47311d02686a600bca9b1b7950e6d9319e12d86a73749fc985727a7a0c8dd.json (1 hunks)
  • .sqlx/query-62b9aeb0ed103e7f63a42f246d713b7727307c032df2c983e7ab8a72d569ddb1.json (1 hunks)
  • .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json (1 hunks)
  • .sqlx/query-84289e60b801d874560edfc1a2a4e031a82470d6847acd1604b7e2abe04b480c.json (2 hunks)
  • .sqlx/query-84fa33a8bb91efbd266364275dfd29ce699bd88257a104b0fdb5b76d1ca48ad2.json (1 hunks)
  • .sqlx/query-91e9aa5a3d2c935592a0d727c81978edb0bf5270ed4cb5e58cbdeb5dea88e2e7.json (2 hunks)
  • .sqlx/query-97ee559390277a9d6ef89d56d63d1f69677f57a656dd510a3992524113c438d8.json (2 hunks)
  • .sqlx/query-db0cade087c39f5c03c2d3760817db1993c130a4934c4298eb882296565659aa.json (1 hunks)
  • crates/lakekeeper/src/api/management/v1/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/catalog.rs (8 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (62 hunks)
  • crates/lakekeeper/src/service/catalog.rs (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-30T10:23:41.114Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

Applied to files:

  • .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • .sqlx/query-84289e60b801d874560edfc1a2a4e031a82470d6847acd1604b7e2abe04b480c.json
  • .sqlx/query-91e9aa5a3d2c935592a0d727c81978edb0bf5270ed4cb5e58cbdeb5dea88e2e7.json
  • .sqlx/query-97ee559390277a9d6ef89d56d63d1f69677f57a656dd510a3992524113c438d8.json
  • crates/lakekeeper/src/implementations/postgres/catalog.rs
  • crates/lakekeeper/src/service/catalog.rs
🧬 Code graph analysis (3)
crates/lakekeeper/src/api/management/v1/tasks.rs (8)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • from (38-42)
  • cancel_scheduled_tasks (585-720)
crates/lakekeeper/src/api/management/mod.rs (4)
  • from (1629-1634)
  • list_tasks (1540-1547)
  • get_task_details (1560-1570)
  • control_tasks (1586-1595)
crates/lakekeeper/src/service/catalog.rs (8)
  • list_tasks (948-954)
  • begin_read (76-76)
  • get_task_details (931-938)
  • resolve_required_tasks (886-905)
  • begin_write (74-74)
  • stop_tasks (1024-1027)
  • clear_tabular_deleted_at (502-506)
  • cancel_scheduled_tasks (986-991)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (92-268)
  • entities (132-141)
  • tasks (248-251)
crates/iceberg-ext/src/catalog/rest/error.rs (3)
  • bad_request (127-133)
  • not_found (182-188)
  • forbidden (211-217)
crates/lakekeeper/src/implementations/postgres/mod.rs (2)
  • begin_read (79-93)
  • begin_write (69-77)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
crates/lakekeeper/src/implementations/postgres/catalog.rs (5)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (248-251)
  • list_tasks (92-268)
crates/lakekeeper/src/implementations/postgres/tasks.rs (9)
  • cancel_scheduled_tasks (585-720)
  • check_and_heartbeat_task (543-575)
  • get_task_queue_config (438-470)
  • pick_task (146-237)
  • queue_task_batch (45-142)
  • record_failure (300-436)
  • record_success (239-297)
  • request_tasks_stop (517-541)
  • set_task_queue_config (472-515)
crates/lakekeeper/src/service/catalog.rs (17)
  • cancel_scheduled_tasks (986-991)
  • check_and_heartbeat_task (994-1009)
  • get_task_details (931-938)
  • get_task_queue_config (1036-1040)
  • list_tasks (948-954)
  • resolve_tasks (847-884)
  • set_task_queue_config (1029-1034)
  • resolve_table_ident (420-425)
  • transaction (82-82)
  • pick_new_task_impl (818-822)
  • resolve_tasks_impl (838-842)
  • record_task_success (907-911)
  • get_task_details_impl (922-927)
  • list_tasks_impl (941-945)
  • enqueue_tasks (962-966)
  • check_and_heartbeat_task_impl (1012-1018)
  • stop_tasks (1024-1027)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/service/catalog.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (248-251)
  • list_tasks (92-268)
crates/lakekeeper/src/service/task_queue/mod.rs (7)
  • tasks (312-329)
  • new (59-61)
  • Self (380-380)
  • Self (392-392)
  • queue_name (98-98)
  • queue_name (262-264)
  • pick_new_task (365-414)
crates/lakekeeper/src/implementations/postgres/catalog.rs (11)
  • resolve_table_ident (188-195)
  • pick_new_task_impl (694-705)
  • resolve_tasks_impl (707-713)
  • record_task_success (715-721)
  • get_task_details_impl (732-739)
  • list_tasks_impl (742-748)
  • enqueue_tasks (750-763)
  • check_and_heartbeat_task_impl (774-789)
  • stop_tasks (791-796)
  • set_task_queue_config (798-805)
  • get_task_queue_config (807-813)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks.rs (3)
  • check_and_heartbeat_task (543-575)
  • set_task_queue_config (472-515)
  • get_task_queue_config (438-470)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: clippy
  • GitHub Check: sqlx-check
🔇 Additional comments (21)
.sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json (2)

3-3: Guard transitions by current state to prevent illegal jumps.

Consider constraining the UPDATE with a current-state predicate (e.g., only allow transition from 'running' → 'scheduled'/'should-stop') to avoid unexpected changes if the row was altered by another actor.

Example:

-  WHERE t.task_id = locked.task_id
+  WHERE t.task_id = locked.task_id
+    AND t.status IN ('running','scheduled')

Please confirm the allowed transition matrix and adjust the predicate accordingly.


11-33: Manual verification needed: confirm SQLx call site parameter ordering
Script search returned no matches for this query’s bindings; please manually inspect all call sites using this query to ensure parameters are bound in the order: task_id, message, task_intermediate_status ($3), task_final_status ($4) to avoid accidental swapping.

.sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json (1)

3-3: Single-statement, no rows returned: confirm caller uses .execute().

The statement returns no columns; ensure the Rust code uses execute() (not fetch_one()) and handles the command tag appropriately.

.sqlx/query-5bd47311d02686a600bca9b1b7950e6d9319e12d86a73749fc985727a7a0c8dd.json (2)

3-3: Reference the data-modifying CTE to guarantee execution order and future-proofing

Postgres may inline/optimize CTEs; referencing the INSERT CTE from the DELETE removes any ambiguity and keeps the one-statement, atomic behavior explicit.

Apply this SQL change in the source (then re-run sqlx prepare to regenerate the descriptor):

 WITH history as (
   INSERT INTO task_log( ... )
   SELECT ...
   FROM task
   WHERE task_id = $1
   ON CONFLICT (task_id, attempt) DO NOTHING
   RETURNING task_id
 )
-DELETE FROM task
-WHERE task_id = $1
+DELETE FROM task
+USING (SELECT 1 FROM history UNION ALL SELECT 1) AS _ensure_run
+WHERE task.task_id = $1
⛔ Skipped due to learnings
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

7-23: Migration artifacts present
Verified that crates/lakekeeper/migrations/20250523101407_tasks_store_their_state.sql defines the task_final_status enum with values failed, cancelled, success; creates task_log and adds columns attempt_scheduled_for, progress, execution_details, task_created_at, duration; and that the same migration (plus the 202508… migration) renames/sets default on scheduled_for, and includes picked_up_at, created_at, last_heartbeat_at on task. No further migration changes required.

.sqlx/query-3f118743d59e0e035f57c9106816533c092fead83b8420cdab3149b040664910.json (1)

100-103: Confirm DB migrations and Rust enum coverage for new API endpoints

  • Migrations adding these enum values exist in
    • crates/lakekeeper/migrations/20250523101407_tasks_store_their_state.sql (set-task-queue-config, get-task-queue-config)
    • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (control-tasks, get-task-details, list-tasks)
  • Ensure the Rust EndpointFlat enum and its route wiring include all five new variants to avoid SQLx/DB mismatches.
.sqlx/query-62b9aeb0ed103e7f63a42f246d713b7727307c032df2c983e7ab8a72d569ddb1.json (1)

109-112: No internal code references to update
Migrations and the SQL query now include the new task endpoints; no other code patterns matched these variants. Update any external analytics, dashboards, or allowlists that assume a closed set to include the new task endpoints.

.sqlx/query-84289e60b801d874560edfc1a2a4e031a82470d6847acd1604b7e2abe04b480c.json (1)

3-21: Nulling picked_up_at is intentional in test
This UPDATE appears only in the cancellation test to reset the task to “scheduled” for testing; clearing picked_up_at here correctly simulates a freshly scheduled task. No change required.

Likely an incorrect or invalid review comment.

.sqlx/query-91e9aa5a3d2c935592a0d727c81978edb0bf5270ed4cb5e58cbdeb5dea88e2e7.json (1)

3-3: Timezone consistency OK
Both scheduled_for and last_heartbeat_at are defined as timestamptz in migrations, and every queue_task call (e.g. tests at line 1145) passes a DateTime<chrono::Utc>—no local‐time values are used.

.sqlx/query-db0cade087c39f5c03c2d3760817db1993c130a4934c4298eb882296565659aa.json (1)

1-41: No changes needed: parameter binding is correct
The sqlx::query! in the TaskFilter::TaskIds branch binds parameters as
[UuidArray, task_final_status (Cancelled), task_intermediate_status (Scheduled), Text (queue_name), Bool (queue_name_is_none), Bool (force_delete_running_tasks)]
which matches the JSON definition.

crates/lakekeeper/src/service/catalog.rs (2)

818-833: pick_new_task wrapper is clean and well-scoped

Clear doc on default_max_time_since_last_heartbeat and narrow instrumentation. Good separation from impl.


420-438: Refactor to resolve_table_ident: good simplification

Delegating table_to_id to resolve_table_ident removes duplication and centralizes list_flags handling.

.sqlx/query-97ee559390277a9d6ef89d56d63d1f69677f57a656dd510a3992524113c438d8.json (1)

3-3: Guard heartbeat updates by status only
The task.updated_at column was removed in migration 20250826171037, so drop the updated_at = now() suggestion. Instead, add a status filter to the WHERE clause to prevent heartbeating non-running tasks:

…WHERE task_id = $1
  AND attempt = $4
  AND status IN ('running','should-stop')::task_intermediate_status[]
.sqlx/query-4b50d3e32f0c04a20c82ed3dd5c93fd5bb2ebaf4e10a15cd387987423c7b6d1c.json (1)

11-116: DB enum migration required for new API endpoints

Adding enum values at the SQLx descriptor level implies the Postgres type api_endpoints includes them. Verify the migration is present and applied in all envs.

Migration snippet (for reference):

ALTER TYPE api_endpoints ADD VALUE IF NOT EXISTS 'management-v1-control-tasks';
ALTER TYPE api_endpoints ADD VALUE IF NOT EXISTS 'management-v1-get-task-details';
ALTER TYPE api_endpoints ADD VALUE IF NOT EXISTS 'management-v1-list-tasks';
.sqlx/query-517181ff739fbdba147bb183aa2d0bc0d2e206686ca4bf15a31d5b5a37728c9a.json (1)

3-3: Historical resolution query looks solid

DISTINCT ON (task_id) with ORDER BY attempt DESC returns latest attempt per task efficiently and aligns with resolve_tasks.rs.

.sqlx/query-349bddee3dedc684d6df1ecbeeddef922d00a12eb388fa490fd20e7fd5d8d1c9.json (1)

3-3: Idempotent log-and-delete looks solid

The CTE insert with ON CONFLICT followed by a matching DELETE provides safe, repeatable archival semantics. Nice.

crates/lakekeeper/src/api/management/v1/tasks.rs (1)

343-444: Control flow and auth layering look good

Bound checks, warehouse CanUse, per-task permission mapping (including CanUndrop for expiration queue), and read->write split are clean.

crates/lakekeeper/src/implementations/postgres/catalog.rs (4)

188-195: API change to resolve_table_ident is consistent

Return type switch to TabularDetails and delegation look correct.


694-705: Task picking bridge aligns with new signature

Passing Duration and TaskQueueName through to pick_task is correct, matching the underlying implementation.


723-731: Param order swap verified for record_failure

Adapter flips to (conn, id, max_retries, details). Good to avoid subtle argument mix-ups. If you have tests around retries/failures, ensure they still pass after this change.


741-748: List tasks adapter looks correct

Delegation to tasks::list_tasks with transaction ref matches the SQLx descriptor shape.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
crates/lakekeeper/src/service/catalog.rs (1)

855-867: Nice fix: cache respects warehouse filter now

This closes the cross-warehouse leak from cached entries. LGTM.

Also applies to: 869-876

crates/lakekeeper/src/implementations/postgres/tasks.rs (1)

170-174: Re-picking ShouldStop on stale heartbeat is intentional — looks good

Condition uses status != Scheduled with heartbeat expiry so Running and ShouldStop can be reconciled. Acknowledging the intentional design.

🧹 Nitpick comments (13)
crates/lakekeeper/src/service/catalog.rs (5)

51-56: Make cache TTL explicit/configurable

Hardcoding 1h makes tuning harder. Promote it to a const or config.

Apply:

+const TASKS_CACHE_TTL: Duration = Duration::from_secs(60 * 60);
 struct TasksCacheExpiry;
 impl<K, V> moka::Expiry<K, V> for TasksCacheExpiry {
     fn expire_after_create(&self, _key: &K, _value: &V, _created_at: Instant) -> Option<Duration> {
-        Some(Duration::from_secs(60 * 60)) // 1 hour
+        Some(TASKS_CACHE_TTL) // 1 hour
     }
 }

818-833: Add trace fields for better observability

Instrumenting the queue and heartbeat window helps triage task picking.

Apply:

-    #[tracing::instrument(name = "catalog_pick_new_task", skip(state))]
+    #[tracing::instrument(
+        name = "catalog_pick_new_task",
+        skip(state),
+        fields(
+            queue = ?queue_name,
+            default_max_time_since_last_heartbeat = ?default_max_time_since_last_heartbeat
+        )
+    )]

879-883: Avoid double cloning when inserting uncached results

Currently cloning twice per entry. Insert into cache first, then move into the result map.

Apply:

-        for (id, value) in &resolve_uncached_result {
-            cached_results.insert(*id, value.clone());
-            TASKS_CACHE.insert(*id, value.clone()).await;
-        }
+        for (id, value) in resolve_uncached_result {
+            TASKS_CACHE.insert(id, value.clone()).await;
+            cached_results.insert(id, value);
+        }

886-905: Consider aggregating missing task IDs in error

Returning at first miss can make debugging multi-ID calls noisy. Optional: collect all missing and return one not-found listing them.

Want a patch to build and format a concise missing-IDs message?


993-1009: Clamp progress to [0.0, 1.0] at the boundary

Prevents accidental out-of-range writes and UI surprises.

Apply:

         Self::check_and_heartbeat_task_impl(
             task_id,
             attempt,
             transaction,
-            progress,
+            progress.clamp(0.0, 1.0),
             execution_details,
         )

Also applies to: 1011-1019

crates/lakekeeper/src/implementations/postgres/tasks.rs (8)

164-175: Add deterministic ordering to the picker to avoid starvation/flaky selection

LIMIT 1 without ORDER BY is nondeterministic. Order by earliest scheduled first (and a stable tiebreaker) to ensure fairness and reduce test flakiness.

Apply:

-        WHERE (t.queue_name = $1 AND scheduled_for < now()) 
+        WHERE (t.queue_name = $1 AND scheduled_for < now()) 
             AND (
                 (status = $3) OR 
                 (status != $3 AND (now() - last_heartbeat_at) > COALESCE(tc.max_time_since_last_heartbeat, $2))
             )
-        -- FOR UPDATE locks the row we select here, SKIP LOCKED makes us not wait for rows other
-        -- transactions locked, this is our queue right there.
-        FOR UPDATE OF t SKIP LOCKED
-        LIMIT 1
+        ORDER BY t.scheduled_for ASC, t.created_at ASC, t.task_id ASC
+        -- FOR UPDATE locks the row we select here; SKIP LOCKED skips rows locked by other txns.
+        FOR UPDATE OF t SKIP LOCKED
+        LIMIT 1

257-281: Guard duration against NULL started_at for consistency

Other queries use CASE around picked_up_at; mirror that here to keep duration semantics consistent.

-                       now() - picked_up_at,
+                       case when picked_up_at is not null
+                           then now() - picked_up_at
+                           else null
+                       end,

466-469: Consider rounding max_seconds_since_last_heartbeat instead of truncation

Currently divides microseconds by 1_000_000 (floor). If the API expects seconds, rounding is usually nicer.

-            .map(|x| x.microseconds / 1_000_000),
+            .map(|x| ((x.microseconds + 500_000) / 1_000_000)),

517-541: Optionally return rows_affected to aid callers/metrics

Returning the number of tasks transitioned to ShouldStop can simplify caller logic and observability. Not required.


551-575: Clamp progress to [0.0, 1.0] at write-time

Prevents bad inputs from skewing UI/metrics without burdening callers.

-            SET last_heartbeat_at = now(), 
-                progress = $2, 
+            SET last_heartbeat_at = now(), 
+                progress = LEAST(GREATEST($2, 0.0), 1.0), 
                 execution_details = $3 

596-646: Make status predicate explicit for readability (no behavior change)

(status = $3 OR $5) relies on $5 being a boolean; when true it matches all active statuses. Consider encoding intent explicitly.

-                        WHERE (status = $3 OR $5) AND warehouse_id = $1 AND (queue_name = $2 OR $6)
+                        WHERE (status = $3 OR ($5 AND status != $3))
+                          AND warehouse_id = $1
+                          AND (queue_name = $2 OR $6)
-                        WHERE (status = $3 OR $6) AND task_id = ANY($1) AND (queue_name = $4 OR $5)
+                        WHERE (status = $3 OR ($6 AND status != $3))
+                          AND task_id = ANY($1)
+                          AND (queue_name = $4 OR $5)

Also applies to: 661-711


1142-1181: Avoid time-based flakiness in scheduling test

Sleeping 600ms for a 500ms schedule can flake in slow CI. Prefer polling with a timeout or widening the margin.


1232-1288: Order-dependent assertions rely on picker determinism

These tests implicitly assume FIFO. If you don’t adopt ORDER BY in the picker, consider relaxing order assertions or explicitly ordering picks in tests.

Also applies to: 1329-1367, 1406-1435

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bb242af and e6e8e99.

📒 Files selected for processing (6)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1 hunks)
  • crates/lakekeeper/src/api/management/v1/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (65 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1 hunks)
  • crates/lakekeeper/src/service/catalog.rs (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/lakekeeper/src/api/management/v1/tasks.rs
  • crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/service/catalog.rs
  • crates/lakekeeper/src/implementations/postgres/tasks.rs
🧬 Code graph analysis (2)
crates/lakekeeper/src/service/catalog.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (248-251)
  • list_tasks (92-268)
crates/lakekeeper/src/implementations/postgres/catalog.rs (11)
  • resolve_table_ident (188-195)
  • pick_new_task_impl (694-705)
  • resolve_tasks_impl (707-713)
  • record_task_success (715-721)
  • get_task_details_impl (732-739)
  • list_tasks_impl (742-748)
  • enqueue_tasks (750-763)
  • check_and_heartbeat_task_impl (774-789)
  • stop_tasks (791-796)
  • set_task_queue_config (798-805)
  • get_task_queue_config (807-813)
crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (2)
  • resolve_table_ident (49-78)
  • format (1096-1098)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks.rs (3)
  • check_and_heartbeat_task (543-575)
  • set_task_queue_config (472-515)
  • get_task_queue_config (438-470)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
crates/lakekeeper/src/api/management/v1/tasks.rs (4)
  • get_task_details (298-341)
  • list_tasks (239-295)
  • from (118-124)
  • from (128-134)
crates/lakekeeper/src/service/catalog.rs (8)
  • get_task_details (931-938)
  • list_tasks (948-954)
  • resolve_tasks (847-884)
  • transaction (82-82)
  • check_and_heartbeat_task (994-1009)
  • cancel_scheduled_tasks (986-991)
  • get_task_queue_config (1036-1040)
  • set_task_queue_config (1029-1034)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (92-268)
  • tasks (248-251)
  • status (76-79)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/service/task_queue/mod.rs (12)
  • queue_name (98-98)
  • queue_name (262-264)
  • tasks (312-329)
  • max_time_since_last_heartbeat (89-91)
  • task (377-377)
  • task (389-389)
  • as_str (64-66)
  • cancel_scheduled_tasks (340-358)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • queue_config (240-257)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: sqlx-check
🔇 Additional comments (10)
crates/lakekeeper/src/service/catalog.rs (5)

1-5: Confirm MSRV for std::sync::LazyLock usage

LazyLock is stable on recent Rust; if your MSRV is lower, consider once_cell::sync::Lazy instead.

Would you like a quick script to detect rust-version/rust-toolchain in the repo?


57-64: Cache builder looks good

Capacity bound + custom expiry via moka is a solid choice.


420-438: Good split: resolve_table_ident + delegation in table_to_id

Clearer API and tighter lifetimes. No issues.


963-966: 'static on enqueue queue_name — intentional policy?

Enqueue APIs require &'static TaskQueueName, while others take &TaskQueueName. If the goal is “only well-known queues can enqueue,” great; otherwise consider relaxing to &TaskQueueName for consistency.

I can prep a diff to remove 'static if you want to allow dynamic (validated) queues.

Also applies to: 973-980


1031-1041: Typed queue config getters/setters look consistent

API surface is coherent with the new TaskQueueName type.

crates/lakekeeper/src/implementations/postgres/tasks.rs (5)

45-51: Typed queue names: good change

Using &TaskQueueName and converting once with as_str() improves safety and avoids stringly-typed bugs. LGTM.


78-124: Batch insert/idempotency looks solid

The CTE+unnest pattern with ON CONFLICT (warehouse_id, entity_type, entity_id, queue_name) DO NOTHING is correct for idempotent enqueue. No issues spotted.


181-187: Resetting pickup fields is correct

Setting progress=0.0, execution_details=NULL, picked_up_at/last_heartbeat_at=now() on pickup is appropriate. LGTM.


299-436: Failure logging and idempotency look correct

The split path (terminal vs retry), ON CONFLICT(task_id, attempt) DO NOTHING, and cleanup/update behavior are sound.


164-175: Indexes already in place—no action needed
The migrations include:

  • task_queue_name_status_idx on (queue_name, status, scheduled_for) and task_warehouse_queue_name_idx on (warehouse_id, queue_name) for picker performance.
  • A non-unique task_entity_type_entity_id_idx exists, but the suggested unique constraint on (warehouse_id, entity_type, entity_id, queue_name) is not present.
  • No unique index on task_log(task_id, attempt) found.

Add only the missing uniqueness constraints in separate migrations.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

♻️ Duplicate comments (1)
crates/lakekeeper/src/implementations/postgres/tasks.rs (1)

188-205: Intended re-pick semantics acknowledged

Allowing stale Running/ShouldStop tasks to be re-picked is deliberate reconciliation. No change requested.

🧹 Nitpick comments (45)
.sqlx/query-c34538592c32c7303aa82638f9a1f7684f88288a01517c2b5305befdfeb7b4c2.json (1)

3-3: Good switch to paired UNNEST; avoids cross product.

This aligns $1::BIGINT[] and $3::JSONB[] element-wise, fixing the prior cross-join behavior and improving performance. Note: multi-array UNNEST requires equal-length arrays; Postgres will error if lengths differ. Please verify upstream validates equal lengths (and returns a client-friendly error) before executing this query. Optionally, make the cast on $2 explicit ($2::uuid) for clarity, though SQLx already infers it.

.sqlx/query-7bae9ea01c9a8adf726d239499183c0bb46b44b2ffe9f60b2db3194fd038e47e.json (5)

3-3: Consider returning a row even on conflict to simplify idempotent callers.

ON CONFLICT DO NOTHING causes the statement to return 0 rows when a log row already exists, which can force callers to special-case “already finalized.” If helpful, switch to DO UPDATE … RETURNING to always return task_id and optionally refresh status/message.

-        ON CONFLICT (task_id, attempt) DO NOTHING
-        RETURNING task_id
+        ON CONFLICT (task_id, attempt)
+        DO UPDATE SET
+            status = EXCLUDED.status,
+            message = EXCLUDED.message
+        RETURNING task_log.task_id

3-3: Guard duration/start for tasks never picked up.

If picked_up_at is NULL (e.g., cancelled before pickup), started_at and duration become NULL. Verify task_log.started_at/duration allow NULLs. If not, derive safe values.

-                picked_up_at,
-                now() - picked_up_at,
+                picked_up_at,
+                CASE WHEN picked_up_at IS NOT NULL
+                     THEN clock_timestamp() - picked_up_at
+                     ELSE interval '0'
+                END,

If you want to preserve “not started,” keep started_at = NULL but set duration to 0 only when the column is NOT NULL.


3-3: Prefer clock_timestamp() over now() for elapsed duration.

now() is transaction-start time; for accurate wall-clock duration at statement time, clock_timestamp() is better.

-                now() - picked_up_at,
+                clock_timestamp() - picked_up_at,

3-3: Progress hard-coded to 1.0 for all terminal states—confirm intent.

Setting progress = 1.0000 for failed/cancelled may be intended (terminal = 100%). If you prefer semantic progress, consider mapping per status.

-                1.0000,
+                CASE $3
+                    WHEN 'success'   THEN 1.0
+                    WHEN 'failed'    THEN 1.0
+                    WHEN 'cancelled' THEN 1.0
+                END,

(Leave as-is if the uniform 1.0 is deliberate.)


3-3: Indexing/locking note for DELETE filter.

Ensure task(task_id, attempt) is indexed (ideally primary key) to keep the DELETE fast and avoid unnecessary locks during scans under load.

.sqlx/query-8cf29b178cb4a59d1cfc2f43d7ebf3cd1d8a44fbcdc57a1ee1cf86be2885b1ec.json (1)

3-3: Prefer explicit column aliases over u.*; consider safer CTE name and duplicate-key handling.

  • Alias UNNEST columns to avoid relying on positional expansion and improve readability.
  • Rename CTE from drop to something non-keyword-ish (e.g., deleted) for clarity.
  • If duplicate keys can appear in $2, define last-write wins deterministically (e.g., WITH ORDINALITY + DISTINCT ON), otherwise confirm upstream validation guarantees uniqueness.
  • Confirm that empty arrays intentionally wipe all properties for table_id.
-  "query": "WITH drop as (DELETE FROM table_properties WHERE table_id = $1)\n           INSERT INTO table_properties (table_id, key, value)\n           SELECT $1, u.* FROM UNNEST($2::text[], $3::text[]) u\n           ON CONFLICT (key, table_id) DO UPDATE SET value = EXCLUDED.value;",
+  "query": "WITH deleted AS (DELETE FROM table_properties WHERE table_id = $1)\n           INSERT INTO table_properties (table_id, key, value)\n           SELECT $1, u.key, u.value\n           FROM UNNEST($2::text[], $3::text[]) AS u(key, value)\n           ON CONFLICT (key, table_id) DO UPDATE SET value = EXCLUDED.value;",

Optional (if duplicate keys possible, last occurrence wins):

-           SELECT $1, u.key, u.value
-           FROM UNNEST($2::text[], $3::text[]) AS u(key, value)
+           SELECT $1, t.key, t.value
+           FROM (
+             SELECT key, value
+             FROM UNNEST($2::text[], $3::text[]) WITH ORDINALITY AS u(key, value, ord)
+             DISTINCT ON (key) key, value
+             ORDER BY key, ord DESC
+           ) t
.sqlx/query-078951ebbfe504d8049b2e6f3748af439d28fe8efd68a2bab46c6918b064029e.json (3)

3-3: Guard against mismatched array lengths (Postgres pads with NULLs).

If any array is shorter, UNNEST pads with NULLs, which can violate NOT NULLs or insert bad data. Validate equal lengths in the caller before executing.

Example (Rust) pre-check:

let lens = [
  snapshot_ids.len(), paths.len(), file_sizes.len(),
  footer_sizes.len(), key_metadata.len(), blob_metadata.len()
];
assert!(lens.windows(2).all(|w| w[0] == w[1]), "array length mismatch for table_statistics insert");

3-3: Nit: cast the scalar for clarity.

Make the scalar’s type explicit to avoid inference surprises.

-SELECT $2, u.* FROM UNNEST($1::BIGINT[], $3::TEXT[], $4::BIGINT[], $5::BIGINT[], $6::TEXT[], $7::JSONB[]) u
+SELECT $2::UUID, u.* FROM UNNEST($1::BIGINT[], $3::TEXT[], $4::BIGINT[], $5::BIGINT[], $6::TEXT[], $7::JSONB[]) u

3-3: Consider idempotency with ON CONFLICT (if a unique key exists).

If (table_id, snapshot_id, statistics_path) is unique, make the insert idempotent.

-INSERT INTO table_statistics(table_id, snapshot_id, statistics_path, file_size_in_bytes, file_footer_size_in_bytes, key_metadata, blob_metadata)
-           SELECT $2::UUID, u.* FROM UNNEST($1::BIGINT[], $3::TEXT[], $4::BIGINT[], $5::BIGINT[], $6::TEXT[], $7::JSONB[]) u
+INSERT INTO table_statistics(table_id, snapshot_id, statistics_path, file_size_in_bytes, file_footer_size_in_bytes, key_metadata, blob_metadata)
+           SELECT $2::UUID, u.* FROM UNNEST($1::BIGINT[], $3::TEXT[], $4::BIGINT[], $5::BIGINT[], $6::TEXT[], $7::JSONB[]) u
+ON CONFLICT (table_id, snapshot_id, statistics_path) DO NOTHING

If a differently named unique constraint exists, switch to ON CONFLICT ON CONSTRAINT .

.sqlx/query-009c03de13ca6188f4c2ce1205783d9ea7f67ac8bc0c0e567d5e268ced7758a4.json (2)

3-3: Optional: Add a lightweight lock CTE to serialize set-replacement per table_id.

Concurrent invocations for the same table_id can race (last writer wins). If stronger replace-set semantics are required, add a locking CTE before delete.

Apply inside the same query string (before deleted AS (...)):

-        WITH input(name, snapshot_id, retention) AS (
+        WITH input(name, snapshot_id, retention) AS (
             SELECT * FROM UNNEST($2::TEXT[], $3::BIGINT[], $4::JSONB[])
-        ), deleted AS (
+        ), locked AS (
+            SELECT 1 FROM table_refs WHERE table_id = $1 FOR UPDATE
+        ), deleted AS (

Note: This only locks existing rows for $1. If none exist, consider an app-level advisory lock instead.


3-3: Single-UNNEST also improves performance and plan stability.

Materializing input avoids repeating UNNEST in both DELETE and INSERT, reducing CPU and making the plan clearer. Also enables future indexes or deduping on input.

.sqlx/query-d0b2eeac710ddb262ddcbed526d261690bf9f308951888e86ce1748b49d58a97.json (1)

3-3: Make INSERT idempotent with ON CONFLICT upsert

Since table_partition_spec defines PRIMARY KEY (table_id, partition_spec_id), add an upsert to avoid unique‐violation errors during retries:

-INSERT INTO table_partition_spec(partition_spec_id, table_id, partition_spec)
-  SELECT sid, $2, s
-    FROM UNNEST($1::INT[], $3::JSONB[]) AS u(sid, s)
+INSERT INTO table_partition_spec(partition_spec_id, table_id, partition_spec)
+  SELECT sid, $2, s
+    FROM UNNEST($1::INT[], $3::JSONB[]) AS u(sid, s)
+  ON CONFLICT (table_id, partition_spec_id) DO UPDATE
+    SET partition_spec = EXCLUDED.partition_spec;
.sqlx/query-7daec1b99e2b91e7546adf64c4ef9e584e0f19b805c699a70969c205f5c33b7f.json (4)

3-3: Clarify idempotency and “returning” semantics when a log row already exists.

With ON CONFLICT DO NOTHING, the delete succeeds but the insert returns 0 rows and the whole statement returns no task_id. If callers rely on RETURNING to signal success, this can look like a no-op even though the task was removed. Consider a no-op upsert to always return a row on conflict, or define that None is expected and handled.

Option A (no-op upsert; preserves existing log row values but guarantees RETURNING):

-            ON CONFLICT (task_id, attempt) DO NOTHING
+            ON CONFLICT (task_id, attempt) DO UPDATE SET
+                status = task_log.status

Option B (refresh final status and selected fields on retry; adjust as per product rules):

-            ON CONFLICT (task_id, attempt) DO NOTHING
+            ON CONFLICT (task_id, attempt) DO UPDATE SET
+                status = EXCLUDED.status,
+                duration = COALESCE(task_log.duration, EXCLUDED.duration),
+                progress = COALESCE(task_log.progress, EXCLUDED.progress),
+                execution_details = COALESCE(task_log.execution_details, EXCLUDED.execution_details),
+                last_heartbeat_at = GREATEST(task_log.last_heartbeat_at, EXCLUDED.last_heartbeat_at),
+                attempt_scheduled_for = COALESCE(task_log.attempt_scheduled_for, EXCLUDED.attempt_scheduled_for),
+                started_at = COALESCE(task_log.started_at, EXCLUDED.started_at),
+                parent_task_id = COALESCE(task_log.parent_task_id, EXCLUDED.parent_task_id),
+                task_created_at = COALESCE(task_log.task_created_at, EXCLUDED.task_created_at)

3-3: Duration/started_at when picked_up_at is NULL.

If a task is finalized without ever being picked up, duration becomes NULL. If you prefer explicit zero for cancelled-before-start tasks, coalesce to interval '0'.

-                now() - picked_up_at,
+                CASE WHEN picked_up_at IS NOT NULL THEN now() - picked_up_at ELSE interval '0' END,

3-3: Minor: prefer statement_timestamp() over now() for elapsed time within the statement.

now() is transaction_timestamp(); statement_timestamp() better reflects the time at the start of this statement (slightly more precise for long transactions).

-                now() - picked_up_at,
+                statement_timestamp() - picked_up_at,

3-3: Confirm caller behavior when nothing is moved.

If no source row matches (or conflict path with DO NOTHING is kept), the query returns 0 rows. Ensure the Rust side uses fetch_optional and treats None as “already finalized or not found,” not an error. Consider adding an integration test for: existing log row + present task row ⇒ move is idempotent and return value matches expectation.

.sqlx/query-6eb81444b25f070f01777ccbbc5f7b662bb3ed494b55616479cd36c66694f968.json (1)

3-3: Multi-arg UNNEST: ensure equal-length validation upstream to avoid runtime errors

This rewrite zips arrays correctly, but Postgres requires all arrays passed to unnest($1,...,$5) to have identical lengths; otherwise the statement errors (“arrays must have the same length”). Add an explicit pre-check in the calling code (before executing this query) to validate vector sizes and return a 4xx with a clear message rather than surfacing a 500. Optional: batch large payloads to avoid oversized array params, and consider renaming the alias “uri” to “endpoint” for clarity.

.sqlx/query-c947337e402bc16f72f676091cf46f03e23a4ae23c1d27ae117ad89ab44f8c26.json (1)

3-3: Align UNNEST columns explicitly and avoid no-op updates.

Readability and fewer accidental swaps if you alias columns; also skip useless updates to reduce bloat.

-  "query": "INSERT INTO view_properties (view_id, key, value)\n           SELECT $1, u.* FROM UNNEST($2::text[], $3::text[]) u\n              ON CONFLICT (view_id, key)\n                DO UPDATE SET value = EXCLUDED.value\n           ;",
+  "query": "INSERT INTO view_properties (view_id, key, value)\n+           SELECT $1, k, v\n+           FROM UNNEST($2::text[], $3::text[]) AS u(k, v)\n+           ON CONFLICT (view_id, key)\n+             DO UPDATE SET value = EXCLUDED.value\n+             WHERE view_properties.value IS DISTINCT FROM EXCLUDED.value;",

Additionally, ensure $2 and $3 have equal cardinality before execution; multi-arg UNNEST requires equal lengths.

.sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json (3)

3-3: Validate array cardinalities before execution.

Multi-arg UNNEST requires equal lengths for $1,$3,$4,$5,$6,$7,$8. Add a pre-check at the call site to avoid runtime errors.


3-3: Consider casting queue_name to a DB enum/domain if available.

If queue_name now has a dedicated DB type (e.g., task_queue_name), cast $2 to it for stricter schema guarantees. Otherwise current Text is fine.


3-3: Minor naming nit.

entity_ids/entity_types are single values per row after UNNEST; consider singular aliases to reduce confusion.

-            ) AS t(
-                task_id,
-                parent_task_id,
-                warehouse_id,
-                scheduled_for,
-                payload,
-                entity_ids,
-                entity_types
-            )
+            ) AS t(
+                task_id,
+                parent_task_id,
+                warehouse_id,
+                scheduled_for,
+                payload,
+                entity_id,
+                entity_type
+            )
...
-            i.entity_ids,
-            i.entity_types
+            i.entity_id,
+            i.entity_type
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1)

42-73: Error handling could be more specific

The error message "Task attempt has neither status nor log status" is generic. Consider including the task_id in the error for better debugging.

 .ok_or_else(|| {
     ErrorModel::internal(
-        "Task attempt has neither status nor log status.",
+        format!("Task {} has neither status nor log status", row.task_id),
         "InternalError",
         None,
     )
 })?,
crates/lakekeeper/src/implementations/postgres/tabular/view/mod.rs (1)

246-251: Prefer explicit column aliasing for multi-UNNEST.

Make the pair mapping obvious and resilient to future edits by naming columns instead of using u.*.

-        r#"INSERT INTO view_properties (view_id, key, value)
-           SELECT $1, u.* FROM UNNEST($2::text[], $3::text[]) u
+        r#"INSERT INTO view_properties (view_id, key, value)
+           SELECT $1, u.key, u.value
+           FROM UNNEST($2::text[], $3::text[]) AS u(key, value)
crates/lakekeeper/src/implementations/postgres/endpoint_statistics/sink.rs (1)

142-148: UNNEST alignment looks good; minor alias clarity.

Great switch to single multi-UNNEST. For readability, align the alias with the destination column name (warehouse_id) to avoid “warehouse” vs “warehouse_id” confusion.

-                            ) AS u(project_id, warehouse, uri, status_code, cnt)
+                            ) AS u(project_id, warehouse_id, uri, status_code, cnt)
.sqlx/query-b799019e0756b6c96e5f3bffe217d13e243efecd5517d63fa3e8f340ad3e6114.json (1)

3-3: Optional: guard duration when picked_up_at is NULL.

now() - picked_up_at yields NULL when picked_up_at is NULL; that’s fine, but if you prefer explicitness (as elsewhere), wrap with CASE.

-    now() - picked_up_at,
+    CASE WHEN picked_up_at IS NOT NULL THEN now() - picked_up_at ELSE NULL END,
crates/lakekeeper/src/implementations/postgres/tabular/table/common.rs (2)

409-416: Prefer ANY/ALL over NOT IN to avoid NULL gotchas

NOT IN with a NULL inside $2 yields UNKNOWN and deletes nothing. If refnames could ever contain NULLs, switch to a NULL-safe form.

-DELETE FROM table_refs WHERE table_id = $1 AND table_ref_name not in (SELECT UNNEST($2::TEXT[]))
+DELETE FROM table_refs
+WHERE table_id = $1
+  AND NOT (table_ref_name = ANY($2::TEXT[]))

25-28: Minor logging message copy-paste

Several error logs say “Error creating table” while performing deletes/inserts on various objects. Consider making messages specific to the operation for easier debugging.

Also applies to: 105-109, 183-186, 269-272, 334-337, 446-449, 516-519, 578-581, 670-673

crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)

97-105: Use consistent accessors in logs

Elsewhere you use task.attempt()/task.task_id(). Here, consider avoiding raw struct fields for consistency.

-            tracing::info!("Task of `{QN_STR}` worker exited successfully. Data at location `{}` deleted.", 
-                task.data.tabular_location);
+            tracing::info!(
+                "Task of `{QN_STR}` worker exited successfully. Data at location `{}` deleted.",
+                task.data.tabular_location
+            );

(And prefer task.task_id() in messages instead of task.id.)

crates/lakekeeper/src/service/task_queue/task_registry.rs (2)

70-77: Sorting by reference requires Ord; make ordering explicit

If TaskQueueName ever drops Ord, this will fail. Safer to sort by string.

-        let mut v: Vec<_> = self.queues.read().await.keys().copied().collect();
-        v.sort_unstable();
+        let mut v: Vec<_> = self.queues.read().await.keys().copied().collect();
+        v.sort_unstable_by_key(|qn| qn.as_str());
         v

318-321: Tests cover shared interior mutability and typed names

Solid coverage. Minor: assertions duplicate across initial/later sets; could DRY with a helper, but fine as-is.

Also applies to: 339-343, 357-365, 379-381, 384-401, 423-439, 441-459

crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (3)

161-174: Table/View not found handling reads well; verify ErrorKind for View

You compare against TableNotFound for both table and view paths. If Iceberg surfaces a distinct ViewNotFound, consider matching both to avoid misclassification.

-Err(e) if e.error.r#type == ErrorKind::TableNotFound.to_string() => { ... }
+Err(e) if e.error.r#type == ErrorKind::TableNotFound.to_string()
+       || e.error.r#type == ErrorKind::ViewNotFound.to_string() => { ... }

(Adjust if a specific kind exists for views.)

Also applies to: 198-201


218-241: Queueing the purge as a child task is great; bubble up Ok(None) explicitly

When ON CONFLICT prevents insert, schedule_task returns Ok(None). Consider logging a debug explaining why no purge was queued to aid observability.

-            .await
-            .map_err(|e| {
+            .await
+            .map_err(|e| {
                 e.append_detail(format!(
                     "Failed to queue purge after `{QN_STR}` task with id `{}`.",
                     task.id
                 ))
-            })?;
+            })?
+            .inspect(|opt| {
+                if opt.is_none() {
+                    tracing::debug!("No purge queued; duplicate task exists for entity/queue.");
+                }
+            });

255-414: Integration test is useful; consider reducing flakiness

Using fixed sleep (1250ms) can flake on slow CI. Prefer polling with timeout for the disappearance check.

-        tokio::time::sleep(std::time::Duration::from_millis(1250)).await;
+        let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10);
+        loop {
+            if std::time::Instant::now() > deadline { break; }
+            tokio::time::sleep(std::time::Duration::from_millis(150)).await;
+            let mut trx = PostgresTransaction::begin_read(catalog_state.clone()).await.unwrap();
+            let gone = <PostgresCatalog as Catalog>::list_tabulars(
+                warehouse, None,
+                ListFlags { include_active: false, include_staged: false, include_deleted: true },
+                trx.transaction(), PaginationQuery::empty(),
+            ).await.unwrap().remove(&tab.table_id.into()).is_none();
+            trx.commit().await.unwrap();
+            if gone { break; }
+        }
crates/lakekeeper/src/implementations/postgres/catalog.rs (1)

721-723: Nit: avoid double reference in record_success

Pass &id instead of &&id. No behavior change; just cleaner.

-        record_success(&&id, transaction, message).await
+        record_success(&id, transaction, message).await
crates/lakekeeper/src/service/task_queue/mod.rs (4)

34-72: Expose AsRef/Borrow for TaskQueueName

Small ergonomics win: add AsRef and Borrow so callers don’t need Deref/as_str manually.

 impl TaskQueueName {
@@
 }
 
+impl AsRef<str> for TaskQueueName {
+    fn as_ref(&self) -> &str {
+        &self.0
+    }
+}
+
+impl std::borrow::Borrow<str> for TaskQueueName {
+    fn borrow(&self) -> &str {
+        &self.0
+    }
+}

264-279: Unify error code naming (“TaskDataDeserializationError”)

Message says “task data” but code is “TaskStateDeserializationError”. Consider consistent naming to ease triage/metrics.

-                "TaskStateDeserializationError",
+                "TaskDataDeserializationError",

524-559: Use a specific error code for execution-details serialization

“Unexpected” is vague. Give this failure its own code to debug client payload issues faster. Optional: clamp progress to [0.0, 1.0].

-                    "Unexpected",
+                    "ExecutionDetailsSerializationError",

Optional clamp:

-        progress: f32,
+        mut progress: f32,
@@
-        C::check_and_heartbeat_task(self.id, transaction, progress, execution_details)
+        if !progress.is_finite() { progress = 0.0; }
+        progress = progress.clamp(0.0, 1.0);
+        C::check_and_heartbeat_task(self.id, transaction, progress, execution_details)

678-725: Tighten log phrasing for deserialization failure paths

A couple messages read awkwardly (“for {id} task {}”). Rephrase to include queue and id deterministically.

-                    "Failed to start DB transaction to record deserialization failure for `{}` task {id}: {e}. Original Error: {error}",
-                    Q::queue_name()
+                    "Failed to start transaction to record deserialization failure for task {id} in `{}` queue: {e}. Original Error: {error}",
+                    Q::queue_name(),
-            e.append_detail(format!(
-                "Failed to record deserialization failure for `{id}` task {}.",
-                Q::queue_name()
-            ))
+            e.append_detail(format!(
+                "Failed to record deserialization failure for task {id} in `{}` queue.",
+                Q::queue_name(),
+            ))
-                "Failed to record deserialization failure for `{id}` task {}: {e}. Original Error: {error}",
-                Q::queue_name()
+                "Failed to record deserialization failure for task {id} in `{}` queue: {e}. Original Error: {error}",
+                Q::queue_name(),
-                "Failed to commit transaction for recording deserialization failure for `{id}` task {}: {e}. Original Error: {error}",
-                Q::queue_name()
+                "Failed to commit transaction for recording deserialization failure for task {id} in `{}` queue: {e}. Original Error: {error}",
+                Q::queue_name(),
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)

45-53: Short-circuit empty batches

Avoid emitting a heavyweight UNNEST/INSERT when tasks.is_empty().

 pub(crate) async fn queue_task_batch(
@@
 ) -> Result<Vec<InsertResult>, IcebergErrorResponse> {
-    let queue_name = queue_name.as_str();
+    if tasks.is_empty() {
+        return Ok(Vec::new());
+    }
+    let queue_name = queue_name.as_str();

161-180: Nit: rename x to picked to improve readability

Variable x carries the picked row; name it accordingly.

-    let x = sqlx::query!(
+    let picked = sqlx::query!(
@@
-    if let Some(task) = x {
+    if let Some(task) = picked {

259-330: Guard duration computation when picked_up_at is NULL

Unlikely, but mirror your other queries’ CASE to be defensive.

-                duration,
+                case when picked_up_at is not null
+                    then now() - picked_up_at
+                    else null
+                end as duration,

474-506: Return max_seconds_since_last_heartbeat with rounding

Minor: integer division truncates. Consider rounding to nearest second for friendlier UX.

-            .map(|x| x.microseconds / 1_000_000),
+            .map(|x| ((x.microseconds + 500_000) / 1_000_000)),

508-551: Allow clearing max_time_since_last_heartbeat

Today COALESCE preserves old value when input is None; add explicit “clear” path if API needs to unset. If not required, ignore.


579-611: Clamp/validate progress in DB call

Optionally clamp to [0,1] here too for consistency with service layer suggestion.

-    Ok(sqlx::query!(
+    let progress = if progress.is_finite() { progress.clamp(0.0, 1.0) } else { 0.0 };
+    Ok(sqlx::query!(
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e6e8e99 and 23ae5a8.

📒 Files selected for processing (38)
  • .sqlx/query-009c03de13ca6188f4c2ce1205783d9ea7f67ac8bc0c0e567d5e268ced7758a4.json (1 hunks)
  • .sqlx/query-078951ebbfe504d8049b2e6f3748af439d28fe8efd68a2bab46c6918b064029e.json (2 hunks)
  • .sqlx/query-0b673560354dbfb03bfe7e67b7695a56fa744f6917784abf2bf458de3766326c.json (2 hunks)
  • .sqlx/query-1782897da2409ef85283e5de1c05a751dca0c5972ffa8afabc0e65bf7dd70fe1.json (0 hunks)
  • .sqlx/query-1b63f41221fc9b9008289c6092d278e17488fa9cf61aab4cd8ffa4f210a300e5.json (1 hunks)
  • .sqlx/query-2b838db363de7027ecb22b4f4d7d92ab06f417dcf82d587f08906d9fafae7cb8.json (2 hunks)
  • .sqlx/query-5f1b3748f859f67ffe73908b8ed56e04eb92f841b5c63cc7a881036e0d664a59.json (2 hunks)
  • .sqlx/query-6eb81444b25f070f01777ccbbc5f7b662bb3ed494b55616479cd36c66694f968.json (3 hunks)
  • .sqlx/query-7bae9ea01c9a8adf726d239499183c0bb46b44b2ffe9f60b2db3194fd038e47e.json (1 hunks)
  • .sqlx/query-7bd3f701a68d5e56def7eb575427ddb11e884dc393c0563e840797914536a0d6.json (1 hunks)
  • .sqlx/query-7daec1b99e2b91e7546adf64c4ef9e584e0f19b805c699a70969c205f5c33b7f.json (1 hunks)
  • .sqlx/query-8cf29b178cb4a59d1cfc2f43d7ebf3cd1d8a44fbcdc57a1ee1cf86be2885b1ec.json (2 hunks)
  • .sqlx/query-94d74cdcb2507a2504aea37264750034609ae69e572316ca9386a59080595e3e.json (0 hunks)
  • .sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json (2 hunks)
  • .sqlx/query-b799019e0756b6c96e5f3bffe217d13e243efecd5517d63fa3e8f340ad3e6114.json (1 hunks)
  • .sqlx/query-b7f5e20f95de77d3339c35142122b33fab017a89690f552557ad3f179f82399f.json (1 hunks)
  • .sqlx/query-bbbadc53978e1e32bc667fa6796fbee53ccfd22044ba5dc78d59655fabe4c0f8.json (0 hunks)
  • .sqlx/query-bf372c3a0aef57991070dd70f658d4efd105d944c077e2d83892865a3adae128.json (2 hunks)
  • .sqlx/query-c34538592c32c7303aa82638f9a1f7684f88288a01517c2b5305befdfeb7b4c2.json (2 hunks)
  • .sqlx/query-c947337e402bc16f72f676091cf46f03e23a4ae23c1d27ae117ad89ab44f8c26.json (2 hunks)
  • .sqlx/query-d0b2eeac710ddb262ddcbed526d261690bf9f308951888e86ce1748b49d58a97.json (2 hunks)
  • .sqlx/query-d1e9859dcc600e55628e413e2e98eb658d1d08ad10b91beb8ca168c8e17045f8.json (1 hunks)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1 hunks)
  • crates/lakekeeper/src/api/management/v1/project.rs (2 hunks)
  • crates/lakekeeper/src/implementations/postgres/catalog.rs (7 hunks)
  • crates/lakekeeper/src/implementations/postgres/endpoint_statistics/sink.rs (2 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/table/common.rs (8 hunks)
  • crates/lakekeeper/src/implementations/postgres/tabular/view/mod.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1 hunks)
  • crates/lakekeeper/src/service/catalog.rs (7 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (24 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (13 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3 hunks)
  • crates/lakekeeper/src/service/task_queue/task_registry.rs (15 hunks)
  • crates/lakekeeper/src/tests/tasks.rs (6 hunks)
💤 Files with no reviewable changes (3)
  • .sqlx/query-1782897da2409ef85283e5de1c05a751dca0c5972ffa8afabc0e65bf7dd70fe1.json
  • .sqlx/query-bbbadc53978e1e32bc667fa6796fbee53ccfd22044ba5dc78d59655fabe4c0f8.json
  • .sqlx/query-94d74cdcb2507a2504aea37264750034609ae69e572316ca9386a59080595e3e.json
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs
  • crates/lakekeeper/src/api/management/v1/project.rs
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
  • crates/lakekeeper/src/service/catalog.rs
  • crates/lakekeeper/src/tests/tasks.rs
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-31T11:28:55.713Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json:4-22
Timestamp: 2025-08-31T11:28:55.713Z
Learning: The task_final_status PostgreSQL enum and the primary key constraint on task_log(task_id, attempt) were both established in migration 20250523101407_tasks_store_their_state.sql, not missing from the schema.

Applied to files:

  • .sqlx/query-1b63f41221fc9b9008289c6092d278e17488fa9cf61aab4cd8ffa4f210a300e5.json
  • .sqlx/query-7bae9ea01c9a8adf726d239499183c0bb46b44b2ffe9f60b2db3194fd038e47e.json
  • .sqlx/query-7bd3f701a68d5e56def7eb575427ddb11e884dc393c0563e840797914536a0d6.json
  • .sqlx/query-b799019e0756b6c96e5f3bffe217d13e243efecd5517d63fa3e8f340ad3e6114.json
  • .sqlx/query-7daec1b99e2b91e7546adf64c4ef9e584e0f19b805c699a70969c205f5c33b7f.json
📚 Learning: 2025-08-31T11:58:20.853Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json:3-3
Timestamp: 2025-08-31T11:58:20.853Z
Learning: In .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json, the UPDATE statement that sets progress = 0.0, picked_up_at = NULL, and execution_details = NULL is correct because this code branch only executes when max_retries_exceeded is true, and the intention is to reset the task state to make it available for pickup again in the retry mechanism.

Applied to files:

  • .sqlx/query-1b63f41221fc9b9008289c6092d278e17488fa9cf61aab4cd8ffa4f210a300e5.json
  • .sqlx/query-7bd3f701a68d5e56def7eb575427ddb11e884dc393c0563e840797914536a0d6.json
  • .sqlx/query-b799019e0756b6c96e5f3bffe217d13e243efecd5517d63fa3e8f340ad3e6114.json
  • .sqlx/query-5f1b3748f859f67ffe73908b8ed56e04eb92f841b5c63cc7a881036e0d664a59.json
  • .sqlx/query-7daec1b99e2b91e7546adf64c4ef9e584e0f19b805c699a70969c205f5c33b7f.json
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs
  • .sqlx/query-5f1b3748f859f67ffe73908b8ed56e04eb92f841b5c63cc7a881036e0d664a59.json
  • crates/lakekeeper/src/implementations/postgres/tasks.rs
🧬 Code graph analysis (8)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (18)
  • tasks (372-389)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • id (260-262)
  • id (322-324)
  • task_id (250-252)
  • task_id (312-314)
  • record_failure (564-601)
  • record_success (607-643)
  • queue_name (98-98)
  • queue_name (307-309)
  • task (437-437)
  • task (449-449)
  • attempt (255-257)
  • attempt (317-319)
  • to_uuid (185-189)
  • cancel_scheduled_tasks (400-418)
crates/lakekeeper/src/implementations/postgres/tasks.rs (7)
  • from (38-42)
  • pick_task (163-257)
  • record_failure (333-472)
  • record_success (259-330)
  • setup_warehouse (856-869)
  • queue_task_batch (45-159)
  • cancel_scheduled_tasks (621-758)
crates/lakekeeper/src/api/management/v1/tasks.rs (3)
  • from (118-124)
  • from (128-134)
  • split (139-148)
crates/lakekeeper/src/implementations/postgres/pagination.rs (4)
  • try_from (44-46)
  • try_from (55-57)
  • try_from (67-109)
  • s (87-87)
crates/lakekeeper/src/implementations/postgres/tasks.rs (5)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (92-269)
  • tasks (249-252)
  • status (76-79)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/service/task_queue/mod.rs (21)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • Self (440-440)
  • Self (452-452)
  • queue_name (98-98)
  • queue_name (307-309)
  • tasks (372-389)
  • max_time_since_last_heartbeat (89-91)
  • task (437-437)
  • task (449-449)
  • id (260-262)
  • id (322-324)
  • task_id (250-252)
  • task_id (312-314)
  • attempt (255-257)
  • attempt (317-319)
  • max_retries (94-96)
  • as_str (64-66)
  • cancel_scheduled_tasks (400-418)
  • queue_config (285-302)
crates/lakekeeper/src/implementations/postgres/catalog.rs (3)
  • get_task_queue_config (800-806)
  • set_task_queue_config (791-798)
  • cancel_scheduled_tasks (766-773)
crates/lakekeeper/src/implementations/postgres/catalog.rs (5)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)
  • tasks (249-252)
  • list_tasks (92-269)
crates/lakekeeper/src/implementations/postgres/tasks.rs (8)
  • cancel_scheduled_tasks (621-758)
  • check_and_heartbeat_task (579-611)
  • get_task_queue_config (474-506)
  • pick_task (163-257)
  • queue_task_batch (45-159)
  • record_failure (333-472)
  • record_success (259-330)
  • set_task_queue_config (508-551)
crates/lakekeeper/src/service/catalog.rs (17)
  • cancel_scheduled_tasks (1008-1013)
  • check_and_heartbeat_task (1016-1023)
  • get_task_details (953-960)
  • get_task_queue_config (1049-1053)
  • list_tasks (970-976)
  • resolve_tasks (852-889)
  • set_task_queue_config (1042-1047)
  • transaction (84-84)
  • pick_new_task_impl (820-824)
  • resolve_tasks_impl (843-847)
  • record_task_success_impl (912-916)
  • record_task_failure_impl (926-931)
  • get_task_details_impl (944-949)
  • list_tasks_impl (963-967)
  • enqueue_tasks (984-988)
  • check_and_heartbeat_task_impl (1026-1031)
  • stop_tasks (1037-1040)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-105)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (2)
crates/lakekeeper/src/service/task_queue/mod.rs (17)
  • tasks (372-389)
  • task_id (250-252)
  • task_id (312-314)
  • task (437-437)
  • task (449-449)
  • from (46-48)
  • from (116-118)
  • from (122-124)
  • record_failure (564-601)
  • record_success (607-643)
  • queue_name (98-98)
  • queue_name (307-309)
  • attempt (255-257)
  • attempt (317-319)
  • as_str (64-66)
  • task_data (268-279)
  • to_uuid (185-189)
crates/lakekeeper/src/implementations/postgres/tasks.rs (8)
  • from (38-42)
  • check_and_heartbeat_task (579-611)
  • pick_task (163-257)
  • record_failure (333-472)
  • record_success (259-330)
  • setup_warehouse (856-869)
  • queue_task_batch (45-159)
  • task_metadata (1401-1408)
crates/lakekeeper/src/service/task_queue/mod.rs (5)
crates/lakekeeper/src/service/task_queue/task_registry.rs (7)
  • fmt (29-34)
  • fmt (88-93)
  • fmt (122-128)
  • fmt (291-297)
  • queue_name (328-330)
  • queue_name (340-342)
  • serde_json (146-146)
crates/lakekeeper/src/implementations/postgres/tasks/list_pagination_token.rs (1)
  • fmt (12-14)
crates/lakekeeper/src/service/mod.rs (21)
  • fmt (260-262)
  • fmt (288-290)
  • fmt (317-319)
  • fmt (350-352)
  • fmt (408-410)
  • fmt (448-450)
  • deref (213-215)
  • deref (268-270)
  • deref (282-284)
  • deref (311-313)
  • deref (358-360)
  • deref (436-438)
  • deref (504-506)
  • from (63-65)
  • from (160-162)
  • from (274-276)
  • from (338-340)
  • from (344-346)
  • from (364-366)
  • from (385-387)
  • from (442-444)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • from (38-42)
  • check_and_heartbeat_task (579-611)
crates/lakekeeper/src/service/catalog.rs (4)
  • transaction (84-84)
  • check_and_heartbeat_task (1016-1023)
  • record_task_failure (933-940)
  • record_task_success (918-924)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (3)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
  • tabular_purge_queue (211-211)
  • new (133-138)
  • queue_name (328-330)
  • queue_name (340-342)
crates/lakekeeper/src/service/task_queue/mod.rs (15)
  • new (59-61)
  • Self (440-440)
  • Self (452-452)
  • queue_name (98-98)
  • queue_name (307-309)
  • task (437-437)
  • task (449-449)
  • poll_for_new_task (477-522)
  • attempt (255-257)
  • attempt (317-319)
  • task_id (250-252)
  • task_id (312-314)
  • id (260-262)
  • id (322-324)
  • schedule_task (333-357)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)
  • new (34-39)
  • queue_name (48-50)
  • task (103-103)
  • task (111-111)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (8)
  • queue_name (98-98)
  • queue_name (307-309)
  • Self (440-440)
  • Self (452-452)
  • new (59-61)
  • from (46-48)
  • from (116-118)
  • from (122-124)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (3)
  • queue_name (68-70)
  • tabular_purge_queue (220-220)
  • new (48-53)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (2)
  • queue_name (48-50)
  • new (34-39)
crates/lakekeeper/src/tests/tasks.rs (1)
  • queue_name (52-54)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (2)
crates/lakekeeper/src/tests/tasks.rs (2)
  • SpecializedTask (80-82)
  • queue_name (52-54)
crates/lakekeeper/src/service/task_queue/mod.rs (12)
  • new (59-61)
  • Self (440-440)
  • Self (452-452)
  • queue_name (98-98)
  • queue_name (307-309)
  • task (437-437)
  • task (449-449)
  • poll_for_new_task (477-522)
  • attempt (255-257)
  • attempt (317-319)
  • task_id (250-252)
  • task_id (312-314)
🪛 GitHub Check: clippy
crates/lakekeeper/src/implementations/postgres/tasks.rs

[failure] 45-45:
this function has too many lines (109/100)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: test
  • GitHub Check: sqlx-check
🔇 Additional comments (70)
.sqlx/query-c34538592c32c7303aa82638f9a1f7684f88288a01517c2b5305befdfeb7b4c2.json (1)

15-15: Descriptor hash update looks consistent with the query change.

No action needed.

.sqlx/query-7bae9ea01c9a8adf726d239499183c0bb46b44b2ffe9f60b2db3194fd038e47e.json (2)

3-3: Solid atomic move-to-log pattern; parameters and column mapping look consistent.

Single-statement CTE delete + insert is atomic; parameter order ($1 UUID, $2 text, $3 task_final_status, $4 int) matches the describe block, and column mapping from moved → task_log is coherent. Good use of PK (task_id, attempt) to ensure idempotency.


12-29: Descriptor aligns with schema choices noted in migrations.

Parameters include task_final_status enum and the (task_id, attempt) PK on task_log is assumed; both were introduced in migration 20250523101407_tasks_store_their_state.sql per team notes. Looks consistent.

.sqlx/query-8cf29b178cb4a59d1cfc2f43d7ebf3cd1d8a44fbcdc57a1ee1cf86be2885b1ec.json (1)

15-15: Hash update acknowledged.

No action needed.

.sqlx/query-078951ebbfe504d8049b2e6f3748af439d28fe8efd68a2bab46c6918b064029e.json (2)

3-3: Multi-column UNNEST rewrite: mapping looks correct.

table_id <- $2 (scalar UUID), snapshot_id/statistics_path/file_size_in_bytes/file_footer_size_in_bytes/key_metadata/blob_metadata <- u.col1..col6 from $1,$3,$4,$5,$6,$7. LGTM.


19-19: sqlx hash update acknowledged.

Generated artifact; no action.

.sqlx/query-009c03de13ca6188f4c2ce1205783d9ea7f67ac8bc0c0e567d5e268ced7758a4.json (2)

7-12: Validate array contract: lengths equal, arrays non-null, names non-empty.

UNNEST($2,$3,$4) requires equal-length arrays; NULL arrays or NULL elements will cause errors or undesirable deletes. Enforce upstream:

  • Arrays are non-null and same length.
  • table_ref_name elements are non-null/non-empty.

I can provide a small guard in the caller to assert these invariants if you want.


3-3: Ensure supporting constraint exists.

ON CONFLICT (table_id, table_ref_name) assumes a unique index/constraint on that pair. Verify it’s present post-migration.

If missing, add:

ALTER TABLE table_refs
  ADD CONSTRAINT table_refs_table_id_ref_name_key UNIQUE (table_id, table_ref_name);
.sqlx/query-d0b2eeac710ddb262ddcbed526d261690bf9f308951888e86ce1748b49d58a97.json (2)

15-15: Hash update acknowledged

Descriptor hash matches the query change. Nothing else to do.


3-3: Cast to INT4[] and alias UNNEST columns for clarity

-  "query": "INSERT INTO table_partition_spec(partition_spec_id, table_id, partition_spec)\n               SELECT sid, $2, s FROM UNNEST($1::INT[], $3::JSONB[]) u(sid, s)",
+  "query": "INSERT INTO table_partition_spec(partition_spec_id, table_id, partition_spec)\n               SELECT partition_spec_id, $2, partition_spec\n               FROM UNNEST($1::INT4[], $3::JSONB[]) AS u(partition_spec_id, partition_spec)",

Note: PostgreSQL requires all arrays in a multi‐argument UNNEST to be equal length; ensure callers supply matching‐length arrays or handle the resulting error.

.sqlx/query-7daec1b99e2b91e7546adf64c4ef9e584e0f19b805c699a70969c205f5c33b7f.json (1)

12-29: Describe block looks consistent with schema.

Parameter types (Uuid, task_final_status enum, Int4) and non-null result align with the migrations you added for task_final_status and task_log PK.

.sqlx/query-6eb81444b25f070f01777ccbbc5f7b662bb3ed494b55616479cd36c66694f968.json (1)

122-122: Metadata hash updated

Auto-generated by SQLx; no action needed.

.sqlx/query-b7f5e20f95de77d3339c35142122b33fab017a89690f552557ad3f179f82399f.json (1)

3-3: No column order issue in insert_partition_statistics SQL
SELECT $2, u.* correctly maps $2 to table_id (UUID) and the elements of u.* to snapshot_id, statistics_path, and file_size_in_bytes as defined by the explicit column list. No changes required.

Likely an incorrect or invalid review comment.

.sqlx/query-2b838db363de7027ecb22b4f4d7d92ab06f417dcf82d587f08906d9fafae7cb8.json (2)

3-3: Good switch to paired UNNEST; avoids cross join.


3-3: Add composite index on (project_id, warehouse_name)
Add a migration to create an index on (project_id, warehouse_name) in the warehouse table to optimize the tuple‐IN lookup. Confirm this index exists in your schema; if it’s missing, add for example:

CREATE INDEX idx_warehouse_project_warehouse
  ON warehouse(project_id, warehouse_name);
.sqlx/query-bf372c3a0aef57991070dd70f658d4efd105d944c077e2d83892865a3adae128.json (1)

3-3: No change required: table_metadata_log.timestamp is bigint. Inserting ts directly matches the column type, so no cast is needed.

.sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json (1)

3-3: Solid batching with multi-column UNNEST and idempotent insert.

.sqlx/query-d1e9859dcc600e55628e413e2e98eb658d1d08ad10b91beb8ca168c8e17045f8.json (2)

179-180: DISTINCT ON clause may not guarantee deterministic results

Using DISTINCT ON (task_created_at, task_id) with ORDER BY task_created_at DESC, task_id DESC, attempt DESC will select the highest attempt for each task. However, this relies on PostgreSQL-specific behavior and could be more explicit.

The approach is correct for getting the latest attempt from task_log. The DISTINCT ON with proper ordering ensures we get the most recent attempt for each task.


146-149: No additional index needed
Existing indexes on (warehouse_id, entity_type, entity_id)—task_warehouse_id_entity_type_entity_id_idx and task_log_warehouse_id_entity_type_entity_id_idx—already cover the suggested columns (see crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql).

.sqlx/query-5f1b3748f859f67ffe73908b8ed56e04eb92f841b5c63cc7a881036e0d664a59.json (1)

3-3: LGTM! Improved task picking logic with proper heartbeat handling

The query correctly handles both scheduled tasks and tasks that need recovery (based on heartbeat timeout). The state reset (progress = 0.0, execution_details = NULL) on pick ensures clean retry semantics.

crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (4)

107-108: Good use of configuration defaults

Using CONFIG.page_size_or_pagination_default ensures consistent pagination behavior across the API.


143-229: Complex SQL query is well-structured with proper filtering

The query correctly handles:

  • Multiple filter conditions with proper NULL handling
  • UNION ALL to combine active and completed tasks
  • Proper pagination with ORDER BY

135-141: Entity filtering logic correctly scopes to warehouse

The filter (entity_warehouse_id == warehouse_id).then_some(...) ensures entities from other warehouses are excluded, preventing potential data leaks.


271-1316: Comprehensive test coverage

The test suite thoroughly covers:

  • Empty warehouse scenarios
  • Single and multiple tasks
  • Various filter combinations
  • Pagination edge cases
  • Mixed active/completed tasks
  • Retry scenarios
  • Cross-warehouse isolation

Excellent test coverage!

crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (5)

37-123: Parse function correctly handles attempt ordering and data extraction

The function properly:

  • Sorts attempts by descending order
  • Handles the most recent record specially
  • Maps all fields correctly with appropriate error handling

151-230: SQL query correctly combines active and historical tasks

The UNION ALL approach properly fetches both active tasks (from task table) and completed tasks (from task_log), with appropriate duration calculation for active tasks.


234-241: Proper truncation of attempts based on requested limit

The code correctly limits the number of historical attempts returned while ensuring the main task details are always included.


244-1010: Excellent test coverage for task details retrieval

The test suite comprehensively covers:

  • Empty/non-existent tasks
  • Active tasks with and without history
  • Completed tasks
  • Retry scenarios with multiple attempts
  • Parent-child task relationships
  • Cross-warehouse isolation
  • Attempt limiting

191-194: Duration calculation for active tasks uses database time

The duration calculation now() - picked_up_at uses the database server's current time, which is good for consistency across different application servers.

crates/lakekeeper/src/implementations/postgres/endpoint_statistics/sink.rs (1)

221-229: Composite IN via multi-UNNEST looks correct.

The pairwise unnest($1, $2) for (project_id, warehouse_name) is the right choice here.

.sqlx/query-0b673560354dbfb03bfe7e67b7695a56fa744f6917784abf2bf458de3766326c.json (1)

3-3: LGTM: row pairing and deterministic order.

Switch to UNNEST($1,$3,$4) with explicit (sid, ts, seq) and ORDER BY seq ensures stable, correctly paired inserts.

.sqlx/query-1b63f41221fc9b9008289c6092d278e17488fa9cf61aab4cd8ffa4f210a300e5.json (1)

3-3: Boolean “toggle” semantics are easy to invert — confirm call sites.

(status = $3 OR $5) and (queue_name = $2 OR $6) mean “ignore the filter when the toggle is TRUE.” Verify callers pass FALSE to apply the filter (and TRUE to ignore), or flip the predicate for self-documenting intent.

Optional alternative for clarity:

(status = $3 OR $5 IS TRUE)
crates/lakekeeper/src/implementations/postgres/tabular/table/common.rs (7)

133-138: UNNEST refactor looks correct and safer

Parallel UNNEST with explicit aliases removes cross-product risk and matches column order. Good use of typed casts.


211-216: Consistent multi-column UNNEST

Same positive note here; deterministic mapping and simpler SQL.


297-304: Deterministic log ordering via synthetic seq is solid

Introducing seq for ORDER BY preserves original order across inserts. Nice.


369-376: Metadata log ordering fix mirrors snapshot log correctly

Parallel arrays + ORDER BY seq avoids out-of-order rows.


568-570: Partition stats insert: column order change is correct

Selecting $2 as table_id then u.* matches DDL order; arrays are length-aligned.


637-646: Table stats insert: alignment and casts look right

Key/Blob metadata serialization handled; casts to JSONB/TEXT are explicit.


523-549: Call sites verified and transactional scope intact Both calls in commit.rs (line 457) and create.rs (line 88) pass the existing &mut PgConnection without change, and the helper uses the provided transaction only.

crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3)

16-20: Typed queue name adoption is clean

Using QN_STR + static LazyLock aligns with the new typed registry.


24-26: ExecutionDetails type wired in correctly

Three-parameter SpecializedTask and empty details struct implement the new trait with no functional behavior change.

Also applies to: 53-57


146-148: Good: commit read txn before IO

Avoids holding locks during storage deletes. Keep this pattern.

crates/lakekeeper/src/service/task_queue/task_registry.rs (4)

42-43: Keying by &'static TaskQueueName is appropriate

Constraining to 'static avoids lifetime pitfalls and matches the queue constants.


51-57: Validator lookup by typed name

Signature change to &TaskQueueName is aligned with the rest of the API.


140-171: Bound switch to TaskConfig is correct

Registry now validates against TaskConfig::queue_name and ToSchema. Good change.


183-207: Built-in registrations updated to typed names

Consistent with QUEUE_NAME constants from queues; worker wiring looks fine.

Also applies to: 205-222

crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (5)

25-31: Typed queue name + API config: good migration

Matches the purge queue pattern and the registry.


33-37: Task triple, payload ctor, and details type are coherent

Interfaces align with SpecializedTask API and docs generation.

Also applies to: 46-54, 58-62, 67-71


80-86: Span fields and accessors are correct and consistent

Using attempt() and task_id() avoids relying on internal struct layout.

Also applies to: 94-102


150-155: Good: explicit error context on begin_write failure

Context string includes queue identifier, helpful for ops.


247-251: Commit error path logs and returns

Looks good; success is recorded inside the transaction earlier, so rollback is consistent.

crates/lakekeeper/src/implementations/postgres/catalog.rs (7)

189-196: resolve_table_ident return type upgrade

Returning TabularDetails is a good API improvement; callers get richer context.


695-706: pick_new_task_impl: correct pool and typed name usage

Using write_pool and &TaskQueueName matches the new tasks module.


733-741: get_task_details_impl forwarding is OK

Keeps ownership of transaction and avoids extra borrow churn.


751-764: enqueue_tasks: typed queue name propagation

Good propagation to SQL layer; early-return on empty input prevents empty UNNEST.


766-773: cancel_scheduled_tasks: typed Option<&TaskQueueName>

Signature and wiring align with new semantics.


775-783: check_and_heartbeat_task_impl exposes progress/details

Nice—enables workers to report progress and arbitrary execution details.


791-807: Task queue config getters/setters: typed names and error messages

Looks correct and consistent with tasks.rs.

crates/lakekeeper/src/service/task_queue/mod.rs (5)

74-85: LGTM: TaskEntity serde shape is clear and versionable

Kebab-case + tagged enum matches the API. Test below confirms round-trip.


285-302: LGTM: Config deserialization and error shaping

Good use of Option + contextualized ErrorModel including queue name.


794-816: LGTM: Status/Outcome enums are minimal and well-typed

Derives (Eq/Hash/EnumIter/sqlx) look correct; mapping to DB types is consistent.


833-842: LGTM: Defensive const fn for heartbeat window

Good asserts; Duration math stays in i64 microseconds domain.


846-868: LGTM: TaskEntity serde round-trip test

Solid targeted unit test.

crates/lakekeeper/src/implementations/postgres/tasks.rs (7)

31-43: LGTM: EntityType mapping and From

The enum/type wiring for sqlx looks clean and future-proof for more entity kinds.


78-141: LGTM: UNNEST-based bulk insert with idempotency key

Good use of composite conflict key (warehouse_id, entity_type, entity_id, queue_name) and returning only inserted rows.


199-205: Reset execution_details on pickup

Good call clearing per-attempt details when a new attempt starts.


332-472: LGTM: Failure path covers both reschedule and terminal

Attempt gating (>= max_retries) and row-locking look correct; error shaping includes task id/attempt.


553-577: LGTM: request_tasks_stop is precise and idempotent

Updates only Running tasks; ShouldStop requests are not re-applied.


621-758: LGTM: Cancel flows log-then-delete with idempotency

Boolean gates (force + queue_name_is_none) are clean; CASE on duration matches other writes.


760-2016: Great test coverage for lifecycle and idempotency

Broad, scenario-driven tests (queue, pick, success/failure, reinsert, cancel, config) materially reduce regression risk.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/docs/api/management-open-api.yaml (2)

2245-2285: Fix path parameter mismatch and POST summary for task-queue config (tabular_expiration).

  • The queue_name path parameter is declared but not present in the path template; this breaks validation.
  • POST summary incorrectly says “Get...”.

Apply:

   /management/v1/{warehouse_id}/task-queue/tabular_expiration/config:
     get:
       tags:
         - tasks
-      summary: Get the configuration for a Task Queue.
+      summary: Get the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.
       operationId: get_task_queue_config_tabular_expiration
       parameters:
         - name: warehouse_id
           in: path
           required: true
           schema:
             type: string
             format: uuid
-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string
     post:
       tags:
         - tasks
-      summary: Get the configuration for a Task Queue.
+      summary: Set the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.

Also applies to: 2283-2309


2311-2351: Fix path parameter mismatch and POST summary for task-queue config (tabular_purge).

Same issues as above.

   /management/v1/{warehouse_id}/task-queue/tabular_purge/config:
     get:
       tags:
         - tasks
-      summary: Get the configuration for a Task Queue.
+      summary: Get the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.
       operationId: get_task_queue_config_tabular_purge
       parameters:
         - name: warehouse_id
           in: path
           required: true
           schema:
             type: string
             format: uuid
-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string
     post:
       tags:
         - tasks
-      summary: Get the configuration for a Task Queue.
+      summary: Set the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.

Also applies to: 2349-2376

♻️ Duplicate comments (3)
crates/lakekeeper/src/service/task_queue/mod.rs (1)

100-104: Send + Sync bounds added — looks good and addresses prior review

This resolves cross-task/thread safety of payloads and execution details.

docs/docs/api/management-open-api.yaml (2)

3466-3472: LGTM: queue-name accepts multiple values now.

Spec now matches server expecting multiple queues.


4627-4662: LGTM: parent-task-id nullable and not required.

Aligns with actual responses that may contain null.

🧹 Nitpick comments (24)
crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (2)

36-55: Slightly cleaner: build the iterator directly and skip the Vec

You can pass an iterator of futures to try_join_all and avoid the temporary Vec entirely.

-    let mut futs = Vec::with_capacity(tabs.len());
-
-    for t in tabs {
-        match t {
-            TabularId::View(id) => {
-                futs.push(authorizer.is_allowed_view_action(
-                    request_metadata,
-                    (*id).into(),
-                    crate::service::authz::CatalogViewAction::CanUndrop,
-                ));
-            }
-            TabularId::Table(id) => {
-                futs.push(authorizer.is_allowed_table_action(
-                    request_metadata,
-                    (*id).into(),
-                    crate::service::authz::CatalogTableAction::CanUndrop,
-                ));
-            }
-        }
-    }
-    let all_allowed = futures::future::try_join_all(futs)
+    let futs = tabs.iter().map(|t| match t {
+        TabularId::View(id) => authorizer.is_allowed_view_action(
+            request_metadata,
+            (*id).into(),
+            crate::service::authz::CatalogViewAction::CanUndrop,
+        ),
+        TabularId::Table(id) => authorizer.is_allowed_table_action(
+            request_metadata,
+            (*id).into(),
+            crate::service::authz::CatalogTableAction::CanUndrop,
+        ),
+    });
+    let all_allowed = futures::future::try_join_all(futs)
         .await?
         .into_iter()
         .all(MustUse::into_inner);

56-60: Optional: consider bounded concurrency/early-exit if tabs can be large

If targets can be large, buffer_unordered with a small limit (e.g., 32) to reduce load and short-circuit on the first false.

Rust sketch (requires use futures::{stream, StreamExt, TryStreamExt};):

let all_allowed = stream::iter(tabs.iter().map(|t| match t {
    TabularId::View(id) => authorizer.is_allowed_view_action(
        request_metadata, (*id).into(), crate::service::authz::CatalogViewAction::CanUndrop),
    TabularId::Table(id) => authorizer.is_allowed_table_action(
        request_metadata, (*id).into(), crate::service::authz::CatalogTableAction::CanUndrop),
}))
.buffer_unordered(32)
.then(|res| async move { res.map(MustUse::into_inner) })
.try_fold(true, |acc, ok| async move { Ok(acc && ok) })
.await?;
.sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json (2)

3-3: Use clock_timestamp() for accurate duration.

now() is fixed at transaction start; use clock_timestamp() to capture wall-clock time of log write.

Apply:

-                    now() - picked_up_at,
+                    clock_timestamp() - picked_up_at,

3-3: Optional guard to avoid resetting non-running tasks.

If business logic expects resets only from a running state, add a predicate to the UPDATE to prevent accidental state rewinds.

-            FROM locked
-                WHERE t.task_id = locked.task_id AND t.attempt = locked.attempt
+            FROM locked
+                WHERE t.task_id = locked.task_id
+                  AND t.attempt = locked.attempt
+                  AND t.status = 'running'::task_intermediate_status
.sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json (4)

3-3: Make bypass conditions explicit and more readable.

Reorder boolean-shortcut clauses to the conventional “bypass OR predicate” form to avoid misreads and accidental precedence mistakes.

Apply:

-DELETE FROM task
-WHERE (status = $3 OR $6) AND task_id = ANY($1) AND (queue_name = $4 OR $5)
+DELETE FROM task
+WHERE task_id = ANY($1)
+  AND ($6 OR status = $3)
+  AND ($5 OR queue_name = $4)

3-3: Consider conflict-upsert semantics to preserve latest/final status.

ON CONFLICT DO NOTHING drops the insert if (task_id, attempt) already exists, potentially losing an updated $2 (final) status. If idempotency must still hold, prefer an UPSERT that keeps the “most final” state.

Example:

-ON CONFLICT (task_id, attempt) DO NOTHING
+ON CONFLICT (task_id, attempt) DO UPDATE
+  SET status = EXCLUDED.status,
+      duration = COALESCE(EXCLUDED.duration, task_log.duration),
+      last_heartbeat_at = GREATEST(EXCLUDED.last_heartbeat_at, task_log.last_heartbeat_at)

3-3: Optional: record finished_at explicitly for auditability.

If task_log has finished_at (or you plan to add it), capturing it alongside duration improves timelines, especially when picked_up_at is NULL.

Proposed addition (if column exists):

-    duration,
+    duration,
+    finished_at,
...
-    case when picked_up_at is not null
+    case when picked_up_at is not null
         then now() - picked_up_at
         else null
     end,
+    now(),

3-3: Parent/child integrity on delete.

Deleting running tasks may break FK references from child tasks (parent_task_id). Verify FK actions (CASCADE/SET NULL/RESTRICT) match the product intent for forced cancellations.

If children should be cancelled too, consider a recursive CTE to collect descendants and apply the same archive-delete atomically.

.sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json (4)

3-3: Preserve/refresh logs on conflicts instead of dropping them.

ON CONFLICT (task_id, attempt) DO NOTHING can leave stale rows in task_log (e.g., status never updated to final). Prefer an upsert to keep audit data authoritative.

Apply:

-                ON CONFLICT (task_id, attempt) DO NOTHING
+                ON CONFLICT (task_id, attempt) DO UPDATE
+                SET status = EXCLUDED.status,
+                    duration = COALESCE(EXCLUDED.duration, task_log.duration),
+                    progress = COALESCE(EXCLUDED.progress, task_log.progress),
+                    execution_details = COALESCE(EXCLUDED.execution_details, task_log.execution_details),
+                    attempt_scheduled_for = COALESCE(EXCLUDED.attempt_scheduled_for, task_log.attempt_scheduled_for),
+                    last_heartbeat_at = GREATEST(task_log.last_heartbeat_at, EXCLUDED.last_heartbeat_at)

3-3: Use clock_timestamp() for accurate per-row duration.

now() is fixed at transaction start; durations can skew in long-running txns. clock_timestamp() reflects wall-clock time at execution.

-                            then now() - picked_up_at
+                            then clock_timestamp() - picked_up_at

4-37: Prefer arrays over bypass booleans for better clarity and planning.

Two booleans ($5/$6) encode “match any,” which hurts planning and readability. Consider array params and ANY/IN semantics (often friendlier to indexes/bitmap scans).

Example shape:

-- parameters: $1 warehouse_id uuid, $2 queue_names text[], $3 statuses task_intermediate_status[], $4 final task_final_status
WITH deleted AS (
  DELETE FROM task t
  WHERE t.warehouse_id = $1
    AND (array_length($2,1) IS NULL OR t.queue_name = ANY($2))
    AND (array_length($3,1) IS NULL OR t.status = ANY($3))
  RETURNING *
)
INSERT INTO task_log (...)
SELECT ... FROM deleted
ON CONFLICT (task_id, attempt) DO UPDATE ...

3-3: Indexing advice for the DELETE predicate.

To support this and related filters, ensure composite indexes exist (even if ORs limit usage in this form):

  • task(warehouse_id, queue_name, status)
  • task(warehouse_id, status, queue_name)

If retaining boolean bypass, consider separate query variants (without ORs) to maximize index usage.

crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)

112-119: Consider extracting the pagination token parsing logic

The pagination token parsing logic here is a bit convoluted with the nested map and map_or. Consider extracting this into a helper function for better readability.

-    let (pagination_ts, pagination_task_id) = token // token_id is the last returned task_id.
-        .as_ref()
-        .map(
-            |PaginateToken::V1(V1PaginateToken { created_at, id }): &PaginateToken<Uuid>| {
-                (created_at, id)
-            },
-        )
-        .map_or((None, None), |(ts, task_id)| (Some(ts), Some(task_id)));
+    let (pagination_ts, pagination_task_id) = match token.as_ref() {
+        Some(PaginateToken::V1(V1PaginateToken { created_at, id })) => {
+            (Some(created_at), Some(id))
+        }
+        None => (None, None),
+    };

146-245: Complex SQL query could benefit from CTEs optimization

The SQL query uses two CTEs (active_tasks and log_tasks) that are then combined with UNION ALL. Each CTE has its own LIMIT which then gets re-limited after the UNION. This approach may not be optimal for performance.

Consider using a single query with conditional filtering or rethinking the pagination strategy to avoid the double limiting.

The current approach:

  1. Fetches up to $2 rows from task table
  2. Fetches up to $2 rows from task_log table
  3. Combines them and limits again to $2

This could potentially fetch 2x the needed data. Consider either:

  • Using a single query with conditional JOINs
  • Implementing cursor-based pagination separately for active and completed tasks
  • Using a materialized view that combines both tables for listing purposes
crates/lakekeeper/src/service/task_queue/task_registry.rs (1)

156-164: Consider improving the warning message for clarity

The warning message uses backticks around the queue name which might not render well in all log outputs. Consider using quotes for better readability.

-            tracing::warn!("Overwriting registration for queue `{queue_name}`");
+            tracing::warn!("Overwriting registration for queue \"{queue_name}\"");
crates/lakekeeper/src/implementations/postgres/tasks.rs (3)

22-28: Consider making entity_id available in production builds

The InsertResult struct has entity_id only available in test builds with #[cfg(test)]. Given that this information could be useful for debugging and observability in production, consider making it always available.

 #[derive(Debug)]
 pub(crate) struct InsertResult {
     pub task_id: TaskId,
-    #[cfg(test)]
     pub entity_id: EntityId,
 }

147-154: Remove commented code

There's a commented line that should be removed for cleaner code.

             .map(|record| InsertResult {
                 task_id: record.task_id.into(),
-                // queue_name: record.queue_name,
                 #[cfg(test)]
                 entity_id: match record.entity_type {
                     EntityType::Tabular => EntityId::Tabular(record.entity_id),
                 },
             })

553-577: Consider validating task_ids array is not empty

The function accepts task_ids: &[TaskId] but doesn't check if it's empty before executing the query. While this won't cause an error, it's inefficient to execute a query that will never match any rows.

 pub(crate) async fn request_tasks_stop(
     transaction: &mut PgConnection,
     task_ids: &[TaskId],
 ) -> crate::api::Result<()> {
+    if task_ids.is_empty() {
+        return Ok(());
+    }
     sqlx::query!(
crates/lakekeeper/src/service/task_queue/mod.rs (3)

35-73: Make TaskQueueName static-friendly to match &'static return type

Returning &'static TaskQueueName from TaskConfig implies a static initializer, but TaskQueueName owns a String, which can’t be constructed in const/static contexts without indirection. Prefer Cow<'static, str> so queues can declare true statics without LazyLock workarounds.

Apply:

-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
-pub struct TaskQueueName(String);
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
+pub struct TaskQueueName(std::borrow::Cow<'static, str>);
@@
 impl Deref for TaskQueueName {
     type Target = str;
 
     fn deref(&self) -> &Self::Target {
-        &self.0
+        &self.0
     }
 }
@@
-impl<T: AsRef<str>> From<T> for TaskQueueName {
-    fn from(name: T) -> Self {
-        Self(name.as_ref().to_string())
-    }
-}
+impl<T: Into<std::borrow::Cow<'static, str>>> From<T> for TaskQueueName {
+    fn from(name: T) -> Self {
+        Self(name.into())
+    }
+}
@@
 impl std::fmt::Display for TaskQueueName {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(f, "{}", self.0)
+        write!(f, "{}", self.0)
     }
 }
@@
 impl TaskQueueName {
     #[must_use]
-    pub fn new(name: &str) -> Self {
-        Self(name.to_string())
-    }
+    pub fn new(name: &str) -> Self {
+        Self(std::borrow::Cow::Owned(name.to_string()))
+    }
+
+    #[must_use]
+    pub const fn from_static(name: &'static str) -> Self {
+        Self(std::borrow::Cow::Borrowed(name))
+    }
@@
     #[must_use]
     pub fn into_string(self) -> String {
-        self.0
+        self.0.into_owned()
     }
 }

Add import (outside hunk):

use std::borrow::Cow;

This lets implementers write: pub static QUEUE_NAME: TaskQueueName = TaskQueueName::from_static("tabular-expiration");


566-599: Recording status: add jittered exponential backoff

Fixed 1s waits can cause thundering herds under catalog errors. Prefer capped exponential backoff with jitter.

Example change:

- for attempt in 1..=5 {
+ for attempt in 1..=5 {
     ...
-    if attempt < 5 {
-        tokio::time::sleep(std::time::Duration::from_secs(1)).await;
-    } else {
+    if attempt < 5 {
+        let base = 1u64 << attempt.min(5); // 2..32
+        let jitter_ms = fastrand::u64(0..250);
+        tokio::time::sleep(std::time::Duration::from_millis(base * 100 + jitter_ms)).await;
+    } else {
         ...
     }
 }

Also applies to: 609-641


105-133: Optional: Add FromStr for TaskId to ease API parsing

Handy for CLIs/params.

Example (outside hunk):

impl std::str::FromStr for TaskId {
    type Err = uuid::Error;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Uuid::parse_str(s).map(TaskId)
    }
}
docs/docs/api/management-open-api.yaml (1)

3462-3465: Docs nit: use property name style consistently.

Change “next_page_token” to “next-page-token” to match the property name.

-            but set this to the `next_page_token` from the previous response.
+            but set this to the `next-page-token` from the previous response.
.sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json (1)

3-3: Handle NULL heartbeats and add deterministic pickup ordering.

  • If a task is Running/Should-Stop with NULL last_heartbeat_at, it won’t be re-picked. Consider treating NULL as stale.
  • Add ORDER BY to prefer earliest scheduled items (and stable selection under contention).

Suggested SQL changes within the query:

-            WHERE (t.queue_name = $1 AND scheduled_for < now()) 
-                AND (
-                    (status = $3) OR 
-                    (status != $3 AND (now() - last_heartbeat_at) > COALESCE(tc.max_time_since_last_heartbeat, $2))
-                )
+            WHERE (t.queue_name = $1 AND scheduled_for < now())
+              AND (
+                    status = $3
+                OR  (status != $3 AND (last_heartbeat_at IS NULL
+                     OR (now() - last_heartbeat_at) > COALESCE(tc.max_time_since_last_heartbeat, $2)))
+              )
             -- FOR UPDATE locks the row we select here, SKIP LOCKED makes us not wait for rows other
             -- transactions locked
-            FOR UPDATE OF t SKIP LOCKED
+            ORDER BY scheduled_for ASC, picked_up_at ASC NULLS FIRST, task_id ASC
+            FOR UPDATE OF t SKIP LOCKED
             LIMIT 1
crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (1)

32-34: Typed queue names adoption looks good; minor ergonomics optional.

  • Using &'static TaskQueueName across registry/WorkerInfo is consistent with the new type.
  • Optional: consider tokio::task::JoinSet to avoid rebuilding handle vectors and simplify restarts.

No action required.

Also applies to: 42-46, 91-127, 129-153

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23ae5a8 and 77ca4b4.

📒 Files selected for processing (20)
  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json (2 hunks)
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json (1 hunks)
  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json (1 hunks)
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json (1 hunks)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1 hunks)
  • crates/lakekeeper/src/api/management/mod.rs (12 hunks)
  • crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (1 hunks)
  • crates/lakekeeper/src/catalog/tables.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1 hunks)
  • crates/lakekeeper/src/service/mod.rs (1 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (24 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (12 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3 hunks)
  • crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (4 hunks)
  • crates/lakekeeper/src/service/task_queue/task_registry.rs (16 hunks)
  • crates/lakekeeper/src/tests/tasks.rs (6 hunks)
  • docs/docs/api/management-open-api.yaml (16 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/lakekeeper/src/service/mod.rs
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
  • crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
  • crates/lakekeeper/src/api/management/mod.rs
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs
  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json
  • crates/lakekeeper/src/implementations/postgres/tasks.rs
📚 Learning: 2025-08-31T11:58:20.853Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json:3-3
Timestamp: 2025-08-31T11:58:20.853Z
Learning: In .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json, the UPDATE statement that sets progress = 0.0, picked_up_at = NULL, and execution_details = NULL is correct because this code branch only executes when max_retries_exceeded is true, and the intention is to reset the task state to make it available for pickup again in the retry mechanism.

Applied to files:

  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json
  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
📚 Learning: 2025-08-31T11:28:55.713Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json:4-22
Timestamp: 2025-08-31T11:28:55.713Z
Learning: The task_final_status PostgreSQL enum and the primary key constraint on task_log(task_id, attempt) were both established in migration 20250523101407_tasks_store_their_state.sql, not missing from the schema.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
📚 Learning: 2025-08-31T11:28:55.713Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json:4-22
Timestamp: 2025-08-31T11:28:55.713Z
Learning: The task_final_status PostgreSQL enum was defined in a previous migration, not missing from the schema as initially flagged.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
📚 Learning: 2025-08-31T12:39:49.414Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json:3-3
Timestamp: 2025-08-31T12:39:49.414Z
Learning: The unique index on task(warehouse_id, entity_type, entity_id, queue_name) exists as 'task_warehouse_id_entity_type_entity_id_queue_name_idx' and was created in migration 20250523101407_tasks_store_their_state.sql, supporting ON CONFLICT operations on these columns.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
📚 Learning: 2025-08-31T12:39:49.414Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json:3-3
Timestamp: 2025-08-31T12:39:49.414Z
Learning: The unique constraint on task(warehouse_id, entity_type, entity_id, queue_name) exists as 'task_warehouse_entity_queue_unique' and was created in migration 20250523101407_tasks_store_their_state.sql, supporting ON CONFLICT operations on these columns.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
📚 Learning: 2025-08-31T12:47:22.894Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-d1e9859dcc600e55628e413e2e98eb658d1d08ad10b91beb8ca168c8e17045f8.json:169-172
Timestamp: 2025-08-31T12:47:22.894Z
Learning: In the Lakekeeper task system, the `task` table uses `created_at` for the task creation timestamp, while `task_log` uses a dedicated `task_created_at` column that preserves the original creation time when tasks are moved from the active table to the historical log. Pagination queries correctly use `created_at` for active tasks and `task_created_at` for logged tasks.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks.rs
🧬 Code graph analysis (8)
crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (1)
crates/lakekeeper/src/api/iceberg/mod.rs (1)
  • with_capacity (111-117)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (5)
crates/lakekeeper/src/service/task_queue/mod.rs (21)
  • tasks (371-388)
  • from (47-49)
  • from (115-117)
  • from (121-123)
  • id (259-261)
  • id (321-323)
  • task_id (249-251)
  • task_id (311-313)
  • into_string (70-72)
  • record_failure (563-600)
  • record_success (606-642)
  • queue_name (97-97)
  • queue_name (306-308)
  • task (436-436)
  • task (448-448)
  • as_str (65-67)
  • attempt (254-256)
  • attempt (316-318)
  • to_uuid (184-188)
  • new (60-62)
  • cancel_scheduled_tasks (399-417)
crates/lakekeeper/src/implementations/postgres/tasks.rs (7)
  • from (36-40)
  • pick_task (162-256)
  • record_failure (332-472)
  • record_success (258-329)
  • setup_warehouse (857-870)
  • queue_task_batch (44-158)
  • cancel_scheduled_tasks (621-759)
crates/lakekeeper/src/api/management/v1/tasks.rs (4)
  • split (139-148)
  • list_tasks (239-295)
  • entities (380-391)
  • entities (392-408)
crates/lakekeeper/src/implementations/postgres/mod.rs (1)
  • transaction (111-113)
crates/lakekeeper/src/implementations/postgres/pagination.rs (4)
  • try_from (44-46)
  • try_from (55-57)
  • try_from (67-109)
  • s (87-87)
crates/lakekeeper/src/implementations/postgres/tasks.rs (7)
crates/lakekeeper/src/api/management/v1/warehouse/mod.rs (3)
  • catalog (863-863)
  • get_task_queue_config (1011-1038)
  • set_task_queue_config (959-1009)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/catalog.rs (8)
  • get_task_details (953-960)
  • list_tasks (970-976)
  • resolve_tasks (852-889)
  • get_task_queue_config (1049-1053)
  • transaction (84-84)
  • set_task_queue_config (1042-1047)
  • check_and_heartbeat_task (1016-1023)
  • cancel_scheduled_tasks (1008-1013)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (93-270)
  • tasks (250-253)
  • status (77-80)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)
  • resolve_tasks (18-103)
crates/lakekeeper/src/service/task_queue/mod.rs (20)
  • from (47-49)
  • from (115-117)
  • from (121-123)
  • Self (439-439)
  • Self (451-451)
  • queue_name (97-97)
  • queue_name (306-308)
  • tasks (371-388)
  • max_time_since_last_heartbeat (90-90)
  • task (436-436)
  • task (448-448)
  • id (259-261)
  • id (321-323)
  • task_id (249-251)
  • task_id (311-313)
  • attempt (254-256)
  • attempt (316-318)
  • as_str (65-67)
  • cancel_scheduled_tasks (399-417)
  • queue_config (284-301)
crates/lakekeeper/src/implementations/postgres/catalog.rs (3)
  • get_task_queue_config (800-806)
  • set_task_queue_config (791-798)
  • cancel_scheduled_tasks (766-773)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (2)
crates/lakekeeper/src/service/task_queue/mod.rs (16)
  • new (60-62)
  • Self (439-439)
  • Self (451-451)
  • queue_name (97-97)
  • queue_name (306-308)
  • max_time_since_last_heartbeat (90-90)
  • task (436-436)
  • task (448-448)
  • poll_for_new_task (476-521)
  • attempt (254-256)
  • attempt (316-318)
  • task_id (249-251)
  • task_id (311-313)
  • id (259-261)
  • id (321-323)
  • schedule_task (332-356)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (5)
  • new (34-39)
  • queue_name (48-50)
  • max_time_since_last_heartbeat (52-54)
  • task (107-107)
  • task (115-115)
crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (5)
crates/lakekeeper/src/service/task_queue/mod.rs (2)
  • queue_name (97-97)
  • queue_name (306-308)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)
  • queue_name (48-50)
crates/lakekeeper/src/service/task_queue/task_registry.rs (2)
  • queue_name (330-332)
  • queue_name (346-348)
crates/lakekeeper/src/tests/tasks.rs (1)
  • queue_name (52-54)
crates/lakekeeper/src/service/task_queue/task_registry.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • queue_name (97-97)
  • queue_name (306-308)
  • Self (439-439)
  • Self (451-451)
  • new (60-62)
  • max_time_since_last_heartbeat (90-90)
  • from (47-49)
  • from (115-117)
  • from (121-123)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (4)
  • queue_name (68-70)
  • tabular_purge_queue (224-224)
  • new (48-53)
  • max_time_since_last_heartbeat (72-74)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3)
  • queue_name (48-50)
  • new (34-39)
  • max_time_since_last_heartbeat (52-54)
crates/lakekeeper/src/tests/tasks.rs (2)
  • queue_name (52-54)
  • max_time_since_last_heartbeat (56-58)
crates/lakekeeper/src/service/task_queue/mod.rs (4)
crates/lakekeeper/src/implementations/postgres/tasks.rs (1)
  • check_and_heartbeat_task (579-611)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (4)
  • max_time_since_last_heartbeat (72-74)
  • queue_name (68-70)
  • task (132-132)
  • task (245-245)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)
  • max_time_since_last_heartbeat (52-54)
  • queue_name (48-50)
  • task (107-107)
  • task (115-115)
crates/lakekeeper/src/service/catalog.rs (5)
  • transaction (84-84)
  • check_and_heartbeat_task (1016-1023)
  • begin_write (76-76)
  • record_task_failure (933-940)
  • record_task_success (918-924)
crates/lakekeeper/src/tests/tasks.rs (5)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • new (60-62)
  • queue_name (97-97)
  • queue_name (306-308)
  • max_time_since_last_heartbeat (90-90)
  • task_id (249-251)
  • task_id (311-313)
  • task (436-436)
  • task (448-448)
  • pick_new_task (424-472)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (5)
  • new (48-53)
  • queue_name (68-70)
  • max_time_since_last_heartbeat (72-74)
  • task (132-132)
  • task (245-245)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (5)
  • new (34-39)
  • queue_name (48-50)
  • max_time_since_last_heartbeat (52-54)
  • task (107-107)
  • task (115-115)
crates/lakekeeper/src/service/task_queue/task_registry.rs (5)
  • new (133-138)
  • queue_name (330-332)
  • queue_name (346-348)
  • max_time_since_last_heartbeat (334-336)
  • max_time_since_last_heartbeat (350-352)
crates/lakekeeper/src/service/catalog.rs (1)
  • pick_new_task (832-838)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: clippy
  • GitHub Check: sqlx-check
🔇 Additional comments (28)
crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (2)

36-36: LGTM: prealloc is a nice micro-win

Using Vec::with_capacity(tabs.len()) avoids reallocations; behavior unchanged.


12-29: Validate non-empty targets list

No explicit check exists for an empty request.targets in require_undrop_permissions, so an empty list bypasses the permission guard. If that’s unintended, add validation to reject empty requests; otherwise confirm that allowing a no-op is acceptable.

.sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json (1)

3-3: Overall flow (lock → log → update) is solid and idempotent.

The FOR UPDATE on the (task_id, attempt) pair, logging with ON CONFLICT (task_id, attempt) DO NOTHING, and then updating the same locked row is correct and should be race-safe. The split between task_log.status (final) and task.status (intermediate) matches the schema/migration setup you’ve established earlier.

.sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json (3)

3-3: Guard against unintended mass-deletes when bypass flags are true.

If $5 or $6 default to true upstream, this will delete by id regardless of queue/status. Confirm callers always set them deliberately and never pass NULL/unspecified.

Would you like a repo-wide scan script to locate all call sites and verify argument ordering/defaults?


3-3: Confirm task_log nullability for started_at and duration.

For scheduled-but-never-picked tasks, started_at and duration are NULL. Ensure task_log.started_at and task_log.duration are nullable to prevent runtime failures.

If nullable constraints differ, I can suggest a compatible mapping (e.g., derive finished_at = now(), started_at = COALESCE(picked_up_at, created_at)).


7-36: Types and constraints align with migrations. LGTM.

Parameter enums and the (task_id, attempt) key match the established schema and PK per migration 20250523101407_tasks_store_their_state.sql.

.sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json (3)

3-3: Verify semantics for deleting RUNNING tasks.

The query allows passing $3 = 'running', which will hard-delete active tasks and log them as a final status $4. Ensure this is only used for admin “kill” flows and that workers tolerate the row disappearing mid-run.

If unintended, gate with an additional param (e.g., $7 allow_running) or restrict $3 to non-running values at the callsite.


3-3: FK/parent integrity check.

You insert parent_task_id into task_log while deleting from task. If task.parent_task_id has FKs or if children reference parents in task, confirm ON DELETE behavior won’t break invariants when bulk-deleting.


3-3: Verify bulk-delete guard for this query
The DELETE’s WHERE clause uses bypass booleans (status = $3 OR $5 and queue_name = $2 OR $6), which bypass intended filters, defeat indexes, and risk unintended mass deletions. Ensure $5 and $6 default to false and are only enabled via an explicit “confirm_bulk” guard in privileged paths—or split into strict-filter vs. bulk-delete query variants. I wasn’t able to locate any callsites for this query; please manually audit its usages.

crates/lakekeeper/src/service/task_queue/task_registry.rs (1)

73-76: LGTM! Clean implementation of sorted queue names

The implementation correctly returns sorted queue names and documents this behavior in the comment.

crates/lakekeeper/src/tests/tasks.rs (1)

49-50: LGTM! Clean static initialization with LazyLock

The use of LazyLock for the static QUEUE_NAME is appropriate and follows Rust best practices for lazy static initialization.

crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)

256-441: Comprehensive test coverage for expiration queue workflow

The test thoroughly covers the expiration queue workflow including task scheduling, deletion, and cleanup. Good use of polling with timeout to avoid infinite loops.

crates/lakekeeper/src/implementations/postgres/tasks.rs (3)

187-191: Good implementation of the reconciliation mechanism

The WHERE clause correctly handles both scheduled tasks and stale Running/ShouldStop tasks. This is essential for fault tolerance when workers crash or are killed.


264-329: Well-structured success recording with comprehensive field capture

The implementation properly captures all necessary fields including progress, execution details, and timing information when recording task success. The use of CTE with DELETE ... RETURNING ensures atomicity.


579-611: Atomic heartbeat with progress and execution details update

Excellent implementation of atomic heartbeat update that simultaneously updates the heartbeat timestamp, progress, and execution details. This ensures consistency and reduces database round-trips.

crates/lakekeeper/src/service/task_queue/mod.rs (8)

134-151: Typed TaskAttemptId and Display formatting — solid

Clearer logging identifiers; AsRef interop is ergonomic.


202-206: AsRef impls — ergonomic and correct

Makes catalog calls and generics cleaner.

Also applies to: 219-225


235-245: TaskCheckState semantics are reasonable

Treating NotActive as terminate but not report keeps idempotency/noise low.


263-302: Error messages improved with queue/id context

Useful diagnostics on (de)serialization failures.


425-473: pick_new_task error path is robust

On deserialization failure, recording a task failure and skipping the task prevents stuck queues.


793-815: Derives for TaskStatus/TaskOutcome are appropriate

Hash/Eq/EnumIter will help API/UI layers and metrics.


834-856: Serde round-trip test for TaskEntity — nice coverage

Confirms kebab-case field naming and type tagging.


97-98: Drop this suggestion: &QUEUE_NAME already coerces to &TaskQueueName via Deref coercion.

Likely an incorrect or invalid review comment.

docs/docs/api/management-open-api.yaml (4)

1174-1177: LGTM: page-size made nullable integer.

Consistent with other list endpoints.

Also applies to: 1390-1392, 1752-1755


5238-5254: LGTM: WarehouseFilter ‘all’ vs ‘unmapped’ variants clarified.

Descriptions and enums look coherent.


5335-5336: LGTM: added tasks tag.

Clear categorization.


2395-2405: No critical issues found in parameter naming conventions; most existing query parameters use kebab-case. Deprecation is optional.

Resolve by choosing one of:

  • Break change: rename numAttempts → num-attempts.
  • Non-breaking: mark numAttempts deprecated and add new num-attempts alias.
crates/lakekeeper/src/catalog/tables.rs (1)

1005-1015: Authorization-to-permissions mapping looks correct and simpler.

can_write → ReadWriteDelete, else can_read → Read, else None is appropriate and preserves prior semantics.

Comment thread docs/docs/api/management-open-api.yaml Resolved
Comment thread docs/docs/api/management-open-api.yaml Resolved
Comment thread docs/docs/api/management-open-api.yaml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
crates/lakekeeper/src/api/management/mod.rs (1)

1469-1498: Update OpenAPI annotation for set_task_queue_config

  • Change the doc comment to /// Set the configuration for a Task Queue.
  • Add request_body = SetTaskQueueConfigRequest, to the utoipa::path macro above responses
docs/docs/api/management-open-api.yaml (1)

2247-2369: Queue-config endpoints: fix summaries and stray queue_name param

  • POST summaries should say “Set…”, not “Get…”.
  • GET for tabular_expiration includes a queue_name path parameter that does not exist in the path; remove it.

Apply:

   /management/v1/{warehouse_id}/task-queue/tabular_expiration/config:
     get:
       tags:
-        - tasks
-      summary: Get the configuration for a Task Queue.
+        - tasks
+      summary: Get the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.
@@
-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string
@@
     post:
       tags:
-        - tasks
-      summary: Get the configuration for a Task Queue.
+        - tasks
+      summary: Set the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.
@@
   /management/v1/{warehouse_id}/task-queue/tabular_purge/config:
     get:
       tags:
-        - tasks
-      summary: Get the configuration for a Task Queue.
+        - tasks
+      summary: Get the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.
@@
     post:
       tags:
-        - tasks
-      summary: Get the configuration for a Task Queue.
+        - tasks
+      summary: Set the configuration for a Task Queue.
       description: These configurations are global per warehouse and shared across all instances of this kind of task.
♻️ Duplicate comments (3)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)

69-74: Add periodic heartbeats during long purges to avoid re-pick (tracked in #1321).

As noted earlier, without heartbeats a long-running purge can be re-picked once it exceeds max_time_since_last_heartbeat, causing duplicate I/O. Add a cancellable heartbeat loop during purge (30–60s) that calls the catalog/task heartbeat API and stops on completion/cancellation. This also enables timely honor of ShouldStop.

@@
-        instrumented_purge::<_, C>(catalog_state.clone(), &secret_state, &task)
+        instrumented_purge::<_, C>(
+            catalog_state.clone(),
+            &secret_state,
+            &task,
+            cancellation_token.clone(),
+        )
             .instrument(span.or_current())
             .await;
-async fn instrumented_purge<S: SecretStore, C: Catalog>(
+async fn instrumented_purge<S: SecretStore, C: Catalog>(
     catalog_state: C::State,
     secret_state: &S,
     task: &TabularPurgeTask,
+    worker_cancel: crate::CancellationToken,
 ) {
-    match purge::<C, S>(task, secret_state, catalog_state.clone()).await {
+    // Start background heartbeat
+    let hb_cancel = crate::CancellationToken::new();
+    let hb_handle = tokio::spawn({
+        let catalog_state = catalog_state.clone();
+        let period = Duration::from_secs(30);
+        let hb_cancel = hb_cancel.clone();
+        let task_id = task.task_id();
+        let attempt = task.attempt();
+        async move {
+            loop {
+                tokio::select! {
+                    () = hb_cancel.cancelled() => break,
+                    () = worker_cancel.cancelled() => break,
+                    () = tokio::time::sleep(period) => {
+                        // NOTE: adjust to your actual API (e.g., task.check_and_heartbeat_task::<C>(...))
+                        if let Err(e) = C::check_and_heartbeat_task(catalog_state.clone(), task_id, attempt).await {
+                            tracing::warn!("Heartbeat failed for `{QN_STR}` task_id={task_id} attempt={attempt}: {e}");
+                        }
+                    }
+                }
+            }
+        }
+    });
+
+    let res = purge::<C, S>(task, secret_state, catalog_state.clone()).await;
+
+    hb_cancel.cancel();
+    let _ = hb_handle.await;
+
+    match res {
         Ok(()) => {
             tracing::info!(
                 "Task of `{QN_STR}` worker exited successfully. Data at location `{}` deleted.",
                 task.data.tabular_location
             );
             task.record_success::<C>(catalog_state, Some("Purged tabular data"))
                 .await;
         }
         Err(err) => {
             tracing::error!(
                 "Error in `{QN_STR}` worker. Failed to purge location {}. {err}",
                 task.data.tabular_location,
             );
             task.record_failure::<C>(
                 catalog_state,
                 &format!(
                     "Failed to purge tabular at location `{}`.\n{err}",
                     task.data.tabular_location
                 ),
             )
             .await;
         }
     };
 }

Verify availability/names of the heartbeat API with:

#!/bin/bash
set -euo pipefail
rg -nP '(check_and_heartbeat|record_heartbeat).*Task' -g 'crates/**/*.rs' -C2

Also applies to: 77-77

crates/lakekeeper/src/api/management/mod.rs (2)

1528-1547: ListTasks OpenAPI: request_body added—thanks

Now documents Json correctly.


1572-1595: ControlTasks OpenAPI: request_body added—good

Docs now match Json and 204 response.

🧹 Nitpick comments (26)
.sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json (5)

3-3: Consider insert-first-then-delete to avoid edge-case loss if log already contains the row.

With DELETE ... RETURNING followed by INSERT ... ON CONFLICT DO NOTHING, a conflict means the INSERT is skipped but the task row is already deleted. If this is intentional cleanup, fine; otherwise switch to an insert-first pattern and only delete rows that were inserted:

-WITH deleted AS (
-  DELETE FROM task
-  WHERE (status = $3 OR $6) AND task_id = ANY($1) AND (queue_name = $4 OR $5)
-  RETURNING *
-)
-INSERT INTO task_log(...)
-SELECT ... FROM deleted
-ON CONFLICT (task_id, attempt) DO NOTHING;
+WITH to_insert AS (
+  SELECT *
+  FROM task
+  WHERE ($6 OR status = $3)
+    AND task_id = ANY($1)
+    AND ($5 OR queue_name = $4)
+  FOR UPDATE SKIP LOCKED
+), ins AS (
+  INSERT INTO task_log(...)
+  SELECT ... FROM to_insert
+  ON CONFLICT (task_id, attempt) DO NOTHING
+  RETURNING task_id, attempt
+)
+DELETE FROM task t
+USING ins
+WHERE t.task_id = ins.task_id AND t.attempt = ins.attempt;

3-3: Use clock_timestamp() for accurate duration.

now() is fixed at transaction start; if the transaction is long-lived, duration will be under-reported. Prefer clock_timestamp() (or statement_timestamp() if you want statement start).

-then now() - picked_up_at
+then clock_timestamp() - picked_up_at

3-3: Improve predicate clarity (and planner friendliness).

The bypass booleans are correct but invert the ORs for readability and potential planning: ($6 OR status = $3) and ($5 OR queue_name = $4). Even better: generate two query variants in code when bypass flags are true to let PostgreSQL pick tighter index plans.


3-3: Optional: update-on-conflict to refresh details.

If repeated archiving of the same (task_id, attempt) should update execution_details/duration, use DO UPDATE with IS DISTINCT FROM guards:

-ON CONFLICT (task_id, attempt) DO NOTHING
+ON CONFLICT (task_id, attempt) DO UPDATE
+SET duration = EXCLUDED.duration,
+    execution_details = CASE
+      WHEN task_log.execution_details IS DISTINCT FROM EXCLUDED.execution_details
+      THEN EXCLUDED.execution_details
+      ELSE task_log.execution_details
+    END

3-3: Minor: avoid RETURNING * in the DELETE CTE.

Return only the columns you actually need to reduce tuple materialization and future coupling.

crates/lakekeeper/src/catalog/tables.rs (1)

1008-1014: Confirm write⇒read+delete policy; consider a concise idiom.

  • Please confirm the security policy that a principal with CanWriteData should receive storage creds with delete and read (RWD). If “write-only” without read/delete is ever a valid state in your authz model, this mapping would over-grant.
  • Minor style: you can express this more idiomatically.

Apply:

-        let storage_permissions = if can_write {
-            Some(StoragePermissions::ReadWriteDelete)
-        } else if can_read {
-            Some(StoragePermissions::Read)
-        } else {
-            None
-        };
+        let storage_permissions = can_write
+            .then_some(StoragePermissions::ReadWriteDelete)
+            .or_else(|| can_read.then_some(StoragePermissions::Read));
crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (1)

42-42: Avoid accidental &&TaskQueueName in the spawn loop

registered_queues.iter() yields (&&TaskQueueName, &QueueWorkerConfig). To keep types crisp when populating WorkerInfo.queue_name: &'static TaskQueueName, destructure by value or deref:

// Option 1 (preferred)
for (&queue_name, queue) in registered_queues.iter() { /* ... */ }

// Option 2
workers.push(WorkerInfo {
    queue_name: *queue_name,
    // ...
});
crates/lakekeeper/src/tests/tasks.rs (2)

70-72: Avoid std::sync::Mutex in async context; make test non‑flaky

  • Use AtomicBool (or tokio::sync::Mutex) instead of std::sync::Mutex inside async code.
  • Replace fixed sleep with a timeout loop waiting for the completion flag to flip, then cancel.

Apply:

-    use std::sync::{Arc, LazyLock, Mutex};
+    use std::sync::{Arc, LazyLock};
+    use std::sync::atomic::{AtomicBool, Ordering};
@@
-        let result = Arc::new(Mutex::new(false));
-        let result_clone = result.clone();
+        let result = Arc::new(AtomicBool::new(false));
+        let result_clone = Arc::clone(&result);
@@
-                        *result_clone.lock().unwrap() = true;
+                        result_clone.store(true, Ordering::Relaxed);
@@
-        tokio::time::sleep(std::time::Duration::from_secs(2)).await;
+        // Wait up to 10s for the worker to set the flag
+        let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10);
+        while !result.load(Ordering::Relaxed) && std::time::Instant::now() < deadline {
+            tokio::time::sleep(std::time::Duration::from_millis(20)).await;
+        }
         cancellation_token.cancel();
         task_handle.await.unwrap();
         assert!(
-            *result.lock().unwrap(),
+            result.load(Ordering::Relaxed),
             "Task was not processed as expected"
         );

Also applies to: 97-161


84-91: Avoid cloning config in test

No need to allocate here; borrow the config.

-                        let config = task.config.clone().unwrap();
+                        let config = task.config.as_ref().unwrap();
                         assert_eq!(config.some_val, "test_value");
crates/lakekeeper/src/service/task_queue/task_registry.rs (5)

156-165: Format with Debug to avoid requiring Display

If TaskQueueName doesn’t implement Display, this will fail. Prefer {:?} here, or implement Display for TaskQueueName.

-            tracing::warn!("Overwriting registration for queue `{queue_name}`");
+            tracing::warn!("Overwriting registration for queue `{queue_name:?}`");

250-277: Log when a queue has no worker

If a queue is registered without a worker, silently skipping can hide config issues. Emit a warning.

-        for name in queues.keys() {
-            if let Some(worker) = workers.get(name) {
+        for name in queues.keys() {
+            if let Some(worker) = workers.get(name) {
                 registered_task_queues.insert(
                     *name,
                     QueueWorkerConfig {
                         worker_fn: Arc::clone(&worker.worker_fn),
                         num_workers: worker.num_workers,
                     },
                 );
-            }
+            } else {
+                tracing::warn!("No worker registered for queue `{name:?}`; skipping.");
+            }
         }

305-323: Confirm MSRV for std::sync::LazyLock in tests

Same MSRV consideration as the other file; keep tests compatible with CI toolchain.

(See the earlier script; reuse here.)


451-469: Add direct assertion for queue_names()

Since RegisteredTaskQueues::queue_names returns sorted names, assert it directly in this test for completeness.

         later_queue_names.sort_unstable();
 
         assert_eq!(
             initial_queue_names,
             vec![&*SECOND_QUEUE_NAME, &*FIRST_QUEUE_NAME]
         );
         assert_eq!(
             later_queue_names,
             vec![&*SECOND_QUEUE_NAME, &*FIRST_QUEUE_NAME]
         );
+
+        // Also verify the dedicated queue_names() helper
+        let names = registry.registered_task_queues().queue_names().await;
+        assert_eq!(names, vec![&*SECOND_QUEUE_NAME, &*FIRST_QUEUE_NAME]);

70-77: queue_names: TaskQueueName already derives Ord; add a unit test for sorted output

TaskQueueName implements Ord via #[derive(..., PartialOrd, Ord)], so no custom comparator is needed. Add a unit test for queue_names to verify it returns names in sorted order.

crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3)

47-55: Heartbeat window: express as hours and consider config-driven value.

Readability nit: use hours(1). Longer-term, prefer a config value so ops can tune reconciliation vs. false re-pick risk.

-    fn max_time_since_last_heartbeat() -> chrono::Duration {
-        chrono::Duration::seconds(3600)
-    }
+    fn max_time_since_last_heartbeat() -> chrono::Duration {
+        chrono::Duration::hours(1)
+    }

57-61: Expose execution details in OpenAPI.

If TaskExecutionDetails surfaces in your management APIs, derive ToSchema (and Default) so it serializes in docs consistently with other queues.

-#[derive(Debug, Clone, Deserialize, Serialize)]
+#[derive(Debug, Clone, Deserialize, Serialize, Default, ToSchema)]
 pub struct TabularPurgeExecutionDetails {}

154-189: Safety guard: prevent accidental high-scope deletes.

Before remove_all, consider asserting the purge target is within an expected prefix (e.g., within the warehouse’s intended table path) to avoid a misconfigured task deleting bucket/container roots.

Example guard (adapt to your types):

let allowed_prefix = warehouse.storage_profile.base_location(); // or derive from table metadata
if !tabular_location.as_ref().starts_with(allowed_prefix.as_ref()) {
    return Err(ErrorModel::bad_request(
        format!("Refusing to purge `{tabular_location}` outside allowed prefix `{allowed_prefix}`."),
        "UnsafePurge",
        None,
    ).into());
}
.sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json (2)

3-3: Guard duration when picked_up_at is NULL (minor)

If a task is failed before pickup, now() - picked_up_at yields NULL. Being explicit improves clarity and avoids accidental implicit casts down the line.

Apply:

-                    now() - picked_up_at,
+                    CASE WHEN picked_up_at IS NOT NULL THEN now() - picked_up_at ELSE NULL END,

3-3: Optional: clear last_heartbeat_at when rescheduling after failure

Resetting the row to Scheduled while keeping last_heartbeat_at can be confusing for observability. Consider nulling it.

 UPDATE task t
 SET 
     status = $3, 
     progress = 0.0,
     picked_up_at = NULL,
-    execution_details = NULL
+    execution_details = NULL,
+    last_heartbeat_at = NULL
.sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json (2)

3-3: Make task picking deterministic and fair

Without ORDER BY, the picked row is arbitrary. Ordering by earliest schedule time (then task_id) improves fairness and predictability.

-            FOR UPDATE OF t SKIP LOCKED
+            ORDER BY t.scheduled_for ASC, t.task_id ASC
+            FOR UPDATE OF t SKIP LOCKED

3-3: Handle NULL heartbeats for non-scheduled states (edge case)

If a Running/ShouldStop row has NULL last_heartbeat_at (rare but possible), it can never be re-picked by the heartbeat clause. Consider coalescing.

-                    (status != $3 AND (now() - last_heartbeat_at) > COALESCE(tc.max_time_since_last_heartbeat, $2))
+                    (status != $3 AND (now() - COALESCE(last_heartbeat_at, picked_up_at, 'epoch'::timestamptz)) > COALESCE(tc.max_time_since_last_heartbeat, $2))
.sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json (1)

3-3: Clarify boolean short-circuit filters (readability)

(status = $3 OR $5) and (queue_name = $2 OR $6) are correct but a bit opaque. Reordering helps readability without changing semantics.

-WHERE (status = $3 OR $5) AND warehouse_id = $1 AND (queue_name = $2 OR $6)
+WHERE ($5 OR status = $3) AND warehouse_id = $1 AND ($6 OR queue_name = $2)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1)

27-29: Warehouse filter: avoid sentinel UUID (style)

Using a boolean short-circuit is fine; passing Uuid::nil() as a sentinel is unnecessary. Consider a nullable parameter in SQL instead.

Example SQL tweak:

... WHERE task_id = ANY($1) AND ($2::uuid IS NULL OR warehouse_id = $2)

And pass Option<Uuid> directly.

crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (2)

128-131: Avoid passing Vec<&Enum>; pass values (copy) to SQL

Collecting references is slightly awkward for SQLx array params. Use .copied() to build Vec<TaskStatus>/Vec<TaskOutcome>.

-        task_status_filter.iter().collect_vec() as Vec<_>,
-        task_log_status_filter.iter().collect_vec() as Vec<_>,
+        task_status_filter.iter().copied().collect_vec(),
+        task_log_status_filter.iter().copied().collect_vec(),

22-39: Minor consistency nit: use Uuid import uniformly

entity_id: uuid::Uuid can be Uuid since it’s already imported.

-    entity_id: uuid::Uuid,
+    entity_id: Uuid,
docs/docs/api/management-open-api.yaml (1)

3428-3479: ListTasksRequest: pluralize queue-name description

Accepts multiple queues; adjust wording.

         queue-name:
           type:
             - array
             - 'null'
           items:
             type: string
-          description: Filter by queue name
+          description: Filter by one or more queue names
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23ae5a8 and 428769b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (21)
  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json (2 hunks)
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json (1 hunks)
  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json (1 hunks)
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json (1 hunks)
  • crates/io/Cargo.toml (0 hunks)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql (1 hunks)
  • crates/lakekeeper/src/api/management/mod.rs (12 hunks)
  • crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs (1 hunks)
  • crates/lakekeeper/src/catalog/tables.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (1 hunks)
  • crates/lakekeeper/src/service/mod.rs (1 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (24 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (12 hunks)
  • crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (3 hunks)
  • crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (4 hunks)
  • crates/lakekeeper/src/service/task_queue/task_registry.rs (16 hunks)
  • crates/lakekeeper/src/tests/tasks.rs (6 hunks)
  • docs/docs/api/management-open-api.yaml (16 hunks)
💤 Files with no reviewable changes (1)
  • crates/io/Cargo.toml
✅ Files skipped from review due to trivial changes (1)
  • crates/lakekeeper/src/api/management/v1/warehouse/undrop.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql
  • crates/lakekeeper/src/service/mod.rs
  • crates/lakekeeper/src/service/task_queue/mod.rs
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
  • crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs
  • crates/lakekeeper/src/implementations/postgres/tasks.rs
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-08-31T11:28:55.713Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json:4-22
Timestamp: 2025-08-31T11:28:55.713Z
Learning: The task_final_status PostgreSQL enum and the primary key constraint on task_log(task_id, attempt) were both established in migration 20250523101407_tasks_store_their_state.sql, not missing from the schema.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json
📚 Learning: 2025-08-31T11:58:20.853Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json:3-3
Timestamp: 2025-08-31T11:58:20.853Z
Learning: In .sqlx/query-755974eeec0224a16075e26d11f8d81d667eaa293e72ba1ccdec9050eb74e778.json, the UPDATE statement that sets progress = 0.0, picked_up_at = NULL, and execution_details = NULL is correct because this code branch only executes when max_retries_exceeded is true, and the intention is to reset the task state to make it available for pickup again in the retry mechanism.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json
📚 Learning: 2025-08-31T12:39:49.414Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json:3-3
Timestamp: 2025-08-31T12:39:49.414Z
Learning: The unique index on task(warehouse_id, entity_type, entity_id, queue_name) exists as 'task_warehouse_id_entity_type_entity_id_queue_name_idx' and was created in migration 20250523101407_tasks_store_their_state.sql, supporting ON CONFLICT operations on these columns.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
📚 Learning: 2025-08-31T12:39:49.414Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-98ca1801d4e1cf55ce25e7da1de6d4a49d6b32d58bbe53a9ba6ff5284ced6460.json:3-3
Timestamp: 2025-08-31T12:39:49.414Z
Learning: The unique constraint on task(warehouse_id, entity_type, entity_id, queue_name) exists as 'task_warehouse_entity_queue_unique' and was created in migration 20250523101407_tasks_store_their_state.sql, supporting ON CONFLICT operations on these columns.

Applied to files:

  • .sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json
  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
  • .sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json
📚 Learning: 2025-08-31T11:28:55.713Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: .sqlx/query-0aeb5d6e3f65746cefe75e374c69780174a7474580da84345cb777e2343d0280.json:4-22
Timestamp: 2025-08-31T11:28:55.713Z
Learning: The task_final_status PostgreSQL enum was defined in a previous migration, not missing from the schema as initially flagged.

Applied to files:

  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
📚 Learning: 2025-08-30T10:23:41.114Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

Applied to files:

  • .sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • .sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json
  • crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs
🧬 Code graph analysis (7)
crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (3)
crates/lakekeeper/src/service/catalog.rs (2)
  • resolve_tasks (852-889)
  • transaction (84-84)
crates/lakekeeper/src/service/task_queue/mod.rs (16)
  • new (60-62)
  • id (259-261)
  • id (321-323)
  • task_id (249-251)
  • task_id (311-313)
  • from (47-49)
  • from (115-117)
  • from (121-123)
  • queue_name (97-97)
  • queue_name (306-308)
  • tasks (371-388)
  • record_failure (563-600)
  • record_success (606-642)
  • to_uuid (184-188)
  • task (436-436)
  • task (448-448)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
  • from (36-40)
  • pick_task (162-256)
  • record_failure (332-472)
  • record_success (258-329)
  • queue_task_batch (44-158)
  • task_metadata (1403-1410)
crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (5)
crates/lakekeeper/src/service/task_queue/mod.rs (2)
  • queue_name (97-97)
  • queue_name (306-308)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)
  • queue_name (48-50)
crates/lakekeeper/src/service/task_queue/task_registry.rs (2)
  • queue_name (330-332)
  • queue_name (346-348)
crates/lakekeeper/src/tests/tasks.rs (1)
  • queue_name (52-54)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (5)
crates/lakekeeper/src/service/task_queue/mod.rs (20)
  • tasks (371-388)
  • from (47-49)
  • from (115-117)
  • from (121-123)
  • id (259-261)
  • id (321-323)
  • task_id (249-251)
  • task_id (311-313)
  • into_string (70-72)
  • record_failure (563-600)
  • record_success (606-642)
  • queue_name (97-97)
  • queue_name (306-308)
  • task (436-436)
  • task (448-448)
  • as_str (65-67)
  • attempt (254-256)
  • attempt (316-318)
  • to_uuid (184-188)
  • cancel_scheduled_tasks (399-417)
crates/lakekeeper/src/config.rs (6)
  • None (749-749)
  • from (569-578)
  • default (388-390)
  • default (435-437)
  • default (458-526)
  • s (324-324)
crates/lakekeeper/src/implementations/postgres/tasks.rs (7)
  • from (36-40)
  • pick_task (162-256)
  • record_failure (332-472)
  • record_success (258-329)
  • setup_warehouse (857-870)
  • queue_task_batch (44-158)
  • cancel_scheduled_tasks (621-759)
crates/lakekeeper/src/api/management/v1/tasks.rs (1)
  • split (139-148)
crates/lakekeeper/src/implementations/postgres/pagination.rs (1)
  • s (87-87)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (1)
crates/lakekeeper/src/service/task_queue/mod.rs (13)
  • new (60-62)
  • Self (439-439)
  • Self (451-451)
  • queue_name (97-97)
  • queue_name (306-308)
  • max_time_since_last_heartbeat (90-90)
  • task (436-436)
  • task (448-448)
  • poll_for_new_task (476-521)
  • attempt (254-256)
  • attempt (316-318)
  • task_id (249-251)
  • task_id (311-313)
crates/lakekeeper/src/tests/tasks.rs (3)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • new (60-62)
  • queue_name (97-97)
  • queue_name (306-308)
  • max_time_since_last_heartbeat (90-90)
  • task_id (249-251)
  • task_id (311-313)
  • task (436-436)
  • task (448-448)
  • pick_new_task (424-472)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (5)
  • new (48-53)
  • queue_name (68-70)
  • max_time_since_last_heartbeat (72-74)
  • task (132-132)
  • task (245-245)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (5)
  • new (34-39)
  • queue_name (48-50)
  • max_time_since_last_heartbeat (52-54)
  • task (107-107)
  • task (115-115)
crates/lakekeeper/src/api/management/mod.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • tasks (250-253)
  • list_tasks (93-270)
  • status (77-80)
crates/lakekeeper/src/service/task_queue/mod.rs (8)
  • tasks (371-388)
  • queue_name (97-97)
  • queue_name (306-308)
  • task_id (249-251)
  • task_id (311-313)
  • from (47-49)
  • from (115-117)
  • from (121-123)
crates/lakekeeper/src/api/management/v1/tasks.rs (5)
  • control_tasks (344-443)
  • get_task_details (298-341)
  • list_tasks (239-295)
  • from (118-124)
  • from (128-134)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/catalog.rs (3)
  • get_task_details (953-960)
  • list_tasks (970-976)
  • set_task_queue_config (1042-1047)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • set_task_queue_config (508-551)
  • from (36-40)
crates/lakekeeper/src/service/task_queue/task_registry.rs (1)
crates/lakekeeper/src/service/task_queue/mod.rs (9)
  • queue_name (97-97)
  • queue_name (306-308)
  • Self (439-439)
  • Self (451-451)
  • new (60-62)
  • max_time_since_last_heartbeat (90-90)
  • from (47-49)
  • from (115-117)
  • from (121-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
🔇 Additional comments (41)
.sqlx/query-1fb0532a75303ad5e0d53182aeef688252b654c83072bf913dfba3416db026a1.json (2)

3-3: Archive semantics are sound; column mapping LGTM.

Delete-to-log flow, status/type mappings, and idempotency via (task_id, attempt) look correct. Using picked_up_at for started_at and copying attempt_scheduled_for/heartbeat/created_at is consistent with the runtime model. Noting prior learnings: the task_final_status enum and (task_id, attempt) PK on task_log exist in migrations, so types/constraints align.


7-36: Parameter types/values align with schema; no action.

UuidArray/$1, final/intermediate enums ($2/$3), and bypass booleans ($5/$6) match the intended contract. Prior learnings confirm the enums/constraints exist in migrations.

crates/lakekeeper/src/catalog/tables.rs (1)

1005-1014: Readability win; behavior preserved.

Extracting booleans via into_inner() and computing storage_permissions with explicit can_write/can_read keeps semantics while making intent clearer. Looks good.

crates/lakekeeper/src/service/task_queue/task_queues_runner.rs (3)

5-5: Type-safe queue name import: LGTM

Brings TaskQueueName into scope cleanly for typed keys and logging.


32-32: Confirm trait bounds for HashMap key and logging

Using HashMap<&'static TaskQueueName, _> requires TaskQueueName: Eq + Hash. Also, this file logs {queue_name} with {}; that requires TaskQueueName: Display. Please confirm these trait impls exist (or switch logs to {:?}).


103-126: Granular JoinError handling: good improvement

Clear separation of panic vs cancellation vs other join failures with appropriate log levels.

crates/lakekeeper/src/tests/tasks.rs (6)

44-48: ExecutionDetails wiring looks correct

The empty struct + TaskExecutionDetails impl is fine and keeps tests focused.


50-58: Typed queue name + heartbeat implementation LGTM

Using a static TaskQueueName with 120s heartbeat matches the new trait contract.


76-76: Nice: queue_name passed as &'static TaskQueueName

Keeps types consistent end-to-end with the registry changes.


109-110: Correct typed usage in set_task_queue_config

Passing &QUEUE_NAME aligns with the new API.


130-131: Correct typed usage in enqueue_task

Consistent with typed queue names.


13-13: MSRV supports std::sync::LazyLock
The manifest’s rust-version = "1.86.0" covers the stabilization of std::sync::LazyLock (stabilized in Rust 1.70). No change needed.

crates/lakekeeper/src/service/task_queue/task_registry.rs (7)

9-11: Import changes are appropriate

Bringing TaskConfig and TaskQueueName into scope clarifies the typed API.


42-42: Typed keys in RegisteredTaskQueues

Keying by &'static TaskQueueName improves safety and avoids accidental string mismatches.


51-57: validate_config_fn now typed

Signature change to &TaskQueueName is a clear win; implementation is straightforward.


100-103: Consistent typed maps for workers

Mirrors the registered_queues map; good.


114-119: QueueRegistration.queue_name typed

Public API surface is consistent with the new type-safe approach.


140-147: register_queue bounded by TaskConfig

Good constraint; validator function via serde round-trip is concise.


285-290: QueueApiConfig queue_name typed

Matches the rest of the registry; good.

crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)

24-25: Type alias alignment with new execution details—LGTM.

Alias correctly binds PurgeQueueConfig, payload, and execution details; improves readability across call sites.


33-40: Constructor for payload—LGTM.

Small, clear helper to enforce initialization; matches field visibilities.


151-151: Pre-IO transaction commit log—LGTM.

Warning before IO is appropriate; avoids holding a DB read transaction across remote storage calls.


16-20: The TaskQueueName type is defined simply as a newtype without any new constructor or inherent methods, and there’s no impl From<&str> in the crate’s service/task_queue module. The implicit .into() relies on the blanket impl From<String> or Into<String> → TaskQueueName via From<String> for TaskQueueName (the latter exists, since the struct wraps a String). Using TaskQueueName::new isn’t possible—no such API exists. Leaving QN_STR.into() is correct and MSRV-safe.

.sqlx/query-284c3872eafc736eecbb225e18a644331ff3f770aa6ff03dfbed961dee5becd6.json (1)

3-3: Solid transactional log-then-reset; idempotency looks correct

CTE lock + log insert + state reset aligns with the retry flow. ON CONFLICT on (task_id, attempt) ensures idempotence. LGTM.

.sqlx/query-0eef2c01a1e39f3a36f5f25ffdf78cf8983df324721ffd4f4168367bc9386755.json (1)

3-3: Time zone simplification looks fine

Switching to now() against timestamptz columns is consistent; no need for AT TIME ZONE 'UTC' here.

.sqlx/query-883cf05f80797b83966b5dc5fc50df81f5eef600eae7ea9ac2c84bdc3d674bbc.json (1)

3-3: Cancel/delete-and-log flow is sound and idempotent

DELETE ... RETURNING into CTE + insert into task_log with ON CONFLICT is clean. Duration guarded by CASE is a nice touch.

crates/lakekeeper/src/implementations/postgres/tasks/resolve_tasks.rs (2)

31-45: Active-task lookup looks good

Scoped by IDs and optional warehouse, correct type mapping, and avoids extra allocations beyond the ID Vec. LGTM.


70-85: DISTINCT ON usage is correct for latest attempt

DISTINCT ON (task_id) with ORDER BY task_id, attempt DESC returns the latest attempt per task_id. Good choice for “last seen” semantics.

crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)

41-72: API mapping is robust; explicit error when status is missing

Good conversion and defensive error if both statuses are NULL. LGTM.


144-245: Pagination UNION strategy is efficient; be aware of per-branch LIMIT tradeoff

Limiting both CTEs to page_size reduces work but can starve older rows from one branch if the other branch is dense. Your tests cover pagination correctness; just noting the tradeoff.

If you ever see gaps across pages, consider removing the inner LIMITs and relying on the final LIMIT, or doubling inner limits.


255-265: Token retention on empty pages (intent check)

Keeping the previous page_token when a page returns empty is unconventional but your tests assert it. Confirm this UX is intended for clients.

crates/lakekeeper/src/api/management/mod.rs (7)

9-9: New v1::tasks module export looks good

Public surfacing of tasks under v1 is consistent with the added endpoints.


60-63: Re-exports for task types: LGTM

The public types (requests/responses, Service) are re-exported cleanly for v1.


73-77: Import TaskId/QueueApiConfig: LGTM

Imports match new endpoint handlers and OpenAPI patching below.


92-92: Add "tasks" tag: LGTM

Matches the new Task Management surface.


1500-1526: GetTaskQueueConfig OpenAPI: LGTM

Params align with route; response type matches GetTaskQueueConfigResponse.


1549-1570: GetTaskDetails OpenAPI: LGTM

Query typing and path params match handler signature.


1896-1904: Router wiring for Tasks endpoints: LGTM

Paths bind to ManagementV1Endpoint::* and correct methods.

docs/docs/api/management-open-api.yaml (3)

2376-2478: Task endpoints (get by id / control / list): LGTM

Paths, verbs, and payload/response schemas align with server handlers and limits.


4627-4770: Task/Attempt schemas: LGTM

Nullable fields and enums align with backend (parent-task-id nullable, status set matches intermediate/final).


5335-5336: New “tasks” tag: LGTM

Consistent with code and grouping.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 31, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/docs/api/management-open-api.yaml (1)

2258-2263: Remove stray path parameter queue_name (not present in route).

Both routes lack a {queue_name} segment but declare a path param. Drop the param to keep the spec valid.

-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string

Also applies to: 2325-2329

♻️ Duplicate comments (1)
crates/lakekeeper/src/service/task_queue/mod.rs (1)

101-104: Thread-safety bounds on data/details — good.

Adding Send + Sync avoids footguns when crossing async boundaries.

🧹 Nitpick comments (8)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (4)

42-44: Use Reverse key to sort desc (clearer, avoids negation).

Negating attempt works but reads odd. Reverse is clearer and avoids potential edge overflows.

-    records.sort_by_key(|r| -r.attempt);
+    use std::cmp::Reverse;
+    records.sort_unstable_by_key(|r| Reverse(r.attempt));

230-230: Adjust error text: not only “active” task details.

This path returns active and historical tasks; “active” is misleading.

-    .map_err(|e| e.into_error_model("Failed to get active task details"))?;
+    .map_err(|e| e.into_error_model("Failed to get task details"))?;

151-173: LIMIT semantics: keep correctness with simpler SQL (optional).

You rely on Rust-side sorting/truncation anyway. Consider removing SQL-side “+ 1” arithmetic to simplify static checking by sqlx and reduce planner work:

-        ORDER BY attempt desc 
-        LIMIT $3 + 1
+        ORDER BY attempt DESC
+        LIMIT $3

You’re already truncating attempts in Rust (Lines 235-237). If you keep “+ 1”, consider casting explicitly to avoid planner surprises: LIMIT ($3 + 1)::int4.

Also applies to: 191-195


26-27: Progress NaN/Infinity can break JSON serialization.

If progress in DB is NaN/∞, serde will error when serializing GetTaskDetailsResponse. If you intentionally “fail fast” on invalid producer progress, fine—just be aware it manifests as a 500 on read. Consider mapping non-finite to an error earlier or documenting this behavior.

Also applies to: 80-81, 114-115

docs/docs/api/management-open-api.yaml (1)

3138-3140: Grammar nit: “an explicit range”.

Tiny doc polish.

-                Either for a explicit range or a page token to paginate through the results.
+                Either for an explicit range or a page token to paginate through the results.
crates/lakekeeper/src/api/management/v1/tasks.rs (1)

321-323: Cap num_attempts to a sane upper bound (optional).

Unbounded values could request large histories. Consider clamping to, e.g., 100, matching other caps.

-        let num_attempts = query.num_attempts.unwrap_or(DEFAULT_ATTEMPTS);
+        let num_attempts = query.num_attempts.unwrap_or(DEFAULT_ATTEMPTS).min(100);
crates/lakekeeper/src/service/task_queue/mod.rs (2)

35-73: TaskQueueName newtype: add serde(transparent) (optional).

It already serializes correctly as a newtype, but marking it transparent is explicit and future-proof.

-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[serde(transparent)]
 pub struct TaskQueueName(String);

523-558: Heartbeat error code naming — good; consider progress guard (optional).

You chose to surface invalid progress via errors (no clamping). That’s fine; consider validating is_finite() to fail early with a precise error message.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 428769b and 15d467e.

📒 Files selected for processing (4)
  • crates/lakekeeper/src/api/management/v1/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (24 hunks)
  • docs/docs/api/management-open-api.yaml (16 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-31T12:49:16.774Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs:125-141
Timestamp: 2025-08-31T12:49:16.774Z
Learning: In the Lakekeeper task system, stored durations in the database never contain months (months == 0 in PgInterval), making the pg_interval_to_duration function's rejection of non-zero months correct and safe.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
📚 Learning: 2025-08-30T10:23:41.114Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
  • crates/lakekeeper/src/service/task_queue/mod.rs
🧬 Code graph analysis (3)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (2)
crates/lakekeeper/src/service/task_queue/mod.rs (17)
  • tasks (371-388)
  • task_id (249-251)
  • task_id (311-313)
  • task (436-436)
  • task (448-448)
  • from (47-49)
  • from (115-117)
  • from (121-123)
  • record_failure (563-600)
  • record_success (606-642)
  • queue_name (97-97)
  • queue_name (306-308)
  • attempt (254-256)
  • attempt (316-318)
  • as_str (65-67)
  • task_data (267-278)
  • to_uuid (184-188)
crates/lakekeeper/src/implementations/postgres/tasks.rs (7)
  • from (36-40)
  • pick_task (162-256)
  • record_failure (332-472)
  • record_success (258-329)
  • setup_warehouse (857-870)
  • queue_task_batch (44-158)
  • task_metadata (1403-1410)
crates/lakekeeper/src/service/task_queue/mod.rs (6)
crates/lakekeeper/src/service/task_queue/task_registry.rs (6)
  • new (133-138)
  • max_time_since_last_heartbeat (334-336)
  • max_time_since_last_heartbeat (350-352)
  • queue_name (330-332)
  • queue_name (346-348)
  • serde_json (146-146)
crates/lakekeeper/src/implementations/postgres/tasks.rs (1)
  • check_and_heartbeat_task (579-611)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (5)
  • new (34-39)
  • max_time_since_last_heartbeat (52-54)
  • queue_name (48-50)
  • task (107-107)
  • task (115-115)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (5)
  • new (48-53)
  • max_time_since_last_heartbeat (72-74)
  • queue_name (68-70)
  • task (132-132)
  • task (245-245)
crates/lakekeeper/src/tests/tasks.rs (3)
  • max_time_since_last_heartbeat (56-58)
  • queue_name (52-54)
  • SpecializedTask (84-86)
crates/lakekeeper/src/service/catalog.rs (4)
  • transaction (84-84)
  • check_and_heartbeat_task (1016-1023)
  • record_task_failure (933-940)
  • record_task_success (918-924)
crates/lakekeeper/src/api/management/v1/tasks.rs (7)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • from (36-40)
  • cancel_scheduled_tasks (621-759)
crates/lakekeeper/src/api/management/mod.rs (4)
  • from (1629-1634)
  • list_tasks (1540-1547)
  • get_task_details (1560-1570)
  • control_tasks (1586-1595)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (93-270)
  • entities (133-142)
  • tasks (250-253)
crates/lakekeeper/src/service/catalog.rs (8)
  • list_tasks (970-976)
  • begin_read (78-78)
  • get_task_details (953-960)
  • resolve_required_tasks (891-910)
  • begin_write (76-76)
  • stop_tasks (1037-1040)
  • clear_tabular_deleted_at (504-508)
  • cancel_scheduled_tasks (1008-1013)
crates/iceberg-ext/src/catalog/rest/error.rs (3)
  • bad_request (127-133)
  • not_found (182-188)
  • forbidden (211-217)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: docker / docker
  • GitHub Check: security_audit
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: clippy
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: sqlx-check
🔇 Additional comments (8)
docs/docs/api/management-open-api.yaml (3)

3436-3476: Queue-name array shape matches server — good.

Spec now models multiple queue names; aligns with Option<Vec> in server.


3290-3294: Type JSON blobs as object|null — good for generators.

execution-details and task-data/attempt.execution-details now explicitly typed; this helps client SDKs.

Also applies to: 4724-4727


2461-2473: New Tasks endpoints and schemas look consistent.

Paths, enums (SCREAMING_SNAKE_CASE), and shapes match server code.

Also applies to: 3477-3497, 4631-4700, 4701-4750

crates/lakekeeper/src/api/management/v1/tasks.rs (3)

248-281: Early returns on empty filters and hard caps — nice.

Short-circuiting empty entity/queue filters and capping to 100 prevents wasteful DB work.


420-446: Control flow and auth for Stop/Cancel look sound.

Per-queue permission mapping (Undrop vs Drop) is careful; transaction boundaries are correct.


526-561: Clear forbidden actions message — good.

Detailed appended context helps operators.

crates/lakekeeper/src/service/task_queue/mod.rs (2)

677-724: Robust deserialization failure handling.

Retries, contextual logs, and recording failure into task_log are well designed.


764-789: Status recording paths include contextual details — nice.

Clear queue/task IDs in errors aid ops.

Comment thread docs/docs/api/management-open-api.yaml Resolved
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 31, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/docs/api/management-open-api.yaml (1)

2258-2263: Fix path parameter mismatch: remove unused queue_name path param (path has no {queue_name}).

Both GET endpoints define queue_name as in: path but the routes lack {queue_name}. This breaks validation and codegen. Either add {queue_name} to the path, or (per your description: “global per warehouse”) remove the param. Recommend removal for consistency (also POSTs don't take it).

Apply:

       parameters:
         - name: warehouse_id
           in: path
           required: true
           schema:
             type: string
             format: uuid
-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string

Also applies to: 2325-2329

♻️ Duplicate comments (2)
crates/lakekeeper/src/service/task_queue/mod.rs (1)

88-99: Traits require Send + Sync — good upgrade for async safety.

This prevents non-thread-safe payloads crossing task boundaries.

crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)

132-141: Optional: use a specific error code for monthful intervals.

If desired, replace the generic "InternalError" with something task-specific like "TaskDurationConversionError" to aid diagnostics. Logic otherwise looks correct given months are never stored.

🧹 Nitpick comments (5)
docs/docs/api/management-open-api.yaml (2)

2395-2405: Document the default for numAttempts (default 5).

The summary mentions a default but it’s missing in the schema.

         - name: numAttempts
           in: query
           description: 'Number of attempts to retrieve (default: 5)'
           required: false
           schema:
             type:
               - integer
               - 'null'
             format: int32
             minimum: 0
+            default: 5

3470-3476: Clarify that queue-name accepts multiple names.

The property is an array; make the description plural to avoid confusion.

-          description: Filter by queue name
+          description: Filter by one or more queue names
crates/lakekeeper/src/service/task_queue/mod.rs (1)

524-559: Add observability around heartbeats.

Consider emitting counters/timers for heartbeat success/failure and check states (Continue/Stop/NotActive) to spot stuck workers and flaky queues.

crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (2)

42-49: Prefer explicit descending sort for clarity.

Avoid the unary negation trick; it’s less readable.

-    // Sort by attempt descending
-    records.sort_by_key(|r| -r.attempt);
+    // Sort by attempt descending
+    records.sort_by(|a, b| b.attempt.cmp(&a.attempt));

596-598: Fix clippy lint: avoid as i64 cast from u32.

Use i64::from(...) for an infallible cast.

-        let scheduled_for = scheduled_for
-            - chrono::Duration::nanoseconds(scheduled_for.timestamp_subsec_nanos() as i64);
+        let scheduled_for = scheduled_for
+            - chrono::Duration::nanoseconds(i64::from(scheduled_for.timestamp_subsec_nanos()));
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 15d467e and fd9d137.

📒 Files selected for processing (5)
  • crates/lakekeeper/src/api/management/mod.rs (12 hunks)
  • crates/lakekeeper/src/api/management/v1/project.rs (2 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • crates/lakekeeper/src/service/task_queue/mod.rs (24 hunks)
  • docs/docs/api/management-open-api.yaml (16 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/lakekeeper/src/api/management/v1/project.rs
  • crates/lakekeeper/src/api/management/mod.rs
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-31T12:49:16.774Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs:125-141
Timestamp: 2025-08-31T12:49:16.774Z
Learning: In the Lakekeeper task system, stored durations in the database never contain months (months == 0 in PgInterval), making the pg_interval_to_duration function's rejection of non-zero months correct and safe.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
📚 Learning: 2025-08-30T10:23:41.114Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
  • crates/lakekeeper/src/service/task_queue/mod.rs
🧬 Code graph analysis (2)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (4)
crates/lakekeeper/src/service/task_queue/mod.rs (16)
  • tasks (372-389)
  • task_id (250-252)
  • task_id (312-314)
  • task (437-437)
  • task (449-449)
  • from (48-50)
  • from (116-118)
  • from (122-124)
  • record_failure (564-601)
  • record_success (607-643)
  • queue_name (98-98)
  • queue_name (307-309)
  • attempt (255-257)
  • attempt (317-319)
  • task_data (268-279)
  • to_uuid (185-189)
crates/lakekeeper/src/api/management/mod.rs (2)
  • from (1629-1634)
  • get_task_details (1560-1570)
crates/lakekeeper/src/api/management/v1/tasks.rs (3)
  • from (121-127)
  • from (131-137)
  • get_task_details (301-344)
crates/lakekeeper/src/implementations/postgres/tasks.rs (6)
  • from (36-40)
  • pick_task (162-256)
  • record_failure (332-472)
  • record_success (258-329)
  • setup_warehouse (857-870)
  • queue_task_batch (44-158)
crates/lakekeeper/src/service/task_queue/mod.rs (6)
crates/lakekeeper/src/service/task_queue/task_registry.rs (5)
  • max_time_since_last_heartbeat (334-336)
  • max_time_since_last_heartbeat (350-352)
  • queue_name (330-332)
  • queue_name (346-348)
  • serde_json (146-146)
crates/lakekeeper/src/implementations/postgres/tasks.rs (1)
  • check_and_heartbeat_task (579-611)
crates/lakekeeper/src/service/task_queue/tabular_purge_queue.rs (4)
  • max_time_since_last_heartbeat (52-54)
  • queue_name (48-50)
  • task (107-107)
  • task (115-115)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (4)
  • max_time_since_last_heartbeat (72-74)
  • queue_name (68-70)
  • task (132-132)
  • task (245-245)
crates/lakekeeper/src/tests/tasks.rs (2)
  • max_time_since_last_heartbeat (56-58)
  • queue_name (52-54)
crates/lakekeeper/src/service/catalog.rs (4)
  • transaction (84-84)
  • check_and_heartbeat_task (1016-1023)
  • record_task_failure (933-940)
  • record_task_success (918-924)
🪛 GitHub Check: clippy
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs

[failure] 597-597:
casts from u32 to i64 can be expressed infallibly using From

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: test
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: sqlx-check
  • GitHub Check: security_audit
🔇 Additional comments (8)
docs/docs/api/management-open-api.yaml (3)

2376-2478: New Task endpoints shape looks coherent and consistent.

Routes, tags, and schemas line up with server types; nullable and pagination conventions match the rest of the spec.


3276-3296: Good: explicit typing for polymorphic fields.

execution-details and task-data are now concretely typed. This will help generators.


5341-5343: Tasks tag addition reads well and aligns with the new surface.

LGTM.

crates/lakekeeper/src/service/task_queue/mod.rs (4)

35-74: Typed TaskQueueName wrapper is solid.

Transparent serde + Deref + Display give nice ergonomics.


76-86: TaskEntity serde/ToSchema shape matches the API.

Enum tagging and UUID wrappers look correct.


135-151: TaskAttemptId utilities are clean and useful.

Display and AsRef impls will simplify logging and DB calls.


424-473: Error handling on pick + graceful polling loop look robust.

Backoff and cancellation handling are sensible.

crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)

149-242: SQL shape and record parsing LGTM.

Union + local sorting, duration handling, and status folding (intermediate/final) look correct; truncation to num_attempts is handled.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 31, 2025
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/docs/api/management-open-api.yaml (1)

2258-2263: Remove invalid queue_name path parameters.

Both endpoints don’t have {queue_name} in the path, yet declare it as a path parameter. This breaks validation and generated clients.

Apply:

@@
-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string
@@
-        - name: queue_name
-          in: path
-          required: true
-          schema:
-            type: string

Also applies to: 2325-2329

♻️ Duplicate comments (3)
docs/docs/api/management-open-api.yaml (3)

3471-3477: LGTM: queue-name now supports multiple queues.

Matches server’s Option<Vec>. Good fix.


3291-3297: LGTM: execution-details typed as (object|null).

Helps generators and mirrors server behavior.

Also applies to: 4725-4728


4662-4666: LGTM: parent-task-id is nullable and no longer required.

Spec now matches responses that may return null.

🧹 Nitpick comments (4)
docs/docs/api/management-open-api.yaml (1)

2396-2406: Constrain numAttempts to a sane maximum (e.g., 100).

Prevents oversized queries and aligns with other list limits.

         - name: numAttempts
           in: query
           description: 'Number of attempts to retrieve (default: 5)'
           required: false
           schema:
             type:
               - integer
               - 'null'
             format: int32
             default: 5
             minimum: 0
+            maximum: 100
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (2)

43-43: Prefer Reverse() over negating integers for descending sort.

Improves clarity and avoids relying on signed negation.

+use std::cmp::Reverse;
@@
-    records.sort_by_key(|r| -r.attempt);
+    records.sort_by_key(|r| Reverse(r.attempt));

Also applies to: 1-6


174-223: Optional: push ordering into SQL for fewer allocations.

Adding ORDER BY attempt DESC in the combined subquery can reduce in-memory sorting work, especially with many attempts.

crates/lakekeeper/src/api/management/v1/tasks.rs (1)

209-213: Cap num_attempts and document it (e.g., ≤100).

Guards against heavy queries and aligns with OpenAPI.

 #[derive(Debug, Deserialize, utoipa::IntoParams)]
 #[serde(rename_all = "camelCase")]
 pub struct GetTaskDetailsQuery {
     /// Number of attempts to retrieve (default: 5)
-    #[param(default = 5)]
+    #[param(default = 5, minimum = 0, maximum = 100)]
     pub num_attempts: Option<u16>,
 }
@@
-        let num_attempts = query.num_attempts.unwrap_or(DEFAULT_ATTEMPTS);
+        let num_attempts = query
+            .num_attempts
+            .unwrap_or(DEFAULT_ATTEMPTS)
+            .min(100);

Also applies to: 322-323

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between fd9d137 and ae5bd82.

📒 Files selected for processing (3)
  • crates/lakekeeper/src/api/management/v1/tasks.rs (1 hunks)
  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1 hunks)
  • docs/docs/api/management-open-api.yaml (16 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-31T12:49:16.774Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs:125-141
Timestamp: 2025-08-31T12:49:16.774Z
Learning: In the Lakekeeper task system, stored durations in the database never contain months (months == 0 in PgInterval), making the pg_interval_to_duration function's rejection of non-zero months correct and safe.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
📚 Learning: 2025-08-30T10:23:41.114Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/migrations/20250826171037_task_runtime_information.sql:7-7
Timestamp: 2025-08-30T10:23:41.114Z
Learning: In the task_runtime_information migration (20250826171037), truncating task_log is intentional as confirmed by c-thiel, likely due to significant schema changes requiring a clean slate.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
📚 Learning: 2025-08-30T10:35:58.903Z
Learnt from: c-thiel
PR: lakekeeper/lakekeeper#1316
File: crates/lakekeeper/src/implementations/postgres/tasks.rs:169-173
Timestamp: 2025-08-30T10:35:58.903Z
Learning: In the task picking SQL query in crates/lakekeeper/src/implementations/postgres/tasks.rs, the WHERE clause intentionally allows both Running and ShouldStop tasks to be re-picked if their last heartbeat is older than max_time_since_last_heartbeat. This is a reconciliation mechanism to handle cases where workers are killed or crash, preventing tasks from being stuck indefinitely in Running or ShouldStop states.

Applied to files:

  • crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs
🧬 Code graph analysis (2)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (3)
crates/lakekeeper/src/service/task_queue/mod.rs (15)
  • tasks (372-389)
  • task_id (250-252)
  • task_id (312-314)
  • task (437-437)
  • task (449-449)
  • from (48-50)
  • from (116-118)
  • from (122-124)
  • record_failure (564-601)
  • record_success (607-643)
  • queue_name (98-98)
  • queue_name (307-309)
  • attempt (255-257)
  • attempt (317-319)
  • to_uuid (185-189)
crates/lakekeeper/src/api/management/v1/tasks.rs (2)
  • from (121-127)
  • from (131-137)
crates/lakekeeper/src/implementations/postgres/tasks.rs (5)
  • from (36-40)
  • pick_task (162-256)
  • record_failure (332-472)
  • record_success (258-329)
  • queue_task_batch (44-158)
crates/lakekeeper/src/api/management/v1/tasks.rs (6)
crates/lakekeeper/src/implementations/postgres/tasks.rs (2)
  • from (36-40)
  • cancel_scheduled_tasks (621-759)
crates/lakekeeper/src/implementations/postgres/tasks/list_tasks.rs (3)
  • list_tasks (93-270)
  • entities (133-142)
  • tasks (250-253)
crates/lakekeeper/src/service/catalog.rs (8)
  • list_tasks (970-976)
  • begin_read (78-78)
  • get_task_details (953-960)
  • resolve_required_tasks (891-910)
  • begin_write (76-76)
  • stop_tasks (1037-1040)
  • clear_tabular_deleted_at (504-508)
  • cancel_scheduled_tasks (1008-1013)
crates/iceberg-ext/src/catalog/rest/error.rs (3)
  • bad_request (127-133)
  • not_found (182-188)
  • forbidden (211-217)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)
  • get_task_details (143-242)
crates/lakekeeper/src/service/task_queue/tabular_expiration_queue.rs (1)
  • queue_name (68-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: sqlx-check
  • GitHub Check: test
🔇 Additional comments (1)
crates/lakekeeper/src/implementations/postgres/tasks/get_task_details.rs (1)

125-141: LGTM: robust PgInterval→Duration conversion.

Rejecting non-zero months is correct per storage invariant; safe conversion of days+micros.

@c-thiel
c-thiel merged commit 1ee7bf2 into main Aug 31, 2025
@c-thiel
c-thiel deleted the ct/report-execution-details branch August 31, 2025 16:16
mrjoe7 added a commit to mrjoe7/lakekeeper that referenced this pull request Oct 30, 2025
* feat: Publish images to Dockerhub (lakekeeper#1274)

* feat: Update UI to 0.9.0 with multi-project support (lakekeeper#1275)

* chore: release 0.9.4

Release-As: 0.9.4

* chore: release main (lakekeeper#1262)

* chore(ci): Fix Dockerhub login

* chore(docs): Improve developer guide (lakekeeper#1265)

* chore(docs): add info regarding `view_version`'s internal representation (lakekeeper#1261)

* chore(docs): Architecture clarify Secret Store (lakekeeper#1284)

* fix: Update Limes to 0.2.2 - Fixes compilation issue due to breaking `jwks_client_rs` change (lakekeeper#1282)

* fix: Update Limes to 0.2.2

* increase min rust version

* chore: release 0.9.5

Release-As: 0.9.5

* chore: release main (lakekeeper#1286)

* chore: enable changelog sections for release-please (lakekeeper#1264)

k

* fix(deps): update rust crate rand to v0.9.2 (lakekeeper#1252)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-channel to v2.5.0 (lakekeeper#1225)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency mkdocs-material to v9.6.17 (lakekeeper#1289)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate anyhow to v1.0.99 (lakekeeper#1290)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: Remove bitnami images (lakekeeper#1288)

* feat!: Move to Lakekeeper IO based on hyperscaler SDKs (lakekeeper#1285)

* chore(deps): update rust crate reqwest to v0.12.23 (lakekeeper#1294)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(docs): Improve Cloud storage test docs

* fix: accept "disable" as PG sslmode as documented (lakekeeper#1303)

* feat: Simplify task interface, re-exports, enable delete-after-commit (lakekeeper#1302)

* feat: Introduce `RequestMetadata` for Internal Principals which bypass AuthZ (lakekeeper#1306)

* chore(deps): update azure/setup-helm action to v4.3.1 (lakekeeper#1299)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(test): use nextest filterset instead of needs_env_var (lakekeeper#1304)

* chore(deps): update rust crate openssl-src to v300.5.2 (lakekeeper#1292)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-compression to v0.4.28 (lakekeeper#1311)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate thiserror to v2.0.16 (lakekeeper#1296)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Provide `ApiContext` to externally registered tasks (lakekeeper#1307)

* feat!: Simplify Task interface, extend SpecializedTask interface (lakekeeper#1310)

* feat: Improve authorizer `are_allowed_*` batch check signature (lakekeeper#1315)

* chore(authz): Enforce use of AuthZ decisions with #[must_use] (lakekeeper#1317)

* feat: Task Management APIs (lakekeeper#1316)

* chore(deps): update rust crate tracing-subscriber to v0.3.20 [security] (lakekeeper#1318)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Add `RunNow` and `RunAt` to Controls for Tasks (lakekeeper#1322)

* chore(deps): update rust crate tokio-util to v0.7.16 (lakekeeper#1313)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(docs): Improve Entra ID docs (lakekeeper#1325)

* chore(docs): Improve Upgrades & Migration docs (lakekeeper#1326)

* feat: Add tasks heartbeat with Catalog state (lakekeeper#1324)

* ci: add configuration for CodeRabbit reviews (lakekeeper#1327)

* feat: Add optional STS session-tags in S3 STS requests for ABAC authorization (lakekeeper#1230)

* feat: Random Server IDs (lakekeeper#1328)

* chore(deps): update rust crate percent-encoding to v2.3.2 (lakekeeper#1312)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(authz): Deprecate Permission Endpoints for Tables without WarehouseIDs (lakekeeper#1334)

* fix: Tasks endpoints in router (lakekeeper#1335)

* feat(ci): add nextest profile ci_no_secrets for external PRs (lakekeeper#1333)

* chore(deps): update rust crate chrono to v0.4.42 (lakekeeper#1331)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: Pin examples duckdb version to 1.3 (lakekeeper#1343)

* feat!: Require warehouse_id when checking permissions on views or tables via ID (lakekeeper#1340)

* fix: migrate away from bitnami in unittest.yml (lakekeeper#1344)

* chore: Remove coderabitt config

* fix(docs): Fix inconsistent URL format in README (lakekeeper#1345)

Co-authored-by: Christian <[email protected]>

* feat: Remove serde_yaml & serde_yml (lakekeeper#1341)

* feat!: add `warehouse_id` to PKs of all `table_*` and `view_*` tables (lakekeeper#1254)

* feat: Minor namespace join performance improvements

* fix: Warehouse permissions are directly used for task retrieval & control (lakekeeper#1347)

* fix: Potential Race Condition when undropping Tabulars (lakekeeper#1342)

* fix: table rename authz and error handling (lakekeeper#1346)

Co-authored-by: Andre Luis Anastacio <[email protected]>

* chore(deps): update rust crate google-cloud-auth to v1.1.2 (lakekeeper#1337)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update rust crate time to v0.3.44 (lakekeeper#1349)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency mkdocs-material to v9.6.20 (lakekeeper#1309)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* feat: Set ServerID during migration (lakekeeper#1348)

* chore(deps): Remove utoipa fork (lakekeeper#1352)

* chore(deps): update rust crate serde_with to v3.14.1 (lakekeeper#1351)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate url to v2.5.7 (lakekeeper#1354)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-compression to v0.4.30 (lakekeeper#1323)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update rust crate serde_json to v1.0.145 (lakekeeper#1250)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update strum monorepo to v0.27.2 (lakekeeper#1251)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update serde monorepo to v1.0.226 (lakekeeper#1355)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update rust crate clap to v4.5.48 (lakekeeper#1356)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Add Entity Names to Tasks (lakekeeper#1353)

* fix: case insensitivity of catalog endpoints (lakekeeper#1338)

* fix: Improve delete_warehouse error message for active tasks

* chore(deps): update rust crate tempfile to v3.22.0 (lakekeeper#1359)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian <[email protected]>

* chore(deps): update rust crate axum-prometheus to 0.9.0 (lakekeeper#1358)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: PgSslMode not supported error string

* feat(authz)!: add OpenFGA schema v4 and v3->v4 migration (lakekeeper#1314)

Co-authored-by: Christian <[email protected]>
Co-authored-by: Christian Thiel <[email protected]>

* chore(deps): update rust crate uuid to v1.18.1 (lakekeeper#1362)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency markdown-grid-tables to v0.6.0 (lakekeeper#1357)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate anyhow to v1.0.100 (lakekeeper#1350)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: clippy

* chore(deps): update rust crate moka to v0.12.11 (lakekeeper#1365)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate tempfile to v3.23.0 (lakekeeper#1367)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update rust crate async-nats to 0.43.0 (lakekeeper#1366)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/setup-node action to v5 (lakekeeper#1371)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/checkout action to v5 (lakekeeper#1369)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update actions/setup-python action to v6 (lakekeeper#1372)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: V3 support (lakekeeper#1364)

* chore: Set Get Task Permission to "CanGetMetadata" (lakekeeper#1376)

* chore(deps): update dependency node to v22 (lakekeeper#1373)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(authz)!: extend OpenFGA tabular entities with WarehouseId (lakekeeper#1329)


---------

Co-authored-by: Christian <[email protected]>
Co-authored-by: Christian Thiel <[email protected]>

* feat: Add support for tasks affecting views (lakekeeper#1378)

* feat(authz): Add specific Task Actions (lakekeeper#1379)

* chore(tests): Test with Iceberg 1.9.2 & 1.10.0 (lakekeeper#1267)

* feat: Enrich task metadata with concrete tabular type (lakekeeper#1383)

* feat: Add loadTable Snapshots filter (lakekeeper#1385)

* feat: add endpoint for fuzzy search of tabulars (lakekeeper#1387)

* feat: Update UI to 0.10.0 (lakekeeper#1390)

* feat(ui): Update UI to 0.10.1

* chore: Use lakekeeper re-exports in bin (lakekeeper#1391)

* fix(tabular-search): distance and docs for `searchterm is uuid` (lakekeeper#1393)

* chore(examples): Idempotent bucket creation in minimal example (lakekeeper#1386)

In the case where you already have a bucket created, like the "examples" bucket, I ran into an issue where the createbuckets service fails, and this prevents lakekeeper from starting back up.

This fix adds a simple minio flag to ignore buckets that already exist, making things even more user friendly

* feat: Make number of workers spawned for Expiration & Purge configurable (lakekeeper#1395)

* chore: release main (lakekeeper#1295)

* chore: added gif to readme (lakekeeper#1396)

* chore: remove unneded `#[allow(dead_code)]` (lakekeeper#1399)

* fix: Use FnOnce for queue & service registration

* Revert "fix: Use FnOnce for queue & service registration"

This reverts commit 47b03a0.

* chore(docs): Add 0.10 docs

* perf(db): remove `join namespace` from `active_tabulars` view (lakekeeper#1401)

* doc(db): how to connect to db and inspect schema (lakekeeper#1402)

* feat: implement `OpenFgaEntity` for `ServerId` (lakekeeper#1394)

* impl OpenFgaEntity
* Use the implementation

* fix: Use FnOnce for queue & service registration (lakekeeper#1404)

* chore(deps): update dependency mkdocs-material to v9.6.21 (lakekeeper#1406)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Expose client-managed X-Iceberg-Access-Delegation (lakekeeper#1407)

* fix: Use higher consistency for some OpenFGA queries (lakekeeper#1408)

* feat: Improve Kubernetes Auth docs (lakekeeper#1415)

* chore: release 0.10.1

Release-As: 0.10.1

* fix: Endpoint stats for Project Endpoints (lakekeeper#1412)

* feat: Add create table guard to cleanup location on Failure (lakekeeper#1418)

* chore: Generate ID types with Macro (lakekeeper#1419)

* chore: Re-Export Tokio from lakekeeper-io create (lakekeeper#1420)

* fix: Add support for `write.metadata.metrics.` Table Properties (lakekeeper#1422)

* fix: Update UI to 0.10.2 (lakekeeper#1423)

* chore: release main (lakekeeper#1403)

* fix: Parse empty ProjectID headers as None (lakekeeper#1424)

* chore: release 0.10.2

Release-As: 0.10.2

* chore: release main (lakekeeper#1425)

* feat: Add `debug_migrate_before_serve` env var (lakekeeper#1426)

* feat: Move OpenFGA Authorizer to separate crate (lakekeeper#1421)

* chore(renovate): Group dependencies

* chore(renovate): ignore additional deps

* chore: Rename src/service -> src/server, trait Catalog -> CatalogStore (lakekeeper#1428)

* feat(examples): add k8s iceberg sink connector (avro) (lakekeeper#1336)


---------

Co-authored-by: Christian <[email protected]>

* chore(ci): Fix release please (lakekeeper#1433)

* feat: Expose License Information via API (lakekeeper#1432)

* fix(deps): update all non-major dependencies (lakekeeper#1429)

* chore(ci): Remove mgmt API version update via release-please

* chore: Restructure catalog_store into multiple modules (lakekeeper#1434)

* feat: Validate Downscoping works on Warehouse creation (lakekeeper#1437)

* chore(ci): Fix release please

* docs: Add info about installing sqlx to developer-guide.md (lakekeeper#1438)

* docs: Update developer-guide.md (lakekeeper#1439)

* chore(deps): update all non-major dependencies (lakekeeper#1436)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: Better normalization for ARNs in S3 Profile (lakekeeper#1441)

* chore(deps): update all non-major dependencies (lakekeeper#1442)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(main): release 0.10.3 (lakekeeper#1427)

* fix: Release Please CI outputs

* fix(ci): Revert 0.10.3 release

* chore(main): release 0.10.3 (lakekeeper#1446)

* feat: Introduce CatalogWarehouseOps & CatalogNamespaceOps abstractions (lakekeeper#1440)

* feat: Allow x-user-agent header (lakekeeper#1453)

* feat: Table & View Ops Abstractions, Improved Error Handling (lakekeeper#1454)

* fix: CORS allow access delegation & etag headers (lakekeeper#1455)

* fix: Headers should be lowercase (lakekeeper#1457)

* chore(tests): Add trino information_schema.tables test (lakekeeper#1456)

* chore: Introduce open-api feature to gate utoipa and swagger (lakekeeper#1458)

* chore: Release As 0.11

* fix: Debug assertion table identifier mismatch for signer (lakekeeper#1460)

* feat: Caching Short-Term-Credentials (STC) (lakekeeper#1459)

* feat: Warehouse Cache (lakekeeper#1462)

* chore(deps): update actions/setup-node action to v6 (lakekeeper#1443)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Version based Warehouse Cache (lakekeeper#1465)

* feat: AuthZ Server and Project Ops (lakekeeper#1471)

* chore(deps): update github artifact actions (lakekeeper#1461)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: Rename release branch pattern to rel-*

* feat: Catalog returns full Namespace Hierarchy for nested Namespaces (lakekeeper#1472)

---------

Co-authored-by: Christian <[email protected]>
Co-authored-by: Christian Thiel <[email protected]>
Co-authored-by: Dao Thanh Tung <[email protected]>
Co-authored-by: Moritz Zielke <[email protected]>
Co-authored-by: Baptiste Gouhoury <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dolan Antenucci <[email protected]>
Co-authored-by: Anatoly Popov <[email protected]>
Co-authored-by: Andre Luis Anastacio <[email protected]>
Co-authored-by: Scott Haines <[email protected]>
Co-authored-by: Viktor Kessler <[email protected]>
Co-authored-by: Yohan Valencia <[email protected]>
Co-authored-by: Paul Roman <[email protected]>
@coderabbitai coderabbitai Bot mentioned this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant