persistence_connection_suite.go ×6

Frontier kind: Code frontier

unlabeled · c_8b185cde9083

4 tests · 3331 LOC · 165 files · introduces 0 tests · 51 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges51 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
528 ranges3331 lines · 165 files · Browse complete extent
All tests (intent)
4 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

4 files ranked by introduced lines: 51 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/tests/persistence_connection_suite.go 40 introduced LOC · 6 ranges

Open complete file

27 t *testing.T,
28 factory *sql.Factory,
29 > ) *connectionSuite { persistence_connection_suite.go
30 > return &connectionSuite{
31 > Assertions: require.New(t),
32 > factory: factory,
33 > }
34 > }
35
36 > func (s *connectionSuite) SetupSuite() { persistence_connection_suite.go
37 >
38 > }
39
40 > func (s *connectionSuite) TearDownSuite() { persistence_connection_suite.go
41 >
42 > }
43
44 > func (s *connectionSuite) SetupTest() { persistence_connection_suite.go
45 > s.Assertions = require.New(s.T())
46 > }
47
48 > func (s *connectionSuite) TearDownTest() { persistence_connection_suite.go
49 >
50 > }
51
52 // Tests that SQL operations do not panic if the underlying connection has been closed and that the persistence layer
53 // returns a useful error message.
54 // Currently only run against MySQL and Postgresql (SQLite always maintains at least one open connection)
55 > func (s *connectionSuite) TestClosedConnectionError() { persistence_connection_suite.go
56 > ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
57 > defer cancel()
58 >
59 > shardID := (int32)(1)
60 > rangeID := rand.Int63()
61 > shardInfo := RandomShardInfo(shardID, rangeID)
62 >
63 > store, err := s.factory.NewShardStore()
64 > s.NoError(err)
65 >
66 > store.Close() // Connection will be closed by this call
67 > manager := p.NewShardManager(store, serialization.NewSerializer())
68 >
69 > resp, err := manager.GetOrCreateShard(ctx, &p.GetOrCreateShardRequest{
70 > ShardID: shardID,
71 > InitialShardInfo: shardInfo,
72 > })
73 >
74 > s.Nil(resp)
75 > s.ErrorContains(err, sqlplugin.DatabaseUnavailableError.Error())
76 > }
go.temporal.io/server/common/persistence/sql/sqlplugin/db_handle.go 7 introduced LOC · 4 ranges

Open complete file

76 // Don't reconnect if we've been closed
77 if !h.running {
78 > return nil db_handle.go
79 > }
80
81 prevConn := h.db.Load()
149 }
150
151 > if db := h.reconnect(false); db != nil { db_handle.go
152 return db
153 }
154 > return invalidConn{} db_handle.go
155 }
156
181 }
182
183 > func (invalidConn) GetContext(ctx context.Context, dest any, query string, args ...any) error { db_handle.go
184 > return DatabaseUnavailableError
185 > }
186
187 func (invalidConn) SelectContext(ctx context.Context, dest any, query string, args ...any) error {
go.temporal.io/server/common/persistence/shard_manager.go 2 introduced LOC · 1 range

Open complete file

57 })
58 if err != nil {
59 > return nil, err shard_manager.go
60 > }
61 shardInfo, err := m.serializer.ShardInfoFromBlob(internalResp.ShardInfo)
62 if err != nil {
go.temporal.io/server/common/persistence/sql/shard.go 2 introduced LOC · 1 range

Open complete file

48 }, nil
49 case sql.ErrNoRows:
50 > default: shard.go
51 > return nil, serviceerror.NewUnavailablef("GetOrCreateShard: failed to get ShardID %v. Error: %v", request.ShardID, err)
52 }
53