-
Notifications
You must be signed in to change notification settings - Fork 283
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: pq: duplicate key value violates unique constraint "pk_msgkey" #1048
Comments
Sorry about the trouble. |
No problem, at the moment its okay as we prepare the next rollout phase, so we learn a lot these days. |
To be clear, you are saying that you run in FT mode. FT is different from clustering. Are you saying that "leader" here is the active server and it failed so a standby took over?
You understand that it all depends on usage. I can't give you any number.
In FT mode, when the active server is stopped and the standby becomes active, it has to recover the store, which depending on the size and disk speed, can take a bit of time. So again, it all depends your usage, and if you can afford "downtime" during the day. |
Yes, I meant active server, the standby took over. |
Checking on this issue: if the standby has taken over, it should get the last sequence from the channel and there should not be duplicate key issues. It almost look like the active was writing say 100, 101 and 102, but when the standby becomes active, it gets from the DB that the last is 100 (as if 101 and 102 was not yet visible in the DB), then those 101 and 102 are committed while the standby-now-active tries to store the next message as 101. First, the standby should not be able to become active if the active is still running (because of FT heartbeats and storelock table being updated). Second, we use DB transactions, so say active writes messages 101 and 102 and crashes, then transaction would be rolledback. |
Hi,
we are currently facing an error related to the message store on Postgres:
[1] 2020/05/20 21:54:44.186034 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.189513 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.193846 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.197352 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.200989 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.205274 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.209437 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.214883 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.218560 [ERR] STREAM: [Client:NatsConnector2fcc937df-d4b0-44e3-8139-95a98ee668b6] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey" [1] 2020/05/20 21:54:44.387503 [ERR] STREAM: [Client:NatsConnectorDPSWSF_AObd2b11e8-5555-4056-ba5e-763b5f8750df] Error processing message for subject "_STAN.pub.nats_cluster.dps.eu.machine.actualvaluesv01": sql: error executing "INSERT INTO Messages VALUES ($1, $2, $3, $4, $5)": pq: duplicate key value violates unique constraint "pk_msgkey"
The shown subject is the most used subject with approx. 7,5 Mio messages stored in the messages table. At the moment we have 3,5 Messages per second. Our NATS-Streaming instance is running in an AKS Cluster with 2-core nodes, using 95% cpu and approx. 770 MB memory.
The text was updated successfully, but these errors were encountered: