Fork me on GitHub
#datalevin
<
2023-08-06
>
Garrett Hopper01:08:21

Trying to use Flow Storm to do some debugging, however I keep getting this stacktrace. Seems to be caused by Flow Storm calling pprint on some Datalevin internals?

Garrett Hopper01:08:36

clojure.lang.ExceptionInfo: Fail to get-value: No implementation of method: :put-key of protocol: #'datalevin.lmdb/IBuffer found for class: nil {:dbi "datalevin/meta", :k :last-modified, :k-type :attr, :v-type :long}
Not sure where the nil is coming from though

Garrett Hopper01:08:19

Where does rtx come from for this get-value function? Oh, the scan macro :thinking_face:

Huahai01:08:21

Do you get this without using flow storm?

Garrett Hopper01:08:56

I did not, no. I've only been able to produce with Flow Storm.

Garrett Hopper01:08:02

https://github.com/juji-io/datalevin/blob/master/src/datalevin/db.cljc#L278 (`:last-modified (s/last-modified store)` in print-method defmethod print-method DB`)

Garrett Hopper01:08:27

Assuming this is expected to work when run later by Flow Storm? Does it need to be within a transaction or something?

Huahai01:08:37

Db is not supposed to be printed, this is for debugging only

Garrett Hopper01:08:42

I think there's an implicit assumption (by Flow Storm, and likely by others) that print-method can be called on any variable at any time.

Huahai02:08:10

Most of the objects are not supposed to be printed by users

Garrett Hopper02:08:32

I don't know that that's a stance Flow Storm would agree with. I'd assume the expectation is that an opaque string with minimal information is printed instead of throwing an error.

Garrett Hopper02:08:02

It definitely makes sense that printing may not be useful or contain much information, but I think it should be fixed to not thrown an error when printed at the wrong time.

Garrett Hopper02:08:33

Admittedly Flow Storm should also be catching this error when printing a var fails. 🤷

Garrett Hopper02:08:58

(And seemingly does catch similar errors sometimes. :thinking_face:)

Huahai02:08:25

These internal objects are all stateful

Garrett Hopper02:08:39

Totally understand; again, I don't think they should print anything useful that contains that stateful data, but I do think they should print an opaque string. (Even just removing the print-method would use the default Clojure behavior which does this, and I think would be preferable.)

Garrett Hopper02:08:02

Not sure what that default behavior looks like on a DB though. 👀

Huahai02:08:16

The error you saw is due to the fact that it tries to print a db that has not been initialized yet,

Garrett Hopper02:08:00

datalevin.db.DB@9dfe7f52

Garrett Hopper02:08:18

Gotcha; what would it take to fix?

Huahai02:08:45

We can of course be defensive in the print method, you can file an issue

Garrett Hopper02:08:18

👍 Thanks 🙂 Will try to get a PR together

Garrett Hopper02:08:09

Tried bypassing (remove-method print-method datalevin.db.DB), and I'm just getting a different stacktrace from Flow Storm, so I think I'm going to punt on this issue for now. 🙂 https://clojurians.slack.com/archives/C03KZ3XT0CF/p1691286079910589

Garrett Hopper02:08:18

Thanks for reading anyways!