br0xen / boltbrowser

A CLI Browser for BoltDB Files
GNU General Public License v3.0
631 stars 91 forks source link

Locked databases #17

Closed xyproto closed 5 years ago

xyproto commented 7 years ago

Hi,

First of all, thanks for creating boltbrowser, it's the shit. :+1:

When creating a database with algernon, with the following command:

algernon -t --boltdb test.db . :7777

And then closing the web server by typing exit or pressing ctrl-d, accessing the database with boltbrowser works fine:

boltbrowser test.db

Adding keys and values (on the Algernon Lua prompt) and then examining them in boltbrowser (after exiting the webserver) also works great:

kv = KeyValue("pageviews")
kv:set("counter", 9999)

However, if accessing the database while the web server is running, there is no error message and no timeout and the console interface just goes into black and hangs (can't be closed with esc, q or ctrl-c), until the web server has quit and released the lock on the database.

This is a feature request for adding a timeout and/or a way to exit boltbrowser when the database is locked. Ignoring the database lock and entering some sort of read-only mode would also be interesting, if possible.

Cheers, Alexander F Rødseth

br0xen commented 7 years ago

I'm glad you like it! I went ahead and added a new issue to timeout and allow exiting boltbrowser if the database is locked (with the 'hacktoberfest' tag, even, so maybe someone else will issue a pull request).

As for opening the DB in a read-only mode, I'm going to have to do some research into that and see what I can come up with.

Thanks!

br0xen commented 5 years ago

This issue has been resolved for a while, I just forgot to close it.

xyproto commented 5 years ago

When trying the steps to reproduce the issue, the terminal still hangs, but there is this output:

���������������������������������

This is with konsole and TERM=konsole-256color.

Neither ctrl-c nor ctrl-\ quits the program.

When setting TERM=vt100, boltbrowser still hangs, but I get this output:

$<50>

I used this command to build and install boltbrowser:

go get -u github.com/br0xen/boltbrowser

Using Go 1.11, on 64-bit Arch Linux.

br0xen commented 5 years ago

Does it still work if the web server isn't running? Or are you getting garbage on the display regardless of if the DB is locked?

br0xen commented 5 years ago

By the way, people have generally had more luck with boltbrowser using a console type of xterm-256color, though in my testing (with konsole) konsole-256color works fine too, so I'm not sure why you were getting some garbled output up there.

I tested a locked database with the newest commit and, by default, it'll timeout trying to connect after a second.