WIP: Hold the proper locks while examining the list of databases.

Introduce a new lock called specMu lock to protect the cluster spec.
This lock is held on update and sync, and when retrieving the spec in
the API code. There is no need to acquire it for cluster creation and
deletion: creation assigns the spec to the cluster before linking it to
the controller, and deletion just removes the cluster from the list in
the controller, both holding the global clustersMu Lock.
This commit is contained in:
Oleksii Kliukin
2017-12-22 13:06:11 +01:00
parent 011458fb05
commit 9720ac1f7e
5 changed files with 49 additions and 9 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ func (c *Cluster) Sync(newSpec *spec.Postgresql) (err error) {
c.mu.Lock()
defer c.mu.Unlock()
c.Postgresql = *newSpec
c.setSpec(newSpec)
defer func() {
if err != nil {