Skip to content

Use INT4 for datasource_outputs.step_id, so it is 4 bytes on CockroachDB too - #884

Merged
maxdml merged 1 commit into
dbos-inc:mainfrom
marc-merino:knit/use-int4-for-step-id-columns-on-cockroachdb
Oct 9, 2026
Merged

maxdml merged 1 commit into
dbos-inc:mainfrom
marc-merino:knit/use-int4-for-step-id-columns-on-cockroachdb

Conversation

@marc-merino

@marc-merino marc-merino commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Knit Bundle

View bundle

This PR is part of Knit bundle use-int4-for-step-id-columns-on-cockroachdb.

See the other review objects in this bundle:

Bundle id: use-int4-for-step-id-columns-on-cockroachdb
Bundle title: Use INT4 for step-ID columns on CockroachDB

Closes #883

datasource_outputs.step_id was created as INT, which is 4 bytes on Postgres but 8 bytes (INT8) on CockroachDB. Every other step-ID column is INT4, and since the system database is shared across SDKs, a reader that decodes the column as a 32-bit integer fails on CockroachDB.

The Postgres data source migration now creates it as INT4. That is a no-op on Postgres, and existing CockroachDB tables keep INT8 because the statement uses CREATE TABLE IF NOT EXISTS.

The same fix is proposed for the other DBOS SDKs.

Testing

  • Ran the statement on CockroachDB: the column is now INT4 (it was INT8).
  • tests/test_datasource.py passes on Postgres and tests/test_cockroachdb.py on CockroachDB.

@marc-merino marc-merino changed the title Use INT4 for step-ID columns on CockroachDB (py) Use INT4 for datasource_outputs.step_id, so it is 4 bytes on CockroachDB too Oct 8, 2026
devhawk pushed a commit to dbos-inc/dbos-transact-java that referenced this pull request Oct 8, 2026
… too (#611)

<!-- BEGIN KNIT BUNDLE -->
## Knit Bundle

[View
bundle](https://svartal.com/app/bundles/7cae31dc-1e9d-47d8-aaec-6df2ed7e80d0)

This PR is part of Knit bundle
`use-int4-for-step-id-columns-on-cockroachdb`.

See the other review objects in this bundle:
- `py`: dbos-inc/dbos-transact-py#884
- `ts`: dbos-inc/dbos-transact-ts#1403
- `golang`: dbos-inc/dbos-transact-golang#499
- `java`: #611 (this
PR)

Bundle id: `use-int4-for-step-id-columns-on-cockroachdb`
Bundle title: Use INT4 for step-ID columns on CockroachDB
<!-- END KNIT BUNDLE -->

Closes #609

`tx_step_outputs.step_id` was created as `INT`, which is 4 bytes on
Postgres but 8 bytes (`INT8`) on CockroachDB. Every other step-ID column
is `INT4`, and since the system database is shared across SDKs, a reader
that decodes the column as a 32-bit integer fails on CockroachDB.

The `TxStepSchema.createTable` now creates it as `INT4`. That is a no-op
on Postgres, and existing CockroachDB tables keep `INT8` because the
statement uses `CREATE TABLE IF NOT EXISTS`.

The same fix is proposed for the other DBOS SDKs.

## Testing

- Ran the statement on CockroachDB: the column is now `INT4` (it was
`INT8`).
- The `txstep` tests pass.
maxdml pushed a commit to dbos-inc/dbos-transact-golang that referenced this pull request Oct 8, 2026
…on CockroachDB too (#499)

<!-- BEGIN KNIT BUNDLE -->
## Knit Bundle

[View
bundle](https://svartal.com/app/bundles/7cae31dc-1e9d-47d8-aaec-6df2ed7e80d0)

This PR is part of Knit bundle
`use-int4-for-step-id-columns-on-cockroachdb`.

See the other review objects in this bundle:
- `py`: dbos-inc/dbos-transact-py#884
- `ts`: dbos-inc/dbos-transact-ts#1403
- `golang`: #499
(this PR)
- `java`: dbos-inc/dbos-transact-java#611

Bundle id: `use-int4-for-step-id-columns-on-cockroachdb`
Bundle title: Use INT4 for step-ID columns on CockroachDB
<!-- END KNIT BUNDLE -->

Closes #497

`notifications.consumed_by_function_id` was created as `INTEGER`, which
is 4 bytes on Postgres but 8 bytes (`INT8`) on CockroachDB. Every other
step-ID column is `INT4`, and since the system database is shared across
SDKs, a reader that decodes the column as a 32-bit integer fails on
CockroachDB.

The Postgres migration 121 now creates it as `INT4`. That is a no-op on
Postgres, and existing CockroachDB tables keep `INT8` because the
statement uses `ADD COLUMN IF NOT EXISTS`.

The same fix is proposed for the other DBOS SDKs.

## Testing

- Ran the statement on CockroachDB: the column is now `INT4` (it was
`INT8`).
- The migration, recv and rewind tests pass on Postgres and on
CockroachDB.
@maxdml
maxdml merged commit d3f2de7 into dbos-inc:main Oct 9, 2026
11 checks passed
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.

datasource_outputs.step_id is INT, which is INT8 on CockroachDB

2 participants