Postgres: TIMESTAMP WITHOUT TIME ZONE + java.sql.Timestamp stores JVM-local time; mixed-TZ fleets/DST corrupt ordering, lag, purge
Mantenedores costumam responder em até 1 dia
Um pull request relacionado já foi integrado.
- #145 de @rawo — integrado
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start with PostgresOutboxStore, which binds created_at, updated_at and last_attempt with setTimestamp and reads them back with getTimestamp, and with the Postgres schema changesets that declare these columns as TIMESTAMP. Add a migration that converts the columns to timestamptz, then switch the store to OffsetDateTime binding and reading. Done when a test passes with a non-UTC TimeZone.setDefault and the migration path for existing users is documented.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Severity: Medium · Area: okapi-postgres schema and JDBC mapping · Found in: code review of main @ e5630a1 (reasoned from pgjdbc semantics, not reproduced)
Problem
The Postgres schema declares created_at, updated_at and last_attempt as TIMESTAMP (without time zone). PostgresOutboxStore writes them with setTimestamp(Timestamp.from(instant)) and reads them with getTimestamp(...).toInstant(). pgjdbc renders a java.sql.Timestamp in the JVM default time zone, so the column stores local wall-clock time of whichever JVM wrote the row:
- Mixed-TZ fleets (e.g. one pod with
TZ=Europe/Warsaw, others UTC, or a developer laptop pointed at a shared DB):ORDER BY created_atis skewed by hours- the lag gauge (
okapi.entries.lag.seconds) is off by hours, possibly negative - the purger's
last_attempt < cutoffdeletesDELIVEREDrows hours early or keeps them hours late
- DST fall-back in a non-UTC zone: an hour of local times repeats, so two different instants map to the same stored value. Ordering and lag are wrong for that hour, and reading back can shift values by 1 h.
MySQL TIMESTAMP(6) normalizes to UTC, so this mainly affects Postgres.
Suggested fix
Migrate the columns to TIMESTAMPTZ (changeset 002 with ALTER COLUMN ... TYPE timestamptz USING ... AT TIME ZONE '<zone that wrote the data>', documented for existing users). Bind with setObject(i, instant.atOffset(ZoneOffset.UTC)) and read with getObject(col, OffsetDateTime::class.java). Add a test that runs the store with a non-UTC TimeZone.setDefault.
- Linguagem predominante
- Kotlin
- Estrelas
- 14
- Forks
- 0
- Merge médio
- 14h 16min
- PRs com merge (30d)
- 9
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de softwaremill/okapi
-
bug
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
softwaremill/okapi#141 ·
Mantenedores costumam responder em até 1 dia
-
OutboxProcessorListener events are emitted before the transaction commits; metrics over-count on commit failureTalvez já em andamento @rawo assumiu há 1 dia. Abertabreaking-change bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
softwaremill/okapi#137 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 42/100
softwaremill/okapi#136 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 3/5 Meio dia Facilidade para iniciantes 62/100
softwaremill/okapi#134 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 22/100
softwaremill/okapi#133 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de softwaremill/okapi
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 2 dias
-
unconfirmed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
thunderbird/thunderbird-android#11893 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 65/100
Droid-Deck/DroidDeck#2198 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
world-federation-of-advertisers/cross-media-measurement#4846 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia