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

SQLite queries return stale table metadata after alter operation #529

Open
2 tasks done
JaniruTEC opened this issue Apr 10, 2024 · 0 comments
Open
2 tasks done

SQLite queries return stale table metadata after alter operation #529

JaniruTEC opened this issue Apr 10, 2024 · 0 comments
Labels
type:bug Something isn't working

Comments

@JaniruTEC
Copy link
Contributor

JaniruTEC commented Apr 10, 2024

Please agree to the following

Summary

In rare cases queries to a recently changed table will return stale table metadata (e.g. column names). This might cause difficult to diagnose bugs during database migration. So far this issue hasn't been reported in production, but was encountered during development on #506.

System Setup

...

Cloud Type

No response

Steps to Reproduce

...

Expected Behavior

...

Actual Behavior

...

Reproducibility

Always

Relevant Log Output

No response

Anything else?

Related bug on the google issue tracker: 153521693

@JaniruTEC JaniruTEC added the type:bug Something isn't working label Apr 10, 2024
@JaniruTEC JaniruTEC changed the title SQLite queries return stale table metadata after update SQLite queries return stale table metadata after alter operation Apr 10, 2024
JaniruTEC added a commit that referenced this issue Apr 10, 2024
UpgradeDatabaseTest.kt:816 and UpgradeDatabaseTest.kt:895 caused the tests to fail because of issue #529 [1]. Consequently they have been commented out until the issue is resolved.

[1] #529
JaniruTEC added a commit that referenced this issue Apr 10, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 10, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Room is designed to choose the journal mode itself if none is specified.
greenDAO's journal mode ("TRUNCATE") will stay for now because the journal mode has influence on the behavior caused by issue #529 [1] and because changing the journal mode complicates the migration further.
This can still be changed later.

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Replaced particular implementation of "fix" with call to freshly introduced, user-supplied mapping function (and added "RandomUUIDSQLMappingFunction" as new mapping function with that particular implementation)
Replaced "fixCompile" with direct instantiation of "CacheControlledSupportSQLiteStatement"
Updated static elements to be inner members of "CacheControlledSupportSQLiteDatabase" (and removed now unnecessary properties)
Changed computation logic of "sql" property in "CacheControlledSupportSQLiteQuery"

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Renamed package "org.cryptomator.data.db.cachecontrol" to "org.cryptomator.data.db.sqlmapping"
Renamed "CacheControlledSupportSQLiteDatabase.kt" to "MappingSupportSQLiteDatabase.kt"
Moved contents to new location

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Renamed class "CacheControlledSupportSQLiteDatabase" to "MappingSupportSQLiteDatabase"
Renamed class "CacheControlledSupportSQLiteOpenHelper" to "MappingSupportSQLiteOpenHelper"
Renamed class "CacheControlledSupportSQLiteOpenHelperFactory" to "MappingSupportSQLiteOpenHelperFactory"
Renamed inner class "CacheControlledSupportSQLiteStatement" to "MappingSupportSQLiteStatement"
Renamed inner class "CacheControlledSupportSQLiteQuery" to "MappingSupportSQLiteQuery"
Renamed method "fix" to "map" in "MappingSupportSQLiteDatabase"
Renamed method "fixWhereClause" to "mapWhereClause" in "MappingSupportSQLiteDatabase"
Renamed property "identifiers" to "mappedQueries" in "MappingSupportSQLiteQuery"
Renamed extension method "SupportSQLiteOpenHelper.Factory.asCacheControlled" to "SupportSQLiteOpenHelper.Factory.asMapped" in "MappingSupportSQLiteDatabase.kt"

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Moved "RandomUUIDSQLMappingFunction" from "MappingSupportSQLiteDatabase.kt" to new file "SQLiteCacheControl.kt"
Added extension function "SupportSQLiteOpenHelper.Factory.asCacheControlled" in "SQLiteCacheControl.kt" as wrapper for "asMapped" with "RandomUUIDSQLMappingFunction" as mapping function
Removed "RandomUUIDSQLMappingFunction" as default mapping function from extension function "SupportSQLiteOpenHelper.Factory.asMapped" in "MappingSupportSQLiteDatabase.kt"
Replaced call to "asMapped" with call to "asCacheControlled" in "DatabaseModule"

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
JaniruTEC added a commit that referenced this issue Apr 13, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
See: c13b12f

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Calling "requery" on a cursor may cause the driver to re-use queries, which is unwanted behavior.

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
JaniruTEC added a commit that referenced this issue Apr 13, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
Also moved compat method for "ContentValues.isEmpty"

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 13, 2024
*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 21, 2024
This also makes the class compatible with "MappingSupportSQLiteDatabase"

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 21, 2024
This also makes the test method compatible with "MappingSupportSQLiteDatabase"
Also added "assertIsUUID"

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 21, 2024
See: b3449f0
Also See: c13b12f

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 22, 2024
JaniruTEC added a commit that referenced this issue Apr 22, 2024
JaniruTEC added a commit that referenced this issue Apr 22, 2024
Added "ValueExtractor<T>" as type alias for "(T) -> Any?"
Changed argument declarations of "pseudo equality" methods and underlying implementations
Added "ValueExtractor<T>" as type declaration for existing value extractor sets

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 22, 2024
Also added workaround for tests

*This commit is related to issue #529 [1]*

[1] #529
JaniruTEC added a commit that referenced this issue Apr 22, 2024
Changed "insert" to directly compile the mapped sql instead of creating a "MappingSupportSQLiteStatement"
Added check if the database is open to "compileStatement"

*This commit is related to issue #529 [1]*

[1] #529
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant