exacaster / lighter

REST API for Apache Spark on K8S or YARN
MIT License
91 stars 21 forks source link

statement can be created in "completed" session state #709

Closed jmilkiewicz closed 12 months ago

jmilkiewicz commented 1 year ago

I looked at the code of lighter and found one thing which can be very problematic. Lighter allows to create (post) statement ignoring status of a session. It seems to that if the corresponding session is in one of states:

statement will be never executed ? It means the statement will always stay in waiting state and will never progress. I am thinking what could help (but maybe not fully) is to simply check state of corresponding session before saving a statement.

If (!session.state.isComplete()){
  //save statement
} else{
... 
}

I can implement it but i am just wondering what shall be the HTTP status code and body when session.state.isComplete == true? Returning HTTP 400 ?

BTW there is another application state SHUTTING_DOWN but seems it is not used anywhere except for test so can be removed.

pdambrauskas commented 1 year ago

Good catch. Maybe it should be 409 Conflict, since 400 is more about request body validation?