Closed mauriciomagni closed 1 year ago
Thank you for letting me know. By design, Facil can include anything from any schema, so the solution, as you discovered, is to modify your include/except patterns.
Out of interest, what schema are these under, what what rule filter were you using that were picking these up? I usually only include stuff from a certain schema, e.g. dbo\..+
. (Normally I'm even more restrictive in my patterns, but specifying the schema is a minimum.)
Hello cmeeren
It filter these out I have added: In procedures: .diagram. `procedures:
- include: .*
except: (dbo.GetGeoPoint|.*diagram.*)
voptionIn: true
voptionOut: true`
and in tableDtos: sysdiagrams `tableDtos:
this is the info about sysdiagrams it creates in TableDtos, I would have expected, that is related to
and this is a sample of one of the SPs:
The weird thing, is these changes end up raising a System.AccessViolationException when the app starts setting up functions in modules. So the execution, never reaches facil itself, it reaches just the code generated in DbGen, as long as I understand, this happens in the static constructor of modules.
this weekend I can investigate further and try to find which one of the SPs is the one generating this strange behavior.
Kind regards,
Do you have a stack trace for the exception? Can you show me the part of the code that throws the exception?
good morning
here is the exception raised:
I know for certain that this is not the actual code motivating the exception, given that removing the SPs for diagramas it just works.
In "CarrierInfoDal" there is a reference to DbGen:
In any case, any of the diagrams' SPs are called, they are just "defined" in DbGen... I will narrow the information during the weekend.
Regards, Mauricio
Thank you for supplying more details.
I will narrow the information during the weekend.
Great, I will await additional information from you. A minimal repro (given some DB schema that I can replicate) would be perfect.
hello cmeeren
I was able to narrow the code that raises the error in my project, but not able to create a minimal reproducible example.
[<EditorBrowsable(EditorBrowsableState.Never)>]
type ``sp_helpdiagramdefinition_Executable`` (connStr: string, conn: SqlConnection, configureConn: SqlConnection -> unit, userConfigureCmd: SqlCommand -> unit, getSqlParams: unit -> SqlParameter [], tempTableData: seq<TempTableData>, tran: SqlTransaction) =
let configureCmd sqlParams (cmd: SqlCommand) =
cmd.CommandType <- CommandType.StoredProcedure
cmd.CommandText <- "dbo.sp_helpdiagramdefinition"
cmd.Parameters.AddRange sqlParams
userConfigureCmd cmd
let mutable ``ordinal_version`` = 0
let mutable ``ordinal_definition`` = 0
let initOrdinals (reader: SqlDataReader) =
``ordinal_version`` <- reader.GetOrdinal "version"
``ordinal_definition`` <- reader.GetOrdinal "definition"
let getItem (reader: SqlDataReader) =
let ``version`` = if reader.IsDBNull ``ordinal_version`` then ValueNone else reader.GetInt32 ``ordinal_version`` |> ValueSome
let ``definition`` = if reader.IsDBNull ``ordinal_definition`` then ValueNone else reader.GetBytes ``ordinal_definition`` |> ValueSome
{|
``version`` = ``version``
``definition`` = ``definition``
|}
member _.ExecuteAsync(?cancellationToken) =
let sqlParams = getSqlParams ()
executeQueryEagerAsync connStr conn tran configureConn (configureCmd sqlParams) initOrdinals getItem tempTableData (defaultArg cancellationToken CancellationToken.None)
member this.AsyncExecute() =
async {
let! ct = Async.CancellationToken
return! this.ExecuteAsync(ct) |> Async.AwaitTask
}
member _.ExecuteAsyncWithSyncRead(?cancellationToken) =
let sqlParams = getSqlParams ()
executeQueryEagerAsyncWithSyncRead connStr conn tran configureConn (configureCmd sqlParams) initOrdinals getItem tempTableData (defaultArg cancellationToken CancellationToken.None)
member this.AsyncExecuteWithSyncRead() =
async {
let! ct = Async.CancellationToken
return! this.ExecuteAsyncWithSyncRead(ct) |> Async.AwaitTask
}
member _.Execute() =
let sqlParams = getSqlParams ()
executeQueryEager connStr conn tran configureConn (configureCmd sqlParams) initOrdinals getItem tempTableData
If I comment out the last method shown in the code above, it works:
member _.Execute() =
let sqlParams = getSqlParams ()
executeQueryEager connStr conn tran configureConn (configureCmd sqlParams) initOrdinals getItem tempTableData
I tried creating a simple project, but it does not fail, so there should be something else that ends up creating this unexpected behavior because, by itself, it does not make sense... Sadly I have not idea how to find it out.
Regards, Mauricio
Thank you for the details!
As I understand it, you would ideally like Facil to automatically exclude these stored procedures.
That is unfortunately problematic for two reasons:
Since Facil is doing exactly as you tell it to by including these procedures when including e.g. dbo\.*
, and since the solution is trivial (just exclude them manually, as you yourself discovered), and since no other users have reported this so far, I will keep the existing functionality.
Hello @cmeeren This message has the only purpose of providing you more info, there is no action expected. As our project grew and the DbGen file became larger we started experiencing the exception System.AccessViolationException more and more. It started showing up after trivial changes in our database and DbGen regeneration, for instance, once it appeared after changing an inner join by a left join, some times after adding a new simple table, etc. We have found a workaround: splitting our data access layer library, and so, producing smaller DbGen files. After we split the libraries and the dbgen files became smaller the issue went away. I have reported this to Microsoft but it is not clear if they will take any action. I wanted to keep you updated about this just in case somebody else experience this issue. Kind regards, Mauricio
Thank you for the info.
hello @cmeeren
Thanks. If you believe this is a compiler issue, you should raise an issue at https://github.com/dotnet/fsharp. But I'm not sure it can be considered a compiler issue. 70k lines is a lot.
Hello!
After adding support for diagrams in my DB, Facil included related types and SPs in the generated file. At a first glance this is not a problem by itself, but it produced an unexpected behavior, my code started raising a System.AccessViolationException.
The culprit for raising this exception are one or many of these: type
sysdiagrams
typesp_alterdiagram_Executable
typesp_alterdiagram
typesp_creatediagram_Executable
typesp_creatediagram
typesp_dropdiagram_Executable
typesp_dropdiagram
typesp_helpdiagramdefinition_Executable
typesp_helpdiagramdefinition
typesp_helpdiagrams_Executable
typesp_helpdiagrams
typesp_renamediagram_Executable
typesp_renamediagram
typesp_upgraddiagrams
As a workaround, we excluded these DB elements using "except" mechanism (facil.yaml) provided by Facil.
Kind regards, Mauricio