NBXplorer error - duplicate key value violates unique constraint
See original GitHub issueThis morning, our BTCPayServer runninon MyNodeBtc gets stuck on block 762359
We are running NBX v2.3.44 (nicolasdorier/nbxplorer:2.3.44) and BtcPay 1.6.12
Here is the error
fail: NBXplorer.Indexer.BTC: Unhandled exception in the indexer, retrying in 10 seconds
Npgsql.PostgresException (0x80004005): 23505: duplicate key value violates unique constraint "nbxv1_evts_pkey"
Relevant log part of Btc pay
2022-11-09 03:14:03.965 +00:00 [INF] DelayedTransactionBroadcasterHostedService successfully exited...
2022-11-09 03:14:03.965 +00:00 [INF] TorServices successfully exited...
2022-11-09 03:14:03.966 +00:00 [INF] CheckConfigurationHostedService successfully exited...
2022-11-09 03:14:03.967 +00:00 [ERR] Error while connecting to WebSocket of NBXplorer (BTC)
System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
at System.Net.WebSockets.ManagedWebSocket.ThrowIfEOFUnexpected(Boolean throwOnPrematureClosure)
at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken, Boolean throwOnPrematureClosure)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location ---
at NBXplorer.WebsocketMessageListener.NextMessageAsync(CancellationToken cancellation)
at BTCPayServer.Payments.Bitcoin.NBXplorerListener.Listen(BTCPayWallet wallet) in /source/BTCPayServer/Payments/Bitcoin/NBXplorerListener.cs:line 142
2022-11-09 03:14:03.968 +00:00 [INF] Disconnected from WebSocket of NBXplorer (BTC)
2022-11-09 03:14:03.973 +00:00 [INF] PullPaymentHostedService successfully exited...
2022-11-09 03:14:03.974 +00:00 [INF] NBXplorerListener successfully exited...
2022-11-09 03:14:03.975 +00:00 [INF] LightningListener successfully exited...
2022-11-09 03:14:03.975 +00:00 [INF] LightningPendingPayoutListener successfully exited...
2022-11-09 03:14:03.981 +00:00 [INF] Stop watching invoices
2022-11-09 03:14:03.988 +00:00 [INF] RatesHostedService successfully exited...
2022-11-09 03:14:03.994 +00:00 [INF] DynamicDnsHostedService successfully exited...
2022-11-09 03:14:03.997 +00:00 [INF] NewVersionCheckerHostedService successfully exited...
2022-11-09 03:14:03.997 +00:00 [INF] DbMigrationsHostedService successfully exited...
2022-11-09 03:14:04.000 +00:00 [INF] LightningAutomatedPayoutProcessor successfully exited...
2022-11-09 03:14:12.862 +00:00 [INF] Root Path: /
2022-11-09 03:14:13.448 +00:00 [INF] Connection to NBXplorer's database successful, dashboard and reporting features activated.
Issue Analytics
- State:
- Created 10 months ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
postgresql duplicate key violates unique constraint
The "duplicate key" error is telling you that the work was not done because it would produce a duplicate key, not that it...
Read more >duplicate key value violates unique constraint · netbox- ...
Hello,. I am attempting to upgrade from version 2.8.3 (the ldap variant) to 2.10.5 (-ldap). I built the system in Docker.
Read more >Duplicate key value violates a unique constraint
It seems many people have had this problem, but I'm somewhat new to Postgres and tried other solutions with no luck. I have...
Read more >01070710:3: Database error (0), ERROR: duplicate key ...
already exists. This message occurs when the following conditions are met: The mcpd binary database has been removed.
Read more >Duplicate key value violates unique constraint ...
The tieserver.log records the following user error repeatedly: Duplicate key value violates unique constraint "file_name_new_pkey" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have frankly no idea why your problem would happen. But there is a single point in the case where we could have inserted the wrong value in this column. You are the only one I ever saw with this problem so I guess probably bad luck.
I am still pushing this new commit on NBXplorer, https://github.com/dgarage/NBXplorer/commit/07323f16ea330b92600d3b53f1759c7c66d6fcac if the bug is somewhere, it was there, even if I don’t know why.
@tehelsper if it ever happen again, let me know, I never saw that happening, and I don’t see any way somebody could have triggered that even on purpose.
update nbxv1_evts_ids set curr_id=
from @PraiaBitcoin is the right workaround.@PraiaBitcoin did this bug happened after a btcpay update? 10000 appears suspiciously in the configuration I use for NBX on docker deployments.