Skip to content

Error writing null sequence_offset to JPA read_side_offsets #3251

Open
@raboof

Description

@raboof

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions