Skip to content

Commit eacf49e

Browse files
committed
upgrades,systemschema: add new column for login time to system.users
- adds an 'estimated_last_login_time' column with the `TIMESTAMPTZ` type. This new column will be used to store the last login timestamp of authenticating users to the database. We plan to populate this asynchronously and with absence of retry mechanisms inorder to reduce latency for performing a single login attempt which could result in updation of the column frequently. This work will be taken up subsequently. - validated the system.users table post migration on local cluster ``` root@localhost:26257/defaultdb> select * from system.users; username | hashedPassword | isRole | user_id | estimated_last_login_time -----------+----------------+--------+---------+---------------------------- admin | \x | t | 2 | NULL root | \x | f | 1 | NULL (2 rows) Time: 3ms total (execution 2ms / network 1ms) ``` informs #147602 fixes #147600 Epic: CRDB-21590 Release note: None
1 parent 32b9329 commit eacf49e

30 files changed

+268
-58
lines changed

docs/generated/settings/settings-for-tenants.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,4 @@ trace.zipkin.collector string the address of a Zipkin instance to receive trace
417417
ui.database_locality_metadata.enabled boolean true if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute application
418418
ui.default_timezone string the default timezone used to format timestamps in the ui application
419419
ui.display_timezone enumeration etc/utc the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the 'ui.default_timezone' setting instead. 'ui.default_timezone' takes precedence over this setting. [etc/utc = 0, america/new_york = 1] application
420-
version version 1000025.2-upgrading-to-1000025.3-step-004 set the active cluster version in the format '<major>.<minor>' application
420+
version version 1000025.2-upgrading-to-1000025.3-step-006 set the active cluster version in the format '<major>.<minor>' application

docs/generated/settings/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,6 @@
375375
<tr><td><div id="setting-ui-database-locality-metadata-enabled" class="anchored"><code>ui.database_locality_metadata.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
376376
<tr><td><div id="setting-ui-default-timezone" class="anchored"><code>ui.default_timezone</code></div></td><td>string</td><td><code></code></td><td>the default timezone used to format timestamps in the ui</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
377377
<tr><td><div id="setting-ui-display-timezone" class="anchored"><code>ui.display_timezone</code></div></td><td>enumeration</td><td><code>etc/utc</code></td><td>the timezone used to format timestamps in the ui. This setting is deprecatedand will be removed in a future version. Use the &#39;ui.default_timezone&#39; setting instead. &#39;ui.default_timezone&#39; takes precedence over this setting. [etc/utc = 0, america/new_york = 1]</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
378-
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.2-upgrading-to-1000025.3-step-004</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
378+
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000025.2-upgrading-to-1000025.3-step-006</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
379379
</tbody>
380380
</table>

pkg/backup/full_cluster_backup_restore_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,28 +1190,28 @@ func TestFullClusterRestoreWithUserIDs(t *testing.T) {
11901190
sqlDB.Exec(t, `BACKUP INTO $1`, localFoo)
11911191

11921192
sqlDB.CheckQueryResults(t, `SELECT * FROM system.users ORDER BY user_id`, [][]string{
1193-
{"root", "", "false", "1"},
1194-
{"admin", "", "true", "2"},
1195-
{"test1", "NULL", "false", "100"},
1196-
{"test2", "NULL", "false", "101"},
1193+
{"root", "", "false", "1", "NULL"},
1194+
{"admin", "", "true", "2", "NULL"},
1195+
{"test1", "NULL", "false", "100", "NULL"},
1196+
{"test2", "NULL", "false", "101", "NULL"},
11971197
})
11981198
// Ensure that the new backup succeeds.
11991199
sqlDBRestore.Exec(t, `RESTORE FROM LATEST IN $1`, localFoo)
12001200

12011201
sqlDBRestore.CheckQueryResults(t, `SELECT * FROM system.users ORDER BY user_id`, [][]string{
1202-
{"root", "", "false", "1"},
1203-
{"admin", "", "true", "2"},
1204-
{"test1", "NULL", "false", "100"},
1205-
{"test2", "NULL", "false", "101"},
1202+
{"root", "", "false", "1", "NULL"},
1203+
{"admin", "", "true", "2", "NULL"},
1204+
{"test1", "NULL", "false", "100", "NULL"},
1205+
{"test2", "NULL", "false", "101", "NULL"},
12061206
})
12071207

12081208
sqlDBRestore.Exec(t, `CREATE USER test3`)
12091209

12101210
sqlDBRestore.CheckQueryResults(t, `SELECT * FROM system.users ORDER BY user_id`, [][]string{
1211-
{"root", "", "false", "1"},
1212-
{"admin", "", "true", "2"},
1213-
{"test1", "NULL", "false", "100"},
1214-
{"test2", "NULL", "false", "101"},
1215-
{"test3", "NULL", "false", "102"},
1211+
{"root", "", "false", "1", "NULL"},
1212+
{"admin", "", "true", "2", "NULL"},
1213+
{"test1", "NULL", "false", "100", "NULL"},
1214+
{"test2", "NULL", "false", "101", "NULL"},
1215+
{"test3", "NULL", "false", "102", "NULL"},
12161216
})
12171217
}

pkg/cli/doctor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestDoctorCluster(t *testing.T) {
157157
"CREATE TABLE to_drop (id INT)",
158158
"DROP TABLE to_drop",
159159
"CREATE TABLE foo (id INT)",
160-
"INSERT INTO system.users VALUES ('node', NULL, true, 3)",
160+
"INSERT INTO system.users VALUES ('node', NULL, true, 3, NULL)",
161161
"GRANT node TO root",
162162
"DELETE FROM system.namespace WHERE name = 'foo'",
163163
"SELECT pg_catalog.pg_sleep(1)",
@@ -222,7 +222,7 @@ func TestDoctorClusterDropped(t *testing.T) {
222222
c.RunWithArgs([]string{"sql", "-e", strings.Join([]string{
223223
"CREATE TABLE foo (i INT)",
224224
desc,
225-
"INSERT INTO system.users VALUES ('node', NULL, true, 3)",
225+
"INSERT INTO system.users VALUES ('node', NULL, true, 3, NULL)",
226226
"GRANT node TO root",
227227
"DELETE FROM system.namespace WHERE name = 'foo'",
228228
"SELECT pg_catalog.pg_sleep(1)",

pkg/clusterversion/cockroach_versions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ const (
216216

217217
V25_3_AddEventLogColumnAndIndex
218218

219+
V25_3_AddEstimatedLastLoginTime
219220
// *************************************************
220221
// Step (1) Add new versions above this comment.
221222
// Do not add new versions to a patch release.
@@ -272,6 +273,8 @@ var versionTable = [numKeys]roachpb.Version{
272273

273274
V25_3_AddEventLogColumnAndIndex: {Major: 25, Minor: 2, Internal: 4},
274275

276+
V25_3_AddEstimatedLastLoginTime: {Major: 25, Minor: 2, Internal: 6},
277+
275278
// *************************************************
276279
// Step (2): Add new versions above this comment.
277280
// Do not add new versions to a patch release.

0 commit comments

Comments
 (0)