foundationdb/fdbserver/masterserver.actor.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

720 lines
27 KiB
C++
Raw Normal View History

2017-05-26 04:48:44 +08:00
/*
* masterserver.actor.cpp
*
* This source file is part of the FoundationDB open source project
*
2022-03-22 04:36:23 +08:00
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
*
2017-05-26 04:48:44 +08:00
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
2017-05-26 04:48:44 +08:00
* http://www.apache.org/licenses/LICENSE-2.0
*
2017-05-26 04:48:44 +08:00
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Add fdbcli command to read/write version epoch (#6480) * Initialize cluster version at wall-clock time Previously, new clusters would begin at version 0. After this change, clusters will initialize at a version matching wall-clock time. Instead of using the Unix epoch (or Windows epoch), FDB clusters will use a new epoch, defaulting to January 1, 2010, 01:00:00+00:00. In the future, this base epoch will be modifiable through fdbcli, allowing administrators to advance the cluster version. Basing the version off of time allows different FDB clusters to share data without running into version issues. * Send version epoch to master * Cleanup * Update fdbserver/storageserver.actor.cpp Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com> * Jump directly to expected version if possible * Fix initial version issue on storage servers * Add random recovery offset to start version in simulation * Type fixes * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Use correct recoveryTransactionVersion when recovering * Allow version epoch to be adjusted forwards (to decrease the version) * Set version epoch in simulation * Add quiet database check to ensure small version offset * Fix initial version issue on storage servers * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Add fdbcli command to read/write version epoch * Cause recovery when version epoch is set * Handle optional version epoch key * Add ability to clear the version epoch This causes version advancement to revert to the old methodology whereas versions attempt to advance by about a million versions per second, instead of trying to match the clock. * Update transaction access * Modify version epoch to use microseconds instead of seconds * Modify fdbcli version target API Move commands from `versionepoch` to `targetversion` top level command. * Add fdbcli tests for * Temporarily disable targetversion cli tests * Fix version epoch fetch issue * Fix Arena issue * Reduce max version jump in simulation to 1,000,000 * Rework fdbcli API It now requires two commands to fully switch a cluster to using the version epoch. First, enable the version epoch with `versionepoch enable` or `versionepoch set <versionepoch>`. At this point, versions will be given out at a faster or slower rate in an attempt to reach the expected version. Then, run `versionepoch commit` to perform a one time jump to the expected version. This is essentially irreversible. * Temporarily disable old targetversion tests * Cleanup * Move version epoch buggify to sequencer This will cause some issues with the QuietDatabase check for the version offset - namely, it won't do anything, since the version epoch is not being written to the txnStateStore in simulation. This will get fixed in the future. Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2022-04-09 03:33:19 +08:00
#include <algorithm>
#include <iterator>
#include "fdbrpc/sim_validation.h"
#include "fdbserver/CoordinatedState.h"
2017-05-26 04:48:44 +08:00
#include "fdbserver/CoordinationInterface.h" // copy constructors for ServerCoordinators class
#include "fdbserver/Knobs.h"
#include "fdbserver/MasterInterface.h"
#include "fdbserver/ResolutionBalancer.actor.h"
#include "fdbserver/ServerDBInfo.h"
#include "flow/ActorCollection.h"
#include "flow/Trace.h"
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#include "flow/swift_support.h"
2021-06-30 02:58:59 +08:00
#include "fdbclient/VersionVector.h"
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#include "fdbserver/MasterData.actor.h"
#ifdef WITH_SWIFT
#include "SwiftModules/FDBServer"
#endif
#include "flow/actorcompiler.h" // This must be the last #include.
2017-05-26 04:48:44 +08:00
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
// Instantiate MasterInterface related templates
template class ReplyPromise<MasterInterface>;
template struct NetSAV<MasterInterface>;
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
// Instantiate ServerDBInfo related templates
template class GetEncryptCipherKeys<struct ServerDBInfo>;
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
void updateLiveCommittedVersion(Reference<MasterData> self, ReportRawCommittedVersionRequest req);
2017-05-26 04:48:44 +08:00
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
Version figureVersionCxx(Version current,
double now,
Version reference,
int64_t toAdd,
double maxVersionRateModifier,
int64_t maxVersionRateOffset) {
// Versions should roughly follow wall-clock time, based on the
// system clock of the current machine and an FDB-specific epoch.
// Calculate the expected version and determine whether we need to
// hand out versions faster or slower to stay in sync with the
// clock.
Version expected = now * SERVER_KNOBS->VERSIONS_PER_SECOND - reference;
// Attempt to jump directly to the expected version. But make
// sure that versions are still being handed out at a rate
// around VERSIONS_PER_SECOND. This rate is scaled depending on
// how far off the calculated version is from the expected
// version.
int64_t maxOffset = std::min(static_cast<int64_t>(toAdd * maxVersionRateModifier), maxVersionRateOffset);
return std::clamp(expected, current + toAdd - maxOffset, current + toAdd + maxOffset);
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
Version figureVersion(Version current,
double now,
Version reference,
int64_t toAdd,
double maxVersionRateModifier,
int64_t maxVersionRateOffset) {
auto impl = SERVER_KNOBS->FLOW_WITH_SWIFT ? fdbserver_swift::figureVersion : figureVersionCxx;
return impl(current, now, reference, toAdd, maxVersionRateModifier, maxVersionRateOffset);
}
#else
Version figureVersion(Version current,
double now,
Version reference,
int64_t toAdd,
double maxVersionRateModifier,
int64_t maxVersionRateOffset) {
return figureVersionCxx(current, now, reference, toAdd, maxVersionRateModifier, maxVersionRateOffset);
}
#endif
#ifdef WITH_SWIFT
SWIFT_ACTOR Future<Void> waitForPrev(Reference<MasterData> self, ReportRawCommittedVersionRequest req) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
auto future = self->swiftImpl->waitForPrev(self.getPtr(), req);
wait(future);
} else {
state double startTime = now();
wait(self->liveCommittedVersion.whenAtLeast(req.prevVersion.get()));
double latency = now() - startTime;
self->waitForPrevLatencies.addMeasurement(latency);
++self->waitForPrevCommitRequests;
updateLiveCommittedVersion(self, req);
req.reply.send(Void());
}
return Void();
}
#else
ACTOR Future<Void> waitForPrev(Reference<MasterData> self, ReportRawCommittedVersionRequest req) {
state double startTime = now();
wait(self->liveCommittedVersion.whenAtLeast(req.prevVersion.get()));
double latency = now() - startTime;
self->waitForPrevLatencies.addMeasurement(latency);
++self->waitForPrevCommitRequests;
updateLiveCommittedVersion(self, req);
req.reply.send(Void());
return Void();
}
#endif
#ifdef WITH_SWIFT
SWIFT_ACTOR Future<Void> getVersionSwift(Reference<MasterData> self, GetCommitVersionRequest req) {
auto future = self->swiftImpl->getVersion(self.getPtr(), req);
wait(future);
return Void();
}
#endif
ACTOR Future<Void> getVersionCxx(Reference<MasterData> self, GetCommitVersionRequest req) {
state Span span("M:getVersion"_loc, req.spanContext);
state std::map<UID, CommitProxyVersionReplies>::iterator proxyItr =
self->lastCommitProxyVersionReplies.find(req.requestingProxy); // lastCommitProxyVersionReplies never changes
2017-05-26 04:48:44 +08:00
2021-04-07 13:13:15 +08:00
++self->getCommitVersionRequests;
if (proxyItr == self->lastCommitProxyVersionReplies.end()) {
2017-05-26 04:48:44 +08:00
// Request from invalid proxy (e.g. from duplicate recruitment request)
req.reply.send(Never());
return Void();
}
2022-09-26 06:28:32 +08:00
CODE_PROBE(proxyItr->second.latestRequestNum.get() < req.requestNum - 1,
"Commit version request queued up",
probe::decoration::rare);
wait(proxyItr->second.latestRequestNum.whenAtLeast(req.requestNum - 1));
2017-05-26 04:48:44 +08:00
auto itr = proxyItr->second.replies.find(req.requestNum);
if (itr != proxyItr->second.replies.end()) {
CODE_PROBE(true, "Duplicate request for sequence");
2017-05-26 04:48:44 +08:00
req.reply.send(itr->second);
} else if (req.requestNum <= proxyItr->second.latestRequestNum.get()) {
CODE_PROBE(true,
2022-09-26 06:28:32 +08:00
"Old request for previously acknowledged sequence - may be impossible with current FlowTransport",
probe::decoration::rare);
2017-05-26 04:48:44 +08:00
ASSERT(req.requestNum <
proxyItr->second.latestRequestNum.get()); // The latest request can never be acknowledged
req.reply.send(Never());
} else {
GetCommitVersionReply rep;
if (self->version == invalidVersion) {
self->lastVersionTime = now();
self->version = self->recoveryTransactionVersion;
rep.prevVersion = self->lastEpochEnd;
2017-05-26 04:48:44 +08:00
} else {
double t1 = now();
if (BUGGIFY) {
t1 = self->lastVersionTime;
}
Add fdbcli command to read/write version epoch (#6480) * Initialize cluster version at wall-clock time Previously, new clusters would begin at version 0. After this change, clusters will initialize at a version matching wall-clock time. Instead of using the Unix epoch (or Windows epoch), FDB clusters will use a new epoch, defaulting to January 1, 2010, 01:00:00+00:00. In the future, this base epoch will be modifiable through fdbcli, allowing administrators to advance the cluster version. Basing the version off of time allows different FDB clusters to share data without running into version issues. * Send version epoch to master * Cleanup * Update fdbserver/storageserver.actor.cpp Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com> * Jump directly to expected version if possible * Fix initial version issue on storage servers * Add random recovery offset to start version in simulation * Type fixes * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Use correct recoveryTransactionVersion when recovering * Allow version epoch to be adjusted forwards (to decrease the version) * Set version epoch in simulation * Add quiet database check to ensure small version offset * Fix initial version issue on storage servers * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Add fdbcli command to read/write version epoch * Cause recovery when version epoch is set * Handle optional version epoch key * Add ability to clear the version epoch This causes version advancement to revert to the old methodology whereas versions attempt to advance by about a million versions per second, instead of trying to match the clock. * Update transaction access * Modify version epoch to use microseconds instead of seconds * Modify fdbcli version target API Move commands from `versionepoch` to `targetversion` top level command. * Add fdbcli tests for * Temporarily disable targetversion cli tests * Fix version epoch fetch issue * Fix Arena issue * Reduce max version jump in simulation to 1,000,000 * Rework fdbcli API It now requires two commands to fully switch a cluster to using the version epoch. First, enable the version epoch with `versionepoch enable` or `versionepoch set <versionepoch>`. At this point, versions will be given out at a faster or slower rate in an attempt to reach the expected version. Then, run `versionepoch commit` to perform a one time jump to the expected version. This is essentially irreversible. * Temporarily disable old targetversion tests * Cleanup * Move version epoch buggify to sequencer This will cause some issues with the QuietDatabase check for the version offset - namely, it won't do anything, since the version epoch is not being written to the txnStateStore in simulation. This will get fixed in the future. Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2022-04-09 03:33:19 +08:00
Version toAdd =
std::max<Version>(1,
std::min<Version>(SERVER_KNOBS->MAX_READ_TRANSACTION_LIFE_VERSIONS,
SERVER_KNOBS->VERSIONS_PER_SECOND * (t1 - self->lastVersionTime)));
Add fdbcli command to read/write version epoch (#6480) * Initialize cluster version at wall-clock time Previously, new clusters would begin at version 0. After this change, clusters will initialize at a version matching wall-clock time. Instead of using the Unix epoch (or Windows epoch), FDB clusters will use a new epoch, defaulting to January 1, 2010, 01:00:00+00:00. In the future, this base epoch will be modifiable through fdbcli, allowing administrators to advance the cluster version. Basing the version off of time allows different FDB clusters to share data without running into version issues. * Send version epoch to master * Cleanup * Update fdbserver/storageserver.actor.cpp Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com> * Jump directly to expected version if possible * Fix initial version issue on storage servers * Add random recovery offset to start version in simulation * Type fixes * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Use correct recoveryTransactionVersion when recovering * Allow version epoch to be adjusted forwards (to decrease the version) * Set version epoch in simulation * Add quiet database check to ensure small version offset * Fix initial version issue on storage servers * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Add fdbcli command to read/write version epoch * Cause recovery when version epoch is set * Handle optional version epoch key * Add ability to clear the version epoch This causes version advancement to revert to the old methodology whereas versions attempt to advance by about a million versions per second, instead of trying to match the clock. * Update transaction access * Modify version epoch to use microseconds instead of seconds * Modify fdbcli version target API Move commands from `versionepoch` to `targetversion` top level command. * Add fdbcli tests for * Temporarily disable targetversion cli tests * Fix version epoch fetch issue * Fix Arena issue * Reduce max version jump in simulation to 1,000,000 * Rework fdbcli API It now requires two commands to fully switch a cluster to using the version epoch. First, enable the version epoch with `versionepoch enable` or `versionepoch set <versionepoch>`. At this point, versions will be given out at a faster or slower rate in an attempt to reach the expected version. Then, run `versionepoch commit` to perform a one time jump to the expected version. This is essentially irreversible. * Temporarily disable old targetversion tests * Cleanup * Move version epoch buggify to sequencer This will cause some issues with the QuietDatabase check for the version offset - namely, it won't do anything, since the version epoch is not being written to the txnStateStore in simulation. This will get fixed in the future. Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2022-04-09 03:33:19 +08:00
rep.prevVersion = self->version;
if (self->referenceVersion.present()) {
self->version = figureVersion(self->version,
g_network->timer(),
self->referenceVersion.get(),
toAdd,
SERVER_KNOBS->MAX_VERSION_RATE_MODIFIER,
SERVER_KNOBS->MAX_VERSION_RATE_OFFSET);
Add fdbcli command to read/write version epoch (#6480) * Initialize cluster version at wall-clock time Previously, new clusters would begin at version 0. After this change, clusters will initialize at a version matching wall-clock time. Instead of using the Unix epoch (or Windows epoch), FDB clusters will use a new epoch, defaulting to January 1, 2010, 01:00:00+00:00. In the future, this base epoch will be modifiable through fdbcli, allowing administrators to advance the cluster version. Basing the version off of time allows different FDB clusters to share data without running into version issues. * Send version epoch to master * Cleanup * Update fdbserver/storageserver.actor.cpp Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com> * Jump directly to expected version if possible * Fix initial version issue on storage servers * Add random recovery offset to start version in simulation * Type fixes * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Use correct recoveryTransactionVersion when recovering * Allow version epoch to be adjusted forwards (to decrease the version) * Set version epoch in simulation * Add quiet database check to ensure small version offset * Fix initial version issue on storage servers * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Add fdbcli command to read/write version epoch * Cause recovery when version epoch is set * Handle optional version epoch key * Add ability to clear the version epoch This causes version advancement to revert to the old methodology whereas versions attempt to advance by about a million versions per second, instead of trying to match the clock. * Update transaction access * Modify version epoch to use microseconds instead of seconds * Modify fdbcli version target API Move commands from `versionepoch` to `targetversion` top level command. * Add fdbcli tests for * Temporarily disable targetversion cli tests * Fix version epoch fetch issue * Fix Arena issue * Reduce max version jump in simulation to 1,000,000 * Rework fdbcli API It now requires two commands to fully switch a cluster to using the version epoch. First, enable the version epoch with `versionepoch enable` or `versionepoch set <versionepoch>`. At this point, versions will be given out at a faster or slower rate in an attempt to reach the expected version. Then, run `versionepoch commit` to perform a one time jump to the expected version. This is essentially irreversible. * Temporarily disable old targetversion tests * Cleanup * Move version epoch buggify to sequencer This will cause some issues with the QuietDatabase check for the version offset - namely, it won't do anything, since the version epoch is not being written to the txnStateStore in simulation. This will get fixed in the future. Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2022-04-09 03:33:19 +08:00
ASSERT_GT(self->version, rep.prevVersion);
} else {
self->version = self->version + toAdd;
}
CODE_PROBE(self->version - rep.prevVersion == 1, "Minimum possible version gap");
bool maxVersionGap = self->version - rep.prevVersion == SERVER_KNOBS->MAX_READ_TRANSACTION_LIFE_VERSIONS;
CODE_PROBE(maxVersionGap, "Maximum possible version gap");
2017-05-26 04:48:44 +08:00
self->lastVersionTime = t1;
self->resolutionBalancer.setChangesInReply(req.requestingProxy, rep);
2017-05-26 04:48:44 +08:00
}
rep.version = self->version;
rep.requestNum = req.requestNum;
proxyItr->second.replies.erase(proxyItr->second.replies.begin(),
proxyItr->second.replies.upper_bound(req.mostRecentProcessedRequestNum));
proxyItr->second.replies[req.requestNum] = rep;
ASSERT(rep.prevVersion >= 0);
2017-05-26 04:48:44 +08:00
req.reply.send(rep);
ASSERT(proxyItr->second.latestRequestNum.get() == req.requestNum - 1);
proxyItr->second.latestRequestNum.set(req.requestNum);
}
return Void();
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
ACTOR Future<Void> getVersion(Reference<MasterData> self, GetCommitVersionRequest req) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
wait(getVersionSwift(self, req));
return Void();
} else {
wait(getVersionCxx(self, req));
return Void();
}
}
#else
ACTOR Future<Void> getVersion(Reference<MasterData> self, GetCommitVersionRequest req) {
wait(getVersionCxx(self, req));
return Void();
}
#endif
CounterValue::CounterValue(std::string const& name, CounterCollection& collection)
: value(std::make_shared<Counter>(name, collection)) {}
void CounterValue::operator+=(Value delta) {
value->operator+=(delta);
}
void CounterValue::operator++() {
value->operator++();
}
void CounterValue::clear() {
value->clear();
}
MasterData::MasterData(Reference<AsyncVar<ServerDBInfo> const> const& dbInfo,
MasterInterface const& myInterface,
ServerCoordinators const& coordinators,
ClusterControllerFullInterface const& clusterController,
Standalone<StringRef> const& dbId,
PromiseStream<Future<Void>> addActor,
bool forceRecovery)
: dbgid(myInterface.id()), lastEpochEnd(invalidVersion), recoveryTransactionVersion(invalidVersion),
liveCommittedVersion(invalidVersion), databaseLocked(false), minKnownCommittedVersion(invalidVersion),
coordinators(coordinators), version(invalidVersion), lastVersionTime(0), myInterface(myInterface),
resolutionBalancer(&version), forceRecovery(forceRecovery), cc("Master", dbgid.toString()),
getCommitVersionRequests("GetCommitVersionRequests", cc),
getLiveCommittedVersionRequests("GetLiveCommittedVersionRequests", cc),
reportLiveCommittedVersionRequests("ReportLiveCommittedVersionRequests", cc),
versionVectorTagUpdates("VersionVectorTagUpdates",
dbgid,
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
waitForPrevCommitRequests("WaitForPrevCommitRequests", cc),
nonWaitForPrevCommitRequests("NonWaitForPrevCommitRequests", cc),
versionVectorSizeOnCVReply("VersionVectorSizeOnCVReply",
dbgid,
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
waitForPrevLatencies("WaitForPrevLatencies",
dbgid,
SERVER_KNOBS->LATENCY_METRICS_LOGGING_INTERVAL,
SERVER_KNOBS->LATENCY_SKETCH_ACCURACY),
addActor(addActor) {
logger = cc.traceCounters("MasterMetrics", dbgid, SERVER_KNOBS->WORKER_LOGGING_INTERVAL, "MasterMetrics");
if (forceRecovery && !myInterface.locality.dcId().present()) {
TraceEvent(SevError, "ForcedRecoveryRequiresDcID").log();
forceRecovery = false;
}
balancer = resolutionBalancer.resolutionBalancing();
locality = tagLocalityInvalid;
#ifdef WITH_SWIFT
using namespace fdbserver_swift;
// FIXME(swift): can we make a cleaner init?
swiftImpl.reset(new MasterDataActor((const MasterDataActor&)MasterDataActor::init()));
#endif
}
#ifdef WITH_SWIFT
void MasterData::setSwiftImpl(fdbserver_swift::MasterDataActor* impl) {
swiftImpl.reset(impl);
}
#endif
MasterData::~MasterData() {}
ACTOR Future<Void> provideVersionsCxx(Reference<MasterData> self) {
2017-05-26 04:48:44 +08:00
state ActorCollection versionActors(false);
loop choose {
when(GetCommitVersionRequest req = waitNext(self->myInterface.getCommitVersion.getFuture())) {
versionActors.add(getVersion(self, req));
2017-05-26 04:48:44 +08:00
}
when(wait(versionActors.getResult())) {}
2017-05-26 04:48:44 +08:00
}
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
SWIFT_ACTOR Future<Void> provideVersionsSwift(Reference<MasterData> self) {
auto future = self->swiftImpl->provideVersions(self.getPtr());
wait(future);
return Void();
}
#endif
#ifdef WITH_SWIFT
ACTOR Future<Void> provideVersions(Reference<MasterData> self) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
wait(provideVersionsSwift(self));
} else {
wait(provideVersionsCxx(self));
}
return Void();
}
#else
ACTOR Future<Void> provideVersions(Reference<MasterData> self) {
wait(provideVersionsCxx(self));
return Void();
}
#endif
#ifdef WITH_SWIFT
void updateLiveCommittedVersionSwift(Reference<MasterData> self, ReportRawCommittedVersionRequest req) {
fdbserver_swift::updateLiveCommittedVersion(self.getPtr(), req);
}
#endif
void updateLiveCommittedVersionCxx(Reference<MasterData> self, ReportRawCommittedVersionRequest req) {
2021-07-14 08:39:42 +08:00
self->minKnownCommittedVersion = std::max(self->minKnownCommittedVersion, req.minKnownCommittedVersion);
2021-07-14 08:39:42 +08:00
if (req.version > self->liveCommittedVersion.get()) {
if (SERVER_KNOBS->ENABLE_VERSION_VECTOR && req.writtenTags.present()) {
// TraceEvent("Received ReportRawCommittedVersionRequest").detail("Version",req.version);
2022-06-04 05:20:32 +08:00
int8_t primaryLocality =
SERVER_KNOBS->ENABLE_VERSION_VECTOR_HA_OPTIMIZATION ? self->locality : tagLocalityInvalid;
self->ssVersionVector.setVersion(req.writtenTags.get(), req.version, primaryLocality);
self->versionVectorTagUpdates.addMeasurement(req.writtenTags.get().size());
}
auto curTime = now();
// add debug here to change liveCommittedVersion to time bound of now()
debug_advanceVersionTimestamp(self->liveCommittedVersion.get(), curTime + CLIENT_KNOBS->MAX_VERSION_CACHE_LAG);
// also add req.version but with no time bound
debug_advanceVersionTimestamp(req.version, std::numeric_limits<double>::max());
2021-07-14 08:39:42 +08:00
self->databaseLocked = req.locked;
self->proxyMetadataVersion = req.metadataVersion;
// Note the set call switches context to any waiters on liveCommittedVersion before continuing.
self->liveCommittedVersion.set(req.version);
}
++self->reportLiveCommittedVersionRequests;
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
void updateLiveCommittedVersion(Reference<MasterData> self, ReportRawCommittedVersionRequest req) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
return updateLiveCommittedVersionSwift(self, req);
} else {
return updateLiveCommittedVersionCxx(self, req);
}
}
#else
void updateLiveCommittedVersion(Reference<MasterData> self, ReportRawCommittedVersionRequest req) {
return updateLiveCommittedVersionCxx(self, req);
}
#endif
#ifdef WITH_SWIFT
SWIFT_ACTOR Future<Void> serveLiveCommittedVersionSwift(Reference<MasterData> self) {
auto future = self->swiftImpl->serveLiveCommittedVersion(self.getPtr());
wait(future);
2021-07-14 08:39:42 +08:00
return Void();
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#endif
2021-07-14 08:39:42 +08:00
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
ACTOR Future<Void> serveLiveCommittedVersionCxx(Reference<MasterData> self) {
2020-06-10 02:09:46 +08:00
loop {
choose {
when(GetRawCommittedVersionRequest req = waitNext(self->myInterface.getLiveCommittedVersion.getFuture())) {
if (req.debugID.present())
g_traceBatch.addEvent("TransactionDebug",
req.debugID.get().first(),
"MasterServer.serveLiveCommittedVersion.GetRawCommittedVersion");
2021-07-14 08:39:42 +08:00
if (self->liveCommittedVersion.get() == invalidVersion) {
self->liveCommittedVersion.set(self->recoveryTransactionVersion);
2020-06-10 02:09:46 +08:00
}
2021-04-07 13:13:15 +08:00
++self->getLiveCommittedVersionRequests;
2020-07-15 15:37:41 +08:00
GetRawCommittedVersionReply reply;
2021-07-14 08:39:42 +08:00
reply.version = self->liveCommittedVersion.get();
reply.locked = self->databaseLocked;
reply.metadataVersion = self->proxyMetadataVersion;
2020-07-15 15:37:41 +08:00
reply.minKnownCommittedVersion = self->minKnownCommittedVersion;
if (SERVER_KNOBS->ENABLE_VERSION_VECTOR) {
self->ssVersionVector.getDelta(req.maxVersion, reply.ssVersionVectorDelta);
self->versionVectorSizeOnCVReply.addMeasurement(reply.ssVersionVectorDelta.size());
}
req.reply.send(reply);
2020-06-10 02:09:46 +08:00
}
when(ReportRawCommittedVersionRequest req =
waitNext(self->myInterface.reportLiveCommittedVersion.getFuture())) {
if (SERVER_KNOBS->ENABLE_VERSION_VECTOR && req.prevVersion.present() &&
2021-07-14 08:39:42 +08:00
(self->liveCommittedVersion.get() != invalidVersion) &&
(self->liveCommittedVersion.get() < req.prevVersion.get())) {
self->addActor.send(waitForPrev(self, req));
} else {
updateLiveCommittedVersion(self, req);
++self->nonWaitForPrevCommitRequests;
2021-07-14 08:39:42 +08:00
req.reply.send(Void());
}
2020-06-10 02:09:46 +08:00
}
2021-07-15 22:23:07 +08:00
}
2020-06-10 02:09:46 +08:00
}
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
ACTOR Future<Void> serveLiveCommittedVersion(Reference<MasterData> self) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
wait(serveLiveCommittedVersionSwift(self));
} else {
wait(serveLiveCommittedVersionCxx(self));
}
return Void();
}
#else
ACTOR Future<Void> serveLiveCommittedVersion(Reference<MasterData> self) {
wait(serveLiveCommittedVersionCxx(self));
return Void();
}
#endif
#ifdef WITH_SWIFT
SWIFT_ACTOR Future<Void> updateRecoveryDataSwift(Reference<MasterData> self) {
auto future = self->swiftImpl->serveUpdateRecoveryData(self.getPtr());
wait(future);
return Void();
}
#endif
ACTOR Future<Void> updateRecoveryDataCxx(Reference<MasterData> self) {
2017-05-26 04:48:44 +08:00
loop {
UpdateRecoveryDataRequest req = waitNext(self->myInterface.updateRecoveryData.getFuture());
TraceEvent("UpdateRecoveryData", self->dbgid)
.detail("ReceivedRecoveryTxnVersion", req.recoveryTransactionVersion)
.detail("ReceivedLastEpochEnd", req.lastEpochEnd)
.detail("CurrentRecoveryTxnVersion", self->recoveryTransactionVersion)
.detail("CurrentLastEpochEnd", self->lastEpochEnd)
Add fdbcli command to read/write version epoch (#6480) * Initialize cluster version at wall-clock time Previously, new clusters would begin at version 0. After this change, clusters will initialize at a version matching wall-clock time. Instead of using the Unix epoch (or Windows epoch), FDB clusters will use a new epoch, defaulting to January 1, 2010, 01:00:00+00:00. In the future, this base epoch will be modifiable through fdbcli, allowing administrators to advance the cluster version. Basing the version off of time allows different FDB clusters to share data without running into version issues. * Send version epoch to master * Cleanup * Update fdbserver/storageserver.actor.cpp Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com> * Jump directly to expected version if possible * Fix initial version issue on storage servers * Add random recovery offset to start version in simulation * Type fixes * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Use correct recoveryTransactionVersion when recovering * Allow version epoch to be adjusted forwards (to decrease the version) * Set version epoch in simulation * Add quiet database check to ensure small version offset * Fix initial version issue on storage servers * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Add fdbcli command to read/write version epoch * Cause recovery when version epoch is set * Handle optional version epoch key * Add ability to clear the version epoch This causes version advancement to revert to the old methodology whereas versions attempt to advance by about a million versions per second, instead of trying to match the clock. * Update transaction access * Modify version epoch to use microseconds instead of seconds * Modify fdbcli version target API Move commands from `versionepoch` to `targetversion` top level command. * Add fdbcli tests for * Temporarily disable targetversion cli tests * Fix version epoch fetch issue * Fix Arena issue * Reduce max version jump in simulation to 1,000,000 * Rework fdbcli API It now requires two commands to fully switch a cluster to using the version epoch. First, enable the version epoch with `versionepoch enable` or `versionepoch set <versionepoch>`. At this point, versions will be given out at a faster or slower rate in an attempt to reach the expected version. Then, run `versionepoch commit` to perform a one time jump to the expected version. This is essentially irreversible. * Temporarily disable old targetversion tests * Cleanup * Move version epoch buggify to sequencer This will cause some issues with the QuietDatabase check for the version offset - namely, it won't do anything, since the version epoch is not being written to the txnStateStore in simulation. This will get fixed in the future. Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2022-04-09 03:33:19 +08:00
.detail("NumCommitProxies", req.commitProxies.size())
.detail("VersionEpoch", req.versionEpoch)
.detail("PrimaryLocality", req.primaryLocality);
self->recoveryTransactionVersion = req.recoveryTransactionVersion;
self->lastEpochEnd = req.lastEpochEnd;
if (req.commitProxies.size() > 0) {
self->lastCommitProxyVersionReplies.clear();
2017-05-26 04:48:44 +08:00
for (auto& p : req.commitProxies) {
self->lastCommitProxyVersionReplies[p.id()] = CommitProxyVersionReplies();
2017-05-26 04:48:44 +08:00
}
}
Add fdbcli command to read/write version epoch (#6480) * Initialize cluster version at wall-clock time Previously, new clusters would begin at version 0. After this change, clusters will initialize at a version matching wall-clock time. Instead of using the Unix epoch (or Windows epoch), FDB clusters will use a new epoch, defaulting to January 1, 2010, 01:00:00+00:00. In the future, this base epoch will be modifiable through fdbcli, allowing administrators to advance the cluster version. Basing the version off of time allows different FDB clusters to share data without running into version issues. * Send version epoch to master * Cleanup * Update fdbserver/storageserver.actor.cpp Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com> * Jump directly to expected version if possible * Fix initial version issue on storage servers * Add random recovery offset to start version in simulation * Type fixes * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Use correct recoveryTransactionVersion when recovering * Allow version epoch to be adjusted forwards (to decrease the version) * Set version epoch in simulation * Add quiet database check to ensure small version offset * Fix initial version issue on storage servers * Disable reference time by default Enable on a cluster using the fdbcli command `versionepoch add 0`. * Add fdbcli command to read/write version epoch * Cause recovery when version epoch is set * Handle optional version epoch key * Add ability to clear the version epoch This causes version advancement to revert to the old methodology whereas versions attempt to advance by about a million versions per second, instead of trying to match the clock. * Update transaction access * Modify version epoch to use microseconds instead of seconds * Modify fdbcli version target API Move commands from `versionepoch` to `targetversion` top level command. * Add fdbcli tests for * Temporarily disable targetversion cli tests * Fix version epoch fetch issue * Fix Arena issue * Reduce max version jump in simulation to 1,000,000 * Rework fdbcli API It now requires two commands to fully switch a cluster to using the version epoch. First, enable the version epoch with `versionepoch enable` or `versionepoch set <versionepoch>`. At this point, versions will be given out at a faster or slower rate in an attempt to reach the expected version. Then, run `versionepoch commit` to perform a one time jump to the expected version. This is essentially irreversible. * Temporarily disable old targetversion tests * Cleanup * Move version epoch buggify to sequencer This will cause some issues with the QuietDatabase check for the version offset - namely, it won't do anything, since the version epoch is not being written to the txnStateStore in simulation. This will get fixed in the future. Co-authored-by: A.J. Beamon <aj.beamon@snowflake.com>
2022-04-09 03:33:19 +08:00
if (req.versionEpoch.present()) {
self->referenceVersion = req.versionEpoch.get();
} else if (BUGGIFY) {
// Cannot use a positive version epoch in simulation because of the
// clock starting at 0. A positive version epoch would mean the initial
// cluster version was negative.
// TODO: Increase the size of this interval after fixing the issue
// with restoring ranges with large version gaps.
self->referenceVersion = deterministicRandom()->randomInt64(-1e6, 0);
}
self->resolutionBalancer.setCommitProxies(req.commitProxies);
self->resolutionBalancer.setResolvers(req.resolvers);
self->locality = req.primaryLocality;
req.reply.send(Void());
2017-05-26 04:48:44 +08:00
}
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
ACTOR Future<Void> updateRecoveryData(Reference<MasterData> self) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
wait(updateRecoveryDataSwift(self));
} else {
wait(updateRecoveryDataCxx(self));
}
return Void();
}
#else
ACTOR Future<Void> updateRecoveryData(Reference<MasterData> self) {
wait(updateRecoveryDataCxx(self));
return Void();
}
#endif
2017-05-26 04:48:44 +08:00
static std::set<int> const& normalMasterErrors() {
static std::set<int> s;
if (s.empty()) {
s.insert(error_code_tlog_stopped);
s.insert(error_code_tlog_failed);
2020-09-11 08:44:15 +08:00
s.insert(error_code_commit_proxy_failed);
2020-07-15 15:37:41 +08:00
s.insert(error_code_grv_proxy_failed);
s.insert(error_code_resolver_failed);
s.insert(error_code_backup_worker_failed);
2017-05-26 04:48:44 +08:00
s.insert(error_code_recruitment_failed);
s.insert(error_code_no_more_servers);
s.insert(error_code_cluster_recovery_failed);
2017-05-26 04:48:44 +08:00
s.insert(error_code_coordinated_state_conflict);
s.insert(error_code_master_max_versions_in_flight);
s.insert(error_code_worker_removed);
s.insert(error_code_new_coordinators_timed_out);
s.insert(error_code_broken_promise);
2017-05-26 04:48:44 +08:00
}
return s;
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
ACTOR Future<Void> masterServerCxx(MasterInterface mi,
Reference<AsyncVar<ServerDBInfo> const> db,
Reference<AsyncVar<Optional<ClusterControllerFullInterface>> const> ccInterface,
ServerCoordinators coordinators,
LifetimeToken lifetime,
bool forceRecovery) {
state Future<Void> ccTimeout = delay(SERVER_KNOBS->CC_INTERFACE_TIMEOUT);
while (!ccInterface->get().present() || db->get().clusterInterface != ccInterface->get().get()) {
wait(ccInterface->onChange() || db->onChange() || ccTimeout);
if (ccTimeout.isReady()) {
TraceEvent("MasterTerminated", mi.id())
.detail("Reason", "Timeout")
2020-07-21 02:35:20 +08:00
.detail("CCInterface", ccInterface->get().present() ? ccInterface->get().get().id() : UID())
.detail("DBInfoInterface", db->get().clusterInterface.id());
return Void();
}
}
2017-05-26 04:48:44 +08:00
state Future<Void> onDBChange = Void();
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
wait(onDBChange);
state PromiseStream<Future<Void>> addActor;
state Reference<MasterData> self(
new MasterData(db, mi, coordinators, db->get().clusterInterface, ""_sr, addActor, forceRecovery));
state Future<Void> collection = actorCollection(addActor.getFuture());
addActor.send(traceRole(Role::MASTER, mi.id()));
addActor.send(provideVersions(self));
addActor.send(serveLiveCommittedVersion(self));
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
addActor.send(updateRecoveryDataCxx(self));
2017-05-26 04:48:44 +08:00
CODE_PROBE(!lifetime.isStillValid(db->get().masterLifetime, mi.id() == db->get().master.id()),
"Master born doomed");
2017-05-26 04:48:44 +08:00
TraceEvent("MasterLifetime", self->dbgid).detail("LifetimeToken", lifetime.toString());
try {
loop choose {
when(wait(onDBChange)) {
2017-05-26 04:48:44 +08:00
onDBChange = db->onChange();
if (!lifetime.isStillValid(db->get().masterLifetime, mi.id() == db->get().master.id())) {
TraceEvent("MasterTerminated", mi.id())
.detail("Reason", "LifetimeToken")
.detail("MyToken", lifetime.toString())
.detail("CurrentToken", db->get().masterLifetime.toString());
CODE_PROBE(true, "Master replaced, dying");
if (BUGGIFY)
wait(delay(5));
2017-05-26 04:48:44 +08:00
throw worker_removed();
}
}
when(wait(collection)) {
ASSERT(false);
throw internal_error();
}
2017-05-26 04:48:44 +08:00
}
} catch (Error& e) {
state Error err = e;
if (e.code() != error_code_actor_cancelled) {
wait(delay(0.0));
}
while (!addActor.isEmpty()) {
addActor.getFuture().pop();
}
2022-09-26 06:28:32 +08:00
CODE_PROBE(
err.code() == error_code_tlog_failed, "Master: terminated due to tLog failure", probe::decoration::rare);
CODE_PROBE(err.code() == error_code_commit_proxy_failed,
"Master: terminated due to commit proxy failure",
probe::decoration::rare);
CODE_PROBE(err.code() == error_code_grv_proxy_failed,
"Master: terminated due to GRV proxy failure",
probe::decoration::rare);
CODE_PROBE(err.code() == error_code_resolver_failed,
"Master: terminated due to resolver failure",
probe::decoration::rare);
CODE_PROBE(err.code() == error_code_backup_worker_failed,
"Master: terminated due to backup worker failure",
probe::decoration::rare);
2017-05-26 04:48:44 +08:00
2019-05-21 05:22:31 +08:00
if (normalMasterErrors().count(err.code())) {
TraceEvent("MasterTerminated", mi.id()).error(err);
2017-05-26 04:48:44 +08:00
return Void();
}
throw err;
2017-05-26 04:48:44 +08:00
}
}
Introduce initial Swift support in fdbserver (#10156) * [fdbserver] workaround the FRT type layout issue to get Swfit getVersion working * MasterData.actor.h: fix comment typo * masterserver.swift: some tweaks * masterserver.swift: remove getVersion function, use the method * masterserver.swift: print replied version to output for tracing * [swift] add radar links for C++ interop issues found in getVersion bringup * Update fdbserver.actor.cpp * Migrate MasterData closer to full reference type This removes the workaround for the FRT type layout issue, and gets us closer to making MasterData a full reference type * [interop] require a new toolchain (>= Oct 19th) to build * [Swift] fix computation of toAdd for getVersion Swift implementation * add Swift to FDBClient and add async `atLeast` to NotifiedVersion * fix * use new atLeast API in master server * =build fixup link dependencies in swift fdbclient * clocks * +clock implement Clock using Flow's notion of time * [interop] workaround the immortal retain/release issue * [swift] add script to get latest centos toolchain * always install swift hooks; not only in "test" mode * simulator - first thing running WIP * cleanups * more cleanup * working snapshot * remove sim debug printlns * added convenience for whenAtLeast * try Alex's workaround * annotate nonnull * cleanup clock a little bit * fix missing impls after rebase * Undo the swift_lookup_Map_UID_CommitProxyVersionReplies workaround No longer needed - the issue was retain/release * [flow][swift] add Swift version of BUGGIFY * [swiftication] add CounterValue type to provide value semantics for Counter types on the Swift side * remove extraneous requestingProxyUID local * masterserver: initial Swift state prototype * [interop] make the Swiftied getVersion work * masterserver - remove the C++ implementation (it can't be supported as state is now missing) * Remove unnecessary SWIFT_CXX_REF_IMMORTAL annotations from Flow types * Remove C++ implementation of CommitProxyVersionReplies - it's in Swift now * [swift interop] remove more SWIFT_CXX_REF_IMMORTAL * [swift interop] add SWIFT_CXX_IMMORTAL_SINGLETON_TYPE annotation for semanticly meaningful immortal uses * rename SWIFT_CXX_REF_IMMORTAL -> UNSAFE_SWIFT_CXX_IMMORTAL_REF * Move master server waitForPrev to swift * =build fix linking swift in all modules * =build single link option * =cmake avoid manual math, just get "last" element from list * implement Streams support (#18) * [interop] update to new toolchain #6 * [interop] remove C++ vtable linking workarounds * [interop] make MasterData proper reference counted SWIFT_CXX_REF_MASTERDATA * [interop] use Swift array to pass UIDs to registerLastCommitProxyVersionReplies * [interop] expose MasterServer actor to C++ without wrapper struct * [interop] we no longer need expose on methods 🥳 * [interop] initial prototype of storing CheckedContinuation on the C++ side * Example of invoking a synchronous swift function from a C++ unit test. (#21) * move all "tests" we have in Swift, and priority support into real modules (#24) * Make set continuation functions inline * Split flow_swift into flow_swift and flow_swift_future to break circular dependency * rename SwiftContinuationCallbackStruct to FlowCallbackForSwiftContinuation * Future interop: use a method in a class template for continuation set call * Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30) * Basic Swift Guide (#29) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Revert "Revert "Merge pull request #22 from FoundationDB/cpp-continuation" (#30)" This reverts commit c025fe6258c4c4904d5e70cd549d408bb61f2802. * Restore the C++ continuation, but it seems waitValue is broken for CInt somehow now * disable broken tests - waitValue not accessible * Streams can be async iterated over (#27) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * remove work in progress things (#35) * remove some not used (yet) code * remove expose func for CInt, it's a primitive so we always have witness info (#37) * +masterdata implement provideVersions in Swift (#36) * serveLiveCommittedVersion in Swift (#38) * Port updateLiveCommittedVersion to swift (#33) Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com> * Implement updateRecoveryData in Swift (#39) Co-authored-by: Alex Lorenz <arphaman@gmail.com> * Simplify flow_swift to avoid multiple targets and generate separate CheckedContinuation header * Uncomment test which was blocked on extensions not being picked up (#31) * [interop] Use a separate target for Swift-to-C++ header generation * reduce boilerplate in future and stream support (#41) * [interop] require interop v8 - that will fix linker issue (https://github.com/apple/swift/issues/62448) * [interop] fix swift_stream_support.h Swift include * [interop] bump up requirement to version 9 * [interop] Generalize the Flow.Optional -> Swift.Optional conversion using generics * [WIP] masterServer func in Swift (#45) * [interop] Try conforms_to with a SWIFT_CONFORMS_TO macro for Optional conformance (#49) * [interop] include FlowOptionalProtocol source file when generating Flow_CheckedContinuation.h This header generation step depends on the import of the C++ Flow module, which requires the presence of FlowOptionalProtocol * conform Future to FlowFutureOps * some notes * move to value() so we can use discardable result for Flow.Void * make calling into Swift async funcs nicer by returning Flow Futures * [interop] hide initial use of FlowCheckedContinuation in flow.h to break dependency cycle * [fdbserver] fix an EncryptionOpsUtils.h modularization issue (showed up with modularized libc++) * Pass GCC toolchain using CMAKE_Swift_COMPILE_EXTERNAL_TOOLCHAIN to Swift's clang importer * [interop] drop the no longer needed libstdc++ include directories * [cmake] add a configuration check to ensure Swift can import C++ standard library * [swift] include msgpack from msgpack_DIR * [interop] make sure the FDB module maps have 'export' directive * add import 'flow_swift' to swift_fdbserver_cxx_swift_value_conformance.swift This is needed for CONFORMS_TO to work in imported modules * make sure the Swift -> C++ manually bridged function signature matches generated signature * [interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed * [interop] make getResolutionBalancer return a pointer to allow Swift to use it We should revert back to a reference once compiler allows references again * [interop] add a workaround for 'pop' being marked as unsafe in Swift * masterserver.swift: MasterData returns the Swift actor pointer in an unsafe manner * Add a 'getCopy' method to AsyncVar to make it more Swift friendly * [interop] bump up the toolchain requirement * Revert "[interop][workaround] force back use of @expose attribute before _Concurrency issue is fixed" This reverts commit b01b271a76d1677bbb7c5c9c64cdad4b8b2b9612. * [interop] add FIXME comments highlighting new issue workarounds * [interop] adopt the new C++ interoperability compiler flag * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * [interop] generate swift compile commands * Do not deduplicate Swift compilation commands * flow actorcompiler.h: add a SWIFT_ACTOR empty macro definition This is needed to make the actor files parsable by clangd * [cmake] add missing dependencies * experimental cross compile * [cmake] fix triple in cross-compiled cmake flags * [interop] update to interop toolchain version 16 * [x-compile] add flags for cross-compiling boost * cleanup x-compile cmake changes * [cmake] fix typo in CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN config variable * [interop] pass MasterDataActor from Swift to C++ and back to Swift * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * Update swift_get_latest_toolchain.sh to fetch 5.9 toochains * set HAVE_FLAG_SEARCH_PATHS_FIRST for cross compilation * Resolve conflicts in net2/sim2/actors, can't build yet * undo SWIFT_ACTOR changes, not necessary for merge * guard c++ compiler flags with is_cxx_compile * Update flow/actorcompiler/ActorParser.cs Co-authored-by: Evan Wilde <etceterawilde@gmail.com> * update the boost dependency * Include boost directory from the container for Swift * conform flow's Optional to FlowOptionalProtocol again * Guard entire RocksDBLogForwarder.h with SSD_ROCKSDB_EXPERIMENTAL to avoid failing on missing rocksdb APIs * remove extraneous merge marker * [swift] update swift_test_streams.swifto to use vars in more places * Add header guard to flow/include/flow/ThreadSafeQueue.h to fix moduralization issue * Update net and sim impls * [cmake] use prebuilt libc++ boost only when we're actually using libc++ * [fdbserver] Swift->C++ header generation for FDBServer should use same module cache path * fixups after merge * remove CustomStringConvertible conformance that would not be used * remove self-caused deprecation warnings in future_support * handle newly added task priority * reformatting * future: make value() not mutating * remove FIXME, not needed anymore * future: clarify why as functions * Support TraceEvent in Swift * Enable TraceEvent using a class wrapper in Swift * prearing WITH_SWIFT flag * wip disabled failing Go stuff * cleanup WITH_SWIFT_FLAG and reenable Go * wip disabled failing Go stuff * move setting flag before printing it * Add SWIFT_IDE_SETUP and cleanup guides and build a bit * Revert "Wipe packet buffers that held serialized WipedString (#10018)" This reverts commit e2df6e33029897360f8e11b3aea8fef97393a98c. * [Swift] Compile workaround in KeyBackedRangeMap; default init is incorrect * [interop] do not add FlowFutureOps conformance when building flow clang module for Flow checked continuation header pre-generation * make sure to show -DUSE_LIBCXX=OFF in readme * readme updates * do not print to stderr * Update Swift and C++ code to build with latest Swift 5.9 toolchain now that we no longer support universal references and bridge the methods that take in a constant reference template parameter correctly * Fix SERVER_KNOBS and enable use them for masterserver * Bump to C++20, Swift is now able to handle it as well * Put waitForPrev behind FLOW_WITH_SWIFT knob * Forward declare updateLiveCommittedVersion * Remove unused code * fix wrong condition set for updateLiveCommittedVersion * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * Enable go-bindings in cmake * Revert "Revert "Wipe packet buffers that held serialized WipedString (#10018)"" This reverts commit 5ad8dce0525fb1844664ed2ccd7ba595db6913dd. * USE_SWIFT flag so we "build without swift" until ready to by default * uncomment a few tests which were disabled during USE_SWIFT enablement * the option is WITH_SWIFT, not USE * formatting * Fix masterserver compile error * Fix some build errors. How did it not merge cleanly? :/ * remove initializer list from constructor * Expect Swift toolchain only if WITH_SWIFT is enabled * Don't require Flow_CheckedContinuation when Swift is disabled * Don't compile FlowCheckedContinuation when WITH_SWIFT=OFF * No-op Swift macros * More compile guards * fix typo * Run clang-format * Guard swift/bridging include in fdbrpc * Remove printf to pass the test * Remove some more printf to avoid potential issues TODO: Need to be TraceEvents instead * Remove __has_feature(nullability) as its only used in Swift * Don't use __FILENAME__ * Don't call generate_module_map outside WITH_SWIFT * Add some more cmake stuff under WITH_SWIFT guard * Some more guards * Bring back TLSTest.cpp * clang-format * fix comment formatting * Remove unused command line arg * fix cmake formatting in some files * Address some review comments * fix clang-format error --------- Co-authored-by: Alex Lorenz <arphaman@gmail.com> Co-authored-by: Russell Sears <russell_sears@apple.com> Co-authored-by: Evan Wilde <etceterawilde@gmail.com> Co-authored-by: Alex Lorenz <aleksei_lorenz@apple.com> Co-authored-by: Vishesh Yadav <vishesh_yadav@apple.com> Co-authored-by: Vishesh Yadav <vishesh3y@gmail.com>
2023-06-03 05:09:28 +08:00
#ifdef WITH_SWIFT
ACTOR Future<Void> masterServerImpl(MasterInterface mi,
Reference<AsyncVar<ServerDBInfo> const> db,
Reference<AsyncVar<Optional<ClusterControllerFullInterface>> const> ccInterface,
ServerCoordinators coordinators,
LifetimeToken lifetime,
bool forceRecovery) {
if (SERVER_KNOBS->FLOW_WITH_SWIFT) {
auto promise = Promise<Void>();
state PromiseStream<Future<Void>> addActor;
state Reference<MasterData> self(
new MasterData(db, mi, coordinators, db->get().clusterInterface, ""_sr, addActor, forceRecovery));
fdbserver_swift::masterServerSwift(
mi,
const_cast<AsyncVar<ServerDBInfo>*>(db.getPtr()),
const_cast<AsyncVar<Optional<ClusterControllerFullInterface>>*>(ccInterface.getPtr()),
coordinators,
lifetime,
forceRecovery,
self.getPtr(),
/*result=*/promise);
Future<Void> f = promise.getFuture();
wait(f);
return Void();
} else {
wait(masterServerCxx(mi, db, ccInterface, coordinators, lifetime, forceRecovery));
return Void();
}
}
#else
ACTOR Future<Void> masterServerImpl(MasterInterface mi,
Reference<AsyncVar<ServerDBInfo> const> db,
Reference<AsyncVar<Optional<ClusterControllerFullInterface>> const> ccInterface,
ServerCoordinators coordinators,
LifetimeToken lifetime,
bool forceRecovery) {
wait(masterServerCxx(mi, db, ccInterface, coordinators, lifetime, forceRecovery));
return Void();
}
#endif
ACTOR Future<Void> masterServer(MasterInterface mi,
Reference<AsyncVar<ServerDBInfo> const> db,
Reference<AsyncVar<Optional<ClusterControllerFullInterface>> const> ccInterface,
ServerCoordinators coordinators,
LifetimeToken lifetime,
bool forceRecovery) {
state Future<Void> ccTimeout = delay(SERVER_KNOBS->CC_INTERFACE_TIMEOUT);
while (!ccInterface->get().present() || db->get().clusterInterface != ccInterface->get().get()) {
wait(ccInterface->onChange() || db->onChange() || ccTimeout);
if (ccTimeout.isReady()) {
TraceEvent("MasterTerminated", mi.id())
.detail("Reason", "Timeout")
.detail("CCInterface", ccInterface->get().present() ? ccInterface->get().get().id() : UID())
.detail("DBInfoInterface", db->get().clusterInterface.id());
return Void();
}
}
state Future<Void> onDBChange = Void();
wait(onDBChange);
wait(masterServerImpl(mi, db, ccInterface, coordinators, lifetime, forceRecovery));
return Void();
}
TEST_CASE("/fdbserver/MasterServer/FigureVersion/Simple") {
ASSERT_EQ(
figureVersion(0, 1.0, 0, 1e6, SERVER_KNOBS->MAX_VERSION_RATE_MODIFIER, SERVER_KNOBS->MAX_VERSION_RATE_OFFSET),
1e6);
ASSERT_EQ(figureVersion(1e6, 1.5, 0, 100, 0.1, 1e6), 1000110);
ASSERT_EQ(figureVersion(1e6, 1.5, 0, 550000, 0.1, 1e6), 1500000);
return Void();
}
TEST_CASE("/fdbserver/MasterServer/FigureVersion/Small") {
// Should always advance by at least 1 version.
ASSERT_EQ(figureVersion(1e6, 2.0, 0, 1, 0.0001, 1e6), 1000001);
ASSERT_EQ(figureVersion(1e6, 0.0, 0, 1, 0.1, 1e6), 1000001);
return Void();
}
TEST_CASE("/fdbserver/MasterServer/FigureVersion/MaxOffset") {
ASSERT_EQ(figureVersion(1e6, 10.0, 0, 5e6, 0.1, 1e6), 6500000);
ASSERT_EQ(figureVersion(1e6, 20.0, 0, 15e6, 0.1, 1e6), 17e6);
return Void();
}
TEST_CASE("/fdbserver/MasterServer/FigureVersion/PositiveReferenceVersion") {
ASSERT_EQ(figureVersion(1e6, 3.0, 1e6, 1e6, 0.1, 1e6), 2e6);
ASSERT_EQ(figureVersion(1e6, 3.0, 1e6, 100, 0.1, 1e6), 1000110);
return Void();
}
TEST_CASE("/fdbserver/MasterServer/FigureVersion/NegativeReferenceVersion") {
ASSERT_EQ(figureVersion(0, 2.0, -1e6, 3e6, 0.1, 1e6), 3e6);
ASSERT_EQ(figureVersion(0, 2.0, -1e6, 5e5, 0.1, 1e6), 550000);
return Void();
}