Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump cache sqlite dbs to v2 for WAL journal mode change #24030

Merged
merged 6 commits into from
May 29, 2024

Conversation

dsherret
Copy link
Member

In #23955 we changed the sqlite db journal mode to WAL. This causes issues when someone is running an old version of Deno using TRUNCATE and a new version because the two fight against each other.

@dsherret dsherret enabled auto-merge (squash) May 29, 2024 13:35
@dsherret dsherret disabled auto-merge May 29, 2024 13:48
use super::cache_db::CacheFailure;
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_runtime::deno_webstorage::rusqlite::params;

pub static TYPE_CHECK_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration {
table_initializer: concat!(
"CREATE TABLE IF NOT EXISTS checkcache (
check_hash TEXT PRIMARY KEY
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now stored as integers.

@@ -28,40 +28,19 @@ WHERE
LIMIT 1";

pub static MODULE_INFO_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration {
table_initializer: "CREATE TABLE IF NOT EXISTS moduleinfocache (
specifier TEXT PRIMARY KEY,
media_type TEXT NOT NULL,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now an integer.

@@ -3,16 +3,17 @@
use std::hash::Hasher;

/// A very fast insecure hasher that uses the xxHash algorithm.
#[derive(Default)]
Copy link
Member Author

@dsherret dsherret May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now forces someone to decide whether to include the deno version in the hash or not.

.query_row(query, params![key.as_u64().to_string()], |row| {
let res = self.conn.query_row(
query,
params![CacheDBHash::new(key.as_u64())],
Copy link
Member Author

@dsherret dsherret May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened denoland/deno_graph#491 to make the hash have the deno_graph version in it.

Edit: Included that here

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM again

cli/cache/emit.rs Outdated Show resolved Hide resolved
@dsherret dsherret enabled auto-merge (squash) May 29, 2024 17:40
@dsherret dsherret merged commit 94f040a into denoland:main May 29, 2024
17 checks passed
@dsherret dsherret deleted the fix_bump_db_versions_v2 branch May 29, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants