Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Lucene.Net.QueryParsers.Classic.ParseException #16373

Closed
mohit-naroliya opened this issue Jun 26, 2024 · 6 comments
Closed

Lucene.Net.QueryParsers.Classic.ParseException #16373

mohit-naroliya opened this issue Jun 26, 2024 · 6 comments

Comments

@mohit-naroliya
Copy link
Contributor

mohit-naroliya commented Jun 26, 2024

Describe the bug

We encountered a strange issue on the production site that caused it to go down. After investigating, we found few exceptions in the log related to Lucene. Here are the logged exceptions:

OrchardCore.Search.Lucene.Services.LuceneSearchService|ERROR|Incorrect Lucene search query syntax provided in search. Lucene.Net.QueryParsers.Classic.ParseException: Cannot parse '"Find Your New Water Billing Account and Customer IDs': Lexical error at line 1, column 54.  Encountered: <EOF> after : "\"Find Your New Water Billing Account and Customer IDs"
---> Lucene.Net.QueryParsers.Classic.TokenMgrError: Lexical error at line 1, column 54.  Encountered: <EOF> after : "\"Find Your New Water Billing Account and Customer IDs"
   at Lucene.Net.QueryParsers.Classic.QueryParserTokenManager.GetNextToken()
   at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_ntk()
   at Lucene.Net.QueryParsers.Classic.QueryParser.Modifiers()
   at Lucene.Net.QueryParsers.Classic.QueryParser.Query(String field)
   at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
   --- End of inner exception stack trace ---
   at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
   at OrchardCore.Search.Lucene.Services.LuceneSearchService.SearchAsync(String indexName, String term, Int32 start, Int32 size)    at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
   at OrchardCore.Search.Lucene.Services.LuceneSearchService.SearchAsync(String indexName, String term, Int32 start, Int32 size)

Following the initial exception, we started receiving numerous connection failed exceptions, which ultimately caused the site to go down. Here is the log and the relevant exceptions:

Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer|ERROR|Connection ID "16933534604013338735", Request ID "4000007b-0001-eb00-b63f-84710c7967bb": An unhandled exception was thrown by the application. System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
   at Microsoft.Data.Common.ADP.ExceptionWithStackTrace(Exception e)
--- End of stack trace from previous location ---
   at OrchardCore.Queries.Sql.SqlQuerySource.ExecuteQueryAsync(Query query, IDictionary`2 parameters)
   at OrchardCore.Queries.Sql.SqlQuerySource.ExecuteQueryAsync(Query query, IDictionary`2 parameters)
   at OrchardCore.Queries.Liquid.QueryFilter.ProcessAsync(FluidValue input, FilterArguments arguments, LiquidTemplateContext ctx)
   at Fluid.Ast.FilterExpression.EvaluateAsync(TemplateContext context)
   at Fluid.Ast.AssignStatement.<WriteToAsync>g__Awaited|7_0(ValueTask`1 task, TemplateContext context, String identifier)
   at Fluid.Parser.FluidTemplate.Awaited(ValueTask`1 task, TextWriter writer, TextEncoder encoder, TemplateContext context, IReadOnlyList`1 statements, Int32 startIndex)
   at OrchardCore.DisplayManagement.Liquid.LiquidViewTemplateExtensions.RenderAsync(LiquidViewTemplate template, TextWriter writer, TextEncoder encoder, LiquidTemplateContext context, Object model)
   at OrchardCore.Liquid.Services.LiquidTemplateManager.RenderHtmlContentAsync(String source, TextEncoder encoder, Object model, IEnumerable`1 properties)
   at OrchardCore.Templates.Services.TemplatesShapeBindingResolver.<>c__DisplayClass8_0.<<BuildShapeBinding>b__0>d.MoveNext()

I went through the OC branch code base and found that there is a method opening a SQL Server connection without properly closing it. This could be the reason we are reaching the maximum connection pool size, leading to the site going down.

image

Above image method calling from the IndexingBackgroundTask that runs every minute.

Orchard Core version - 1.8.3

Copy link
Contributor

Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. A core team member will review your issue and get back to you.

If you like Orchard Core, please star our repo and join our community channels.

@sebastienros
Copy link
Member

How is the Lucene query issue related to the SQL connections pool limits? Can you share more of the stack-trace where the lucene issue is coming from? I want to understand what is sending user input as a lucene query. Because what is happening is that the code is expecting a lucene query, but the user doesn't provide that. There is a mismatch that needs to be resolved. If it's your code then don't expect a query from the user, build a query from the text that is provided. IF it's OC's code we need to fix it, but we need to know what is calling it.

The example you showed for the connection is actually closing it as it's using a using statement that will dispose and close the connection however it exits the method. It doesn't mean there is no such issue, but not in the code you pointed to.

Copy link
Contributor

It seems that this issue didn't really move for quite a while despite us asking the author for further feedback. Is this something you'd like to revisit any time soon or should we close? Please reply.

@github-actions github-actions bot added the stale label Jul 17, 2024
@sebastienros sebastienros added this to the backlog milestone Jul 18, 2024
Copy link
Contributor

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

@github-actions github-actions bot removed the stale label Jul 18, 2024
Copy link
Contributor

github-actions bot commented Aug 2, 2024

It seems that this issue didn't really move for quite a while despite us asking the author for further feedback. Is this something you'd like to revisit any time soon or should we close? Please reply.

@github-actions github-actions bot added the stale label Aug 2, 2024
Copy link
Contributor

github-actions bot commented Aug 9, 2024

Closing this issue because it didn't receive further feedback from the author for very long. If you think this is still relevant, feel free to reopen it with the requested details.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants