Pg:which_groups/0 fail

Why does pg:which_groups() fail with bad_arg when no groups exist?

Minimal example:

Eshell V13.0  (abort with ^G)
1> pg:which_groups().
** exception error: bad argument
     in function  ets:match/2
        called as ets:match(pg,{'$1','_','_'})
        *** argument 1: the table identifier does not refer to an existing ETS table
     in call from pg:which_groups/1 (pg.erl, line 186)

Why this call does not return []? :thinking:

1 Like
1> pg:start_link().
2> pg:which_groups().

yeah, so there aren’t any groups started by erts? What is the difference between pg groups and process groups used by erts?

1 Like
start_link() -> {ok, pid()} | {error, any()}

Starts the default pg scope within supervision tree. Kernel may be configured  to  do  it  automatically, see kernel(6) configuration manual.
1 Like

I know that I must start pg scope, but I’m asking why… I’m asking for a difference between pg groups and groups used by erts because that confuses me… Even if pg is not started, you can ask for group_leader for your process which handles your IO. So what is the difference between those groups and is there any documentation on this subject?

1 Like

There is no specific reason, it’s just my oversight.
I agree that the error makes no sense, essentially leaking internal implementation (ETS used to speed up/make more concurrent access). Correct error should be something like “scope is not started”. Thanks for reporting, let me some time to fix it.