Skip to content

[Collections] Fix useSearchIndices race #3529

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

Merged
merged 1 commit into from
Jun 5, 2021

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented Jun 4, 2021

Motivation:
rdar://78872613

SQLitePackageCollectionsStorage.useSearchIndices is set in createSchemaIfNecessary, which is invoked only along with a database operation. Since search methods (e.g., searchPackages) check useSearchIndices first thing, it's possible that createSchemaIfNecessary hasn't been called yet and as a result useSearchIndices defaults to false, causing a different code path to get executed.

Modification:
Make sure createSchemaIfNecessary is called before reading useSearchIndices.

Motivation:
rdar://78872613

`SQLitePackageCollectionsStorage.useSearchIndices` is set in `createSchemaIfNecessary`, which is invoked only along with a database operation. Since search methods (e.g., `searchPackages`) check `useSearchIndices` first thing, it's possible that `createSchemaIfNecessary` hasn't been called yet and as a result `useSearchIndices` defaults to `false`, causing a different code path to get executed.

Modification:
Make sure `createSchemaIfNecessary` is called before reading `useSearchIndices`.
@yim-lee
Copy link
Contributor Author

yim-lee commented Jun 4, 2021

@swift-ci please smoke test

@yim-lee
Copy link
Contributor Author

yim-lee commented Jun 4, 2021

@swift-ci please smoke test macOS

@yim-lee
Copy link
Contributor Author

yim-lee commented Jun 4, 2021

CI error seems unrelated:

https://ci.swift.org/job/swift-package-manager-PR-macos-smoke-test/3239/

14:22:04 [423/2208][ 19%][74.388s] /usr/local/bin/sccache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/swift-reflection-dump -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/swift/tools/swift-reflection-dump -Iinclude -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/swift/include -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/llvm-project/llvm/include -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/buildbot_incremental/llvm-macosx-x86_64/include -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/llvm-project/clang/include -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/buildbot_incremental/llvm-macosx-x86_64/tools/clang/include -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/cmark/src -I/Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/buildbot_incremental/cmark-macosx-x86_64/src -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -fdiagnostics-color -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O3  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk  -fno-exceptions -fno-rtti -Werror=gnu -UNDEBUG -target x86_64-apple-macosx10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -arch x86_64 -F/../../../Developer/Library/Frameworks -O2 -g0 -std=c++14 -MD -MT tools/swift-reflection-dump/CMakeFiles/swift-reflection-dump.dir/swift-reflection-dump.cpp.o -MF tools/swift-reflection-dump/CMakeFiles/swift-reflection-dump.dir/swift-reflection-dump.cpp.o.d -o tools/swift-reflection-dump/CMakeFiles/swift-reflection-dump.dir/swift-reflection-dump.cpp.o -c /Users/buildnode/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/swift/tools/swift-reflection-dump/swift-reflection-dump.cpp
14:22:05 ninja: build stopped: subcommand failed.

@yim-lee
Copy link
Contributor Author

yim-lee commented Jun 4, 2021

@swift-ci please smoke test macOS

@yim-lee yim-lee merged commit 62fef21 into swiftlang:main Jun 5, 2021
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Jun 5, 2021
Motivation:
rdar://78872613

`SQLitePackageCollectionsStorage.useSearchIndices` is set in `createSchemaIfNecessary`, which is invoked only along with a database operation. Since search methods (e.g., `searchPackages`) check `useSearchIndices` first thing, it's possible that `createSchemaIfNecessary` hasn't been called yet and as a result `useSearchIndices` defaults to `false`, causing a different code path to get executed.

Modification:
Make sure `createSchemaIfNecessary` is called before reading `useSearchIndices`.
@yim-lee yim-lee deleted the useSearchIndices-race branch June 5, 2021 03:41
yim-lee added a commit that referenced this pull request Jun 7, 2021
Motivation:
rdar://78872613

`SQLitePackageCollectionsStorage.useSearchIndices` is set in `createSchemaIfNecessary`, which is invoked only along with a database operation. Since search methods (e.g., `searchPackages`) check `useSearchIndices` first thing, it's possible that `createSchemaIfNecessary` hasn't been called yet and as a result `useSearchIndices` defaults to `false`, causing a different code path to get executed.

Modification:
Make sure `createSchemaIfNecessary` is called before reading `useSearchIndices`.
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.

3 participants