diff options
author | Jeff Layton <jlayton@primarydata.com> | 2014-09-19 11:00:03 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2014-09-19 11:16:16 -0400 |
commit | 3548dd1563d5893ba6dce6eb44652b6d56fa065f (patch) | |
tree | 8d141a5bf84220e558049857d9b06f6d64ee9fd5 /support/export/export.c | |
parent | 7e63dda9eb4e1da4890b8d893717cf748580e3e6 (diff) | |
download | nfs-utils-3548dd1563d5893ba6dce6eb44652b6d56fa065f.tar.gz nfs-utils-3548dd1563d5893ba6dce6eb44652b6d56fa065f.tar.xz nfs-utils-3548dd1563d5893ba6dce6eb44652b6d56fa065f.zip |
nfsdcltrack: overhaul database initializtion
We have some possibility for races with nfsdcltrack when the DB schema
is upgraded.
Suppose we update the nfs-utils package on a machine after the DB has
been initialized. With the current scheme of initializing the DB only
during the "init" phase, we could end up with a new program that expects
a new schema with an old database.
We could try to do a one-time update when the package is installed, but
that could be racy. We could get an upcall between when the program is
installed and when we run the update. Also, relying on packaging to get
that right is tricky at best. To fix this, change how the database
initialization and checking of the schema revision works.
On every upcall, attempt to open the db as we normally would. If that
fails, then try to create the directory if it doesn't exist and then
retry the open. If it fails again, then give up.
If we get a successful open, then query the DB for the schema version.
If it matches what we expect, then declare success and move on. If the
query fails then assume that the DB isn't set up yet. Start an exclusive
transaction, check the schema version again and then set up the DB if no
one raced in to create it in the meantime.
This should only add a tiny bit of overhead on most upcalls (just an
extra select of the parameters table), and should improve the
performance of the "init" upcall. It'll also make it possible to handle
DB schema changes sanely.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support/export/export.c')
0 files changed, 0 insertions, 0 deletions