Add ability to skip shared lock acquisition
This commit is contained in:
1 parent
cb8a541b02
commit
16c9e9b592
3 files changed
+25
-15
No files matched your search
@@ -100,6 +100,10 @@ func NewListener(l *listenerutil.ListenerConfig, ui cli.Ui) (net.Listener, map[s
|
||||
return ln, props, nil, nil
|
||||
}
|
||||
|
||||
if l.TLSCertFile == "" {
|
||||
return nil, nil, nil, fmt.Errorf("tls not disabled for listener at address %q with purpose %q but no certificate file supplied", finalAddr, purpose)
|
||||
}
|
||||
|
||||
// Don't request a client cert unless they've explicitly configured it to do
|
||||
// so
|
||||
if !l.TLSRequireAndVerifyClientCert {
|
||||
|
||||
@@ -438,22 +438,24 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error(fmt.Errorf("Can't get schema manager: %w.", err).Error())
|
||||
return base.CommandCliError
|
||||
}
|
||||
// This is an advisory locks on the DB which is released when the db session ends.
|
||||
if err := sMan.SharedLock(c.Context); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Unable to gain shared access to the database: %w", err).Error())
|
||||
return base.CommandCliError
|
||||
}
|
||||
defer func() {
|
||||
// The base context has already been canceled so we shouldn't use it here.
|
||||
// 1 second is chosen so the shutdown is still responsive and this is a mostly
|
||||
// non critical step since the lock should be released when the session with the
|
||||
// database is closed.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
if err := sMan.SharedUnlock(ctx); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Unable to release shared lock to the database: %w", err).Error())
|
||||
if !c.Config.Controller.Database.SkipSharedLockAcquisition {
|
||||
// This is an advisory lock on the DB which is released when the db session ends.
|
||||
if err := sMan.SharedLock(c.Context); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Unable to gain shared access to the database: %w", err).Error())
|
||||
return base.CommandCliError
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
// The base context has already been canceled so we shouldn't use it here.
|
||||
// 1 second is chosen so the shutdown is still responsive and this is a mostly
|
||||
// non critical step since the lock should be released when the session with the
|
||||
// database is closed.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
if err := sMan.SharedUnlock(ctx); err != nil {
|
||||
c.UI.Error(fmt.Errorf("Unable to release shared lock to the database: %w", err).Error())
|
||||
}
|
||||
}()
|
||||
}
|
||||
ckState, err := sMan.CurrentState(c.Context)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error checking schema state: %w", err).Error())
|
||||
|
||||
@@ -228,6 +228,10 @@ type Database struct {
|
||||
MaxIdleConnectionsRaw interface{} `hcl:"max_idle_connections"`
|
||||
ConnMaxIdleTime interface{} `hcl:"max_idle_time"`
|
||||
ConnMaxIdleTimeDuration *time.Duration `hcl:"-"`
|
||||
|
||||
// SkipSharedLockAcquisition allows skipping grabbing the database shared
|
||||
// lock. This is dangerous unless you know what you're doing.
|
||||
SkipSharedLockAcquisition bool `hcl:"skip_shared_lock_acquisition"`
|
||||
}
|
||||
|
||||
type Plugins struct {
|
||||
|
||||
Reference in new issue
Block a user