Skip to content

Funding channel causes crash due to "UNIQUE constraint failed: peers.node_id" #1029

Closed
@sadilek

Description

@sadilek

I connected to a node and opened a channel:

$ lightning-cli listpeers | grep 0333b58f86a0c31da7ee61a4bc2232faccf8c4fe4167fe0dd9ce019fe03e82faac
<empty, not connected to this node yet>
$ lightning-cli connect 0333b58f86a0c31da7ee61a4bc2232faccf8c4fe4167fe0dd9ce019fe03e82faac 52.215.249.189 9735
{ "id" : "0333b58f86a0c31da7ee61a4bc2232faccf8c4fe4167fe0dd9ce019fe03e82faac" }
$ lightning-cli fundchannel 0333b58f86a0c31da7ee61a4bc2232faccf8c4fe4167fe0dd9ce019fe03e82faac 50000
lightning-cli: reading response: Success

Lightningd crashed:

2018-02-18T23:43:21.033Z lightningd(17531): 0333b58f86a0c31da7ee61a4bc2232faccf8c4fe4167fe0dd9ce019fe03e82faac chan #0: State changed from UNINITIALIZED to OPENINGD
wallet_channel_save: UNIQUE constraint failed: peers.node_id
2018-02-18T23:43:21.040Z lightningd(17531): wallet_channel_save: UNIQUE constraint failed: peers.node_id
Log dumped in crash.log
2018-02-18T23:43:21.849Z lightningd(17531): FATAL SIGNAL 6 RECEIVED
2018-02-18T23:43:21.861Z lightningd(17531): backtrace: lightningd/log.c:498 (log_crash) 0x411f92
2018-02-18T23:43:21.861Z lightningd(17531): backtrace: (null):0 ((null)) 0x7f351c4694af
2018-02-18T23:43:21.861Z lightningd(17531): backtrace: (null):0 ((null)) 0x7f351c469428
2018-02-18T23:43:21.861Z lightningd(17531): backtrace: (null):0 ((null)) 0x7f351c46b029
2018-02-18T23:43:21.861Z lightningd(17531): backtrace: lightningd/log.c:587 (fatal) 0x4123cc
2018-02-18T23:43:21.862Z lightningd(17531): backtrace: wallet/db.c:217 (db_exec_prepared_) 0x44e5dc
2018-02-18T23:43:21.862Z lightningd(17531): backtrace: wallet/wallet.c:800 (wallet_channel_save) 0x4535d3
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: lightningd/peer_control.c:2415 (peer_offer_channel) 0x420902
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: lightningd/peer_control.c:2492 (gossip_peer_released) 0x420d73
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: lightningd/subd.c:306 (sd_msg_reply) 0x4269e0
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: lightningd/subd.c:454 (sd_msg_read) 0x426fc5
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: lightningd/subd.c:327 (read_fds) 0x426add
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: ccan/ccan/io/io.c:59 (next_plan) 0x45e440
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: ccan/ccan/io/io.c:387 (do_plan) 0x45ef17
2018-02-18T23:43:21.863Z lightningd(17531): backtrace: ccan/ccan/io/io.c:397 (io_ready) 0x45ef55
2018-02-18T23:43:21.864Z lightningd(17531): backtrace: ccan/ccan/io/poll.c:310 (io_loop) 0x460824
2018-02-18T23:43:21.864Z lightningd(17531): backtrace: lightningd/lightningd.c:378 (main) 0x4106e6
2018-02-18T23:43:21.864Z lightningd(17531): backtrace: (null):0 ((null)) 0x7f351c45482f
2018-02-18T23:43:21.864Z lightningd(17531): backtrace: (null):0 ((null)) 0x4032d8
2018-02-18T23:43:21.864Z lightningd(17531): backtrace: (null):0 ((null)) 0xffffffffffffffff
Fatal signal 6. 0x412078 log_crash
        lightningd/log.c:524
0x7f351c4694af ???
        ???:0
0x7f351c469428 ???
        ???:0
0x7f351c46b029 ???
        ???:0
0x4123cc fatal
        lightningd/log.c:587
0x44e5dc db_exec_prepared_
        wallet/db.c:217
0x4535d3 wallet_channel_save
        wallet/wallet.c:800
0x420902 peer_offer_channel
        lightningd/peer_control.c:2415
0x420d73 gossip_peer_released
        lightningd/peer_control.c:2492
0x4269e0 sd_msg_reply
        lightningd/subd.c:306
0x426fc5 sd_msg_read
        lightningd/subd.c:454
0x426add read_fds
        lightningd/subd.c:327
0x45e440 next_plan
        ccan/ccan/io/io.c:59
0x45ef17 do_plan
        ccan/ccan/io/io.c:387
0x45ef55 io_ready
        ccan/ccan/io/io.c:397
0x460824 io_loop
        ccan/ccan/io/poll.c:310
0x4106e6 main
        lightningd/lightningd.c:378
0x7f351c45482f ???
        ???:0
0x4032d8 ???

By the time of the crash, my node was fully caught up. After the restart, it's now catching up again:

$ lightning-cli getinfo
{ "id" : "036487e0bd981617c674c2856fc0050472a0182838e0a4a1a67545c6cdee9f49a0", "port" : 9735, "address" : 
	[ 
		{ "type" : "ipv4", "address" : "81.6.40.158", "port" : 9735 } ], "version" : "v0.5.2-2016-11-21-1990-gb2819f9", "blockheight" : 507142, "network" : "bitcoin" }

I might have been connected to this node in the past. I happen to have a copy of the sqllite DB from before the crash.

$ sqlite3 /tmp/lightningd.sqlite3 
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
sqlite> select id, hex(node_id), address from peers where hex(node_id) like "0333%";
102|0333B58F86A0C31DA7EE61A4BC2232FACCF8C4FE4167FE0DD9CE019FE03E82FAAC|52.215.249.189:9735

So despite listpeers not listing the node, it's still in the peers table. There is no channel referencing it though:
sqlite> select id, state from channels where hex(peer_id) like "0333%";

I can reproduce this, so let me know if you need more info.

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