Your little code snippet shows that you're declaring id inside the route
handler to correctly scope it by request, and your async.serial() call is
correct as far as is shown...  For the closure around id to work as you
desire, you also need to define f1 and f2 inside the request handler. Your
snippet doesn't show that much, so it's possible you are already doing
that. But if you aren't doing that, and have defined those functions
somewhere else, then they will be accessing a global variable shared by all
requests instead.

Could you share a little more of your code?

~Ryan

On Sat, Oct 8, 2016, 10:56 PM Eric Pan <[email protected]> wrote:

> Here is my problems and I am wondering how it could happen.
>
> Route.get("/", function(req,res) {
> var id;
>
> async.serial([f1,f2],....
>
> f1, f2 does database insert
> In f1, set the id returned by the sql
> In f2, insert record with the id which is set from f1
> The app works good but the problem happens when getting heavy traffic
> The id in f2 is wrong, seems like from another user's request
> That means the id in f1 and f2 doesn't match.
> Can somebody explain to me why?
> Many thanks
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/1e7c4e19-5aca-4b0f-9a83-9439a9171170%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

~Ryan

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAGjmZGwiNs-vYebWbqg4SxPspGSP8%2BNmwwzVUbgJif-jew2rpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to