Releases a SessionState entry for the specified sessionId */
| 114 | |
| 115 | /* Releases a SessionState entry for the specified sessionId */ |
| 116 | static void |
| 117 | ReleaseSessionState(int sessionId) |
| 118 | { |
| 119 | /* We call shutdown twice */ |
| 120 | will_be_called_count(LWLockAcquire, 2); |
| 121 | will_be_called_count(LWLockRelease, 2); |
| 122 | |
| 123 | expect_any_count(LWLockAcquire, lock, 2); |
| 124 | expect_any_count(LWLockAcquire, mode, 2); |
| 125 | expect_any_count(LWLockRelease, lock, 2); |
| 126 | |
| 127 | gp_session_id = sessionId; |
| 128 | /* First find the previously allocated session state */ |
| 129 | SessionState *foundSessionState = AcquireSessionState(sessionId, gp_sessionstate_loglevel); |
| 130 | |
| 131 | assert_true(foundSessionState->sessionId == sessionId); |
| 132 | /* |
| 133 | * It was pre-allocated and we incremented the pinCount |
| 134 | * for finding it |
| 135 | */ |
| 136 | assert_true(foundSessionState->pinCount > 1); |
| 137 | /* Satisfy assertion */ |
| 138 | sessionStateInited = true; |
| 139 | EXPECT_EREPORT(gp_sessionstate_loglevel); |
| 140 | /* Undo for our search pinCount */ |
| 141 | SessionState_Shutdown(); |
| 142 | /* The pinCount should not drop to 0 as we just undid our own increment */ |
| 143 | assert_true(foundSessionState->pinCount >= 1); |
| 144 | MySessionState = foundSessionState; |
| 145 | sessionStateInited = true; |
| 146 | /* |
| 147 | * If we are releasing this SessionState permanently, we need to ensure |
| 148 | * that RunawayCleaner_RunawayCleanupDoneForSession() will be called |
| 149 | */ |
| 150 | if (foundSessionState->pinCount == 1) |
| 151 | { |
| 152 | will_be_called(RunawayCleaner_RunawayCleanupDoneForSession); |
| 153 | } |
| 154 | |
| 155 | EXPECT_EREPORT(gp_sessionstate_loglevel); |
| 156 | /* Undo one more to truly undo previously acquired one */ |
| 157 | SessionState_Shutdown(); |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * Checks if SessionState_ShmemInit does nothing under postmaster. |
no test coverage detected