@@ -18,6 +18,23 @@ export enum OverlayDatabaseMode {
18
18
19
19
export const CODEQL_OVERLAY_MINIMUM_VERSION = "2.22.3" ;
20
20
21
+ /**
22
+ * The maximum (uncompressed) size of the overlay base database that we will
23
+ * upload. Actions Cache has an overall capacity of 10 GB, and the Actions Cache
24
+ * client library uses zstd compression.
25
+ *
26
+ * Ideally we would apply a size limit to the compressed overlay-base database,
27
+ * but we cannot do so because compression is handled transparently by the
28
+ * Actions Cache client library. Instead we place a limit on the uncompressed
29
+ * size of the overlay-base database.
30
+ *
31
+ * Assuming 2.5:1 compression ratio, the 6 GB limit on uncompressed data would
32
+ * translate to a limit of around 2.4 GB after compression.
33
+ */
34
+ const OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_MB = 6000 ;
35
+ const OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_BYTES =
36
+ OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_MB * 1_000_000 ;
37
+
21
38
/**
22
39
* Writes a JSON file containing Git OIDs for all tracked files (represented
23
40
* by path relative to the source root) under the source root. The file is
@@ -212,6 +229,26 @@ export async function uploadOverlayBaseDatabaseToCache(
212
229
} ) ;
213
230
214
231
const dbLocation = config . dbLocation ;
232
+
233
+ const databaseSizeBytes = await tryGetFolderBytes ( dbLocation , logger ) ;
234
+ if ( databaseSizeBytes === undefined ) {
235
+ logger . warning (
236
+ "Failed to determine database size. " +
237
+ "Skip uploading overlay-base database to cache." ,
238
+ ) ;
239
+ return false ;
240
+ }
241
+
242
+ if ( databaseSizeBytes > OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_BYTES ) {
243
+ const databaseSizeMB = Math . round ( databaseSizeBytes / 1_000_000 ) ;
244
+ logger . warning (
245
+ `Database size (${ databaseSizeMB } MB) ` +
246
+ `exceeds maximum upload size (${ OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_MB } MB). ` +
247
+ "Skip uploading overlay-base database to cache." ,
248
+ ) ;
249
+ return false ;
250
+ }
251
+
215
252
const codeQlVersion = ( await codeql . getVersion ( ) ) . version ;
216
253
const checkoutPath = getRequiredInput ( "checkout_path" ) ;
217
254
const cacheKey = await generateCacheKey ( config , codeQlVersion , checkoutPath ) ;
0 commit comments