Skip to content

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

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

devhawk 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 #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.

@devhawk

devhawk commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @marc-merino!

@devhawk
devhawk merged commit 85b3f0e into dbos-inc:main Oct 8, 2026
12 checks passed
@marc-merino

marc-merino commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

You're welcome, @devhawk :) I DM'd you on Discord about these PR's, would really appreciate it if you had a look. Cheers

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.
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.

tx_step_outputs.step_id is INT, which is INT8 on CockroachDB

2 participants