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

panic: Unable to flush sub store: pq: duplicate key value violates unique constraint "pk_msgpendingkey" #741

Closed
LafonteFull opened this issue Feb 7, 2019 · 7 comments · Fixed by #828

Comments

@LafonteFull
Copy link

LafonteFull commented Feb 7, 2019

Got this error yesterday and today, and it's fixed after deleting the table contents by myself.

panic: Unable to flush sub store: pq: duplicate key value violates unique constraint "pk_msgpendingkey"
goroutine 22 [running]:
github.com/nats-io/nats-streaming-server/server.(*StanServer).ioLoop(0xc0001e6000, 0xc000146630)
    /home/admin/nats/src/github.com/nats-io/nats-streaming-server/server/server.go:3782 +0xb4d
created by github.com/nats-io/nats-streaming-server/server.(*StanServer).startIOLoop
    /home/admin/nats/src/github.com/nats-io/nats-streaming-server/server/server.go:3611 +0xcc

Version :
version | 1.3.0
proto | 1
go | go1.11.4
Postgres : 10 on AWS RDS

@kozlovic
Copy link
Member

kozlovic commented Feb 7, 2019

You did not actually print the NATS Streaming version. Could you please let me know which one is it?

@kozlovic
Copy link
Member

kozlovic commented Feb 7, 2019

Also, you would not point 2 (or more) NATS Streaming server to the same database by any chance?

@kozlovic
Copy link
Member

kozlovic commented Mar 9, 2019

Any news on that? Closing for now, will re-open if you provide some updates.

@kozlovic kozlovic closed this as completed Mar 9, 2019
@TipDev
Copy link

TipDev commented Apr 17, 2019

I also have the same problem.

Unable to flush sub store: pq: duplicate key value violates unique constraint" pk_msgpendingkey "

nats-streaming-server version 0.11.2, nats-server version 1.3.0
postgres 10.7

I configure a fail-tolerance cluster (2 nats-streaming servers) that run from one database(postgres sql-store).
I assume on that when the current leader becomes unavailable, stand by will capture the storlock in postgres and be promoted to leader.

@TipDev
Copy link

TipDev commented Apr 17, 2019

@kozlovic, please re-open this issue

@kozlovic kozlovic reopened this Apr 17, 2019
kozlovic added a commit that referenced this issue May 9, 2019
Issue was due to the fact that we were not keeping track of the
maximum row number, so if a subscription that are pending state
saved in row 1 and 3 and the last recovered subscription had
state in row 2, and then the next update was for the first subscription
the SQL statement would have tried to add a row with ID 3 which
already existed.

Resolves #741

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
@kozlovic
Copy link
Member

kozlovic commented May 9, 2019

@LafonteFull @TipDev Sorry for the delay in getting back to you. I finally figure out what the problem was. I have pushed a PR if you want to try it out PR #828

@TipDev
Copy link

TipDev commented Jul 31, 2019

@kozlovic Sorry for the delay. This is grate news! Thank you!

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 a pull request may close this issue.

3 participants