Skip to content

Commit 11b716d

Browse files
committed
bugfix: load and usage schema data race
We need to block shards to avoid schema usage by concurrent requests. Now it can be a ping request or a watch request so it does not look critical. We don't expect many of this requests and such requests do not use schema at all. Part of #218
1 parent de7e60b commit 11b716d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

connection.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,9 @@ func (conn *Connection) OverrideSchema(s *Schema) {
13681368
if s != nil {
13691369
conn.mutex.Lock()
13701370
defer conn.mutex.Unlock()
1371+
conn.lockShards()
1372+
defer conn.unlockShards()
1373+
13711374
conn.Schema = s
13721375
}
13731376
}

schema.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ func (conn *Connection) loadSchema() (err error) {
329329
schema.SpacesById[index.SpaceId].Indexes[index.Name] = index
330330
}
331331

332+
conn.lockShards()
332333
conn.Schema = schema
334+
conn.unlockShards()
335+
333336
return nil
334337
}
335338

0 commit comments

Comments
 (0)