Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error writing null sequence_offset to JPA read_side_offsets #3251

Open
raboof opened this issue Jun 7, 2021 · 0 comments
Open

Error writing null sequence_offset to JPA read_side_offsets #3251

raboof opened this issue Jun 7, 2021 · 0 comments

Comments

@raboof
Copy link
Contributor

raboof commented Jun 7, 2021

When using cassandra as the write side and JPA as the read side, offsets will be time_uuid offsets rather than sequence offsets, so we will write null into the sequence_offset of the read side offsets table. However, when using postgres, the null value appears to be incorrectly converted, reporting a type conversion error for the sequence_offset column: Expected bigint, actual bytea:

In com.lightbend.lagom.internal.javadsl.persistence.jpa.JpaReadSideImpl.postgresqlBindUpdateOffsetQuery:

Statement:

update "read_side_offsets" set "sequence_offset"=?,"time_uuid_offset"=? where "read_side_id"=? and "tag"=?;
insert into "read_side_offsets" ("read_side_id","tag","sequence_offset","time_uuid_offset") select ?,?,?,? where not exists (select 1 from "read_side_offsets" where "read_side_id"=? and "tag"=?)

Parameters:

{1=null, 2=3e921930-c2ea-11eb-b3a8-6bd0db76f94f, 3=return-receipt-query-offset, 4=ReceiptEvent, 5=return-receipt-query-offset, 6=ReceiptEvent, 7=null, 8=3e921930-c2ea-11eb-b3a8-6bd0db76f94f, 9=return-receipt-query-offset, 10=ReceiptEvent}

Since the sequence_offset will always be null when reading from cassandra, a workaround is to create the table with a sequence_offset column of type bytea:

CREATE TABLE read_side_offsets (
  read_side_id VARCHAR(255), tag VARCHAR(255),
  sequence_offset bytea, time_uuid_offset char(36),
  PRIMARY KEY (read_side_id, tag)
)

This is possibly similar to #1772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant