After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641768 - dconf gsettings backend silently drops writes if it can't talk to dbus
dconf gsettings backend silently drops writes if it can't talk to dbus
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-02-07 19:35 UTC by Dan Winship
Modified: 2011-08-16 18:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gsettings-tool: warn if setting a value fails (1.39 KB, patch)
2011-03-11 03:10 UTC, Dan Winship
rejected Details | Review
gsettings-tool: warn if setting a value fails (1.38 KB, patch)
2011-06-06 19:04 UTC, Dan Winship
reviewed Details | Review

Description Dan Winship 2011-02-07 19:35:20 UTC
If the dconf gsettings backend can't connect to the session bus, it just fails silently.

Eg, if you run the gsettings tool from a vt, then it won't be able to find a running bus, and it won't be able to launch a new bus (because apparently dbus-launch requires X to be running). But it doesn't give any error, it just pretends to have set the key.
Comment 1 Allison Karlitskaya (desrt) 2011-02-07 21:51:53 UTC
Would a g_warning() on failure to connect to D-Bus be good enough?
Comment 2 Dan Winship 2011-02-07 22:56:35 UTC
Well... it would be better than what's there now. But there are probably other situations where the app may want to know, programmatically, that things are failing.
Comment 3 Allison Karlitskaya (desrt) 2011-02-08 01:31:29 UTC
I intentionally left that ability out since I've noticed that applications tend to check error codes if one is available via the API -- and in this case, it's better that they do not (since we would get about 100 weird/broken copy-pasted implementations of popping up a Gtk error dialog about the problem).  Most applications can not (and should not) meaningfully notify the user about something that is almost certainly an installation/distribution error.

That said, some other out-of-band notification could be extremely helpful here.  The annoying irony, however, is that I imagine most such out-of-band notifications would use D-Bus in some way or another...

Do you have a better suggestion about how this could be handled in the general (ie: not commandline) case for normal apps?
Comment 4 Dan Winship 2011-02-08 03:14:54 UTC
If GSettingsBackend had an equivalent of g_vfs_is_active(), then the dconf backend could recuse itself if there wasn't already a session bus running, and then you'd get a memory backend, with associated g_warning. And even if you didn't see the warning, it might still be (more) obvious that something's wrong, since you'd get the default values for everything.
Comment 5 Allison Karlitskaya (desrt) 2011-02-08 03:56:02 UTC
Interesting.

We could just have the dconf backend fail to register itself if it can't get on DBus.

The problem with that, of course, is that it requires attempting to connect to D-Bus...

We could check for an environment variable and, if set, assume that D-Bus is present.

It also begs another question: by the same logic, don't we want to attempt to guard against cases where the dconf service can't be started for one reason or another?  We can't really do that...

Also: dconf is perfectly fine to use without the session bus -- you just can't write.  Should we really remove your ability to read your settings just because D-Bus can't be contacted?

One more thing: I'm not sure it's possible to have a global 'is dconf available' function since it's possible to configure a dconf profile such that it doesn't require access to the session bus (ie: only system-level databases in use).
Comment 6 Dan Winship 2011-02-08 13:43:49 UTC
How about just having the gsettings tool do a get() after it does the sync(), and if the value wasn't updated, print an error and exit(1).
Comment 7 Dan Winship 2011-03-11 03:10:51 UTC
Created attachment 183115 [details] [review]
gsettings-tool: warn if setting a value fails

warning: breaks string freeze...
Comment 8 Dan Winship 2011-04-09 16:54:48 UTC
Attachment 183115 [details] pushed as ea57fef - gsettings-tool: warn if setting a value fails
Comment 9 Dan Winship 2011-04-09 16:56:06 UTC
oops, I didn't actually mean to commit this. So... uh... revert it if you don't like it. :-)
Comment 10 Ray Strode [halfline] 2011-05-23 17:44:32 UTC
(In reply to comment #9)
> oops, I didn't actually mean to commit this. So... uh... revert it if you don't
> like it. :-)

You wish is my command:

http://git.gnome.org/browse/glib/commit/?id=eabad1923e7b0f133f8f38e57601a97521e38cfe

attachment 183115 [details] [review] makes gsettings fail any time the user tries to set a key to the same value it already has.

This breaks gdm dist-check among other things.

Maybe the backend should keep a state variable "in_read_only_mode" if they couldn't get on the bus or something and post a g_warning() if the state variable is true and some write is attempted?
Comment 11 Dan Winship 2011-06-06 19:04:31 UTC
Created attachment 189352 [details] [review]
gsettings-tool: warn if setting a value fails

change the check to "if (!g_variant_equal (stored, new))" rather
than "if (g_variant_equal (stored, existing))"
Comment 12 Ray Strode [halfline] 2011-06-06 21:28:16 UTC
Review of attachment 189352 [details] [review]:

This seems more reasonable, but will cause spurious messages in sort of pathological cases (think multiple gsettings calls in parallel)

Any reason not to track the dbus case specifically in the backend?
Comment 13 Allison Karlitskaya (desrt) 2011-08-15 14:12:16 UTC
I'm just going to g_warning() from the dconf backend when a write fails for any reason.  This should only be in "your install is broken" type of cases anyway...
Comment 14 Allison Karlitskaya (desrt) 2011-08-15 14:39:06 UTC
Okay.  Now you get something like this:


$ gsettings set org.gnome.shell.clock show-date true
 
** (process:4548): WARNING **: Command line `dbus-launch --autolaunch=63d8da7f109ce322e1d478de00000008 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n



or this:


$ gsettings set org.gnome.shell.clock show-date true
 
** (process:4507): WARNING **: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files

which seems pretty reasonable to me.