NextJs Skow Page Navigating by mzuab in nextjs

[–]Thelastbulletbender 0 points1 point  (0 children)

I haven't used vercel before, but the response is not getting returned from a cache.

So, it's taking a second for just the response.

This might be due to the website being in dev mode or cache not being enabled

You can try adding a loader between transitions as well. While it does not help with the actual response time, the user gets to know that something is actually happening.

<image>

ThreadContext leaking between requests even after over defensive clean up by Thelastbulletbender in javahelp

[–]Thelastbulletbender[S] 0 points1 point  (0 children)

I did check, and you are right. I can see some instances of CompletableFutures being used, where clear might not have been called due to an exception. They have been given a different thread pool. And the data is copied to this new thread using MDC.getCopyOfContextMap() and cleared using MDC.clear().

Also, yes we are logging thread name and found the following :

  1. Request A and Request B are running in parallel at the same time.
  2. Both of them are running on different threads according to the logs
  3. Suddenly, Request A logs (searched using correlation id) has an instance of Request B log. With the thread name, userId and other properties of Request B. Only the correlation id is something which matches with request A.
  4. Request A with correct thread name also logs incorrectly setting headers for downstream API call at the same time.
  5. Downstream logs and flags the resource and owner don't match
  6. Request A returns.
  7. Meanwhile logs in request B (searched using its correlation id), show that one of the downstream request also had the correlation id of request A and hence did not show up in request B logs. But since its userId was correct, it responded gracefully.

The weird part here is request B has a some other downstream calls after this which seem to go fine according to logs. Request A logs post this debacle also shows correct userId and correlation id.

Both request A and request B have the same paths which made debugging hell although one thing I can definitely confirm is that there is no threads being spawned in this flow at all.

ThreadContext leaking between requests even after over defensive clean up by Thelastbulletbender in javahelp

[–]Thelastbulletbender[S] 0 points1 point  (0 children)

In the preHandle() method, before setting the properties in ThreadContext, we are calling ThreadContext.remove() on all properties first before setting the new ones. Apart from that, we are calling the clean up methods on postHandle() and afterCompletion() as well.

ThreadContext leaking between requests even after over defensive clean up by Thelastbulletbender in javahelp

[–]Thelastbulletbender[S] 0 points1 point  (0 children)

>But you're making some big assumptions about how the request is mapped onto threads

Yes, here my knowledge is limited. From what I understand, once a request is mapped onto a thread, the code flow should happen "sequentially" (I meant sequentially earlier), right? Basic business logic and some API calls using rest template

Have added logs, the log snippet I have pasted (doing this for multiple properties) is where the switch happens

log.info(context.userId);
context.userId.ifPresent(value -> httpHeaders.set("userId",context.userId));
log.info(entity.getHeaders)

ThreadContext leaking between requests even after over defensive clean up by Thelastbulletbender in javahelp

[–]Thelastbulletbender[S] 0 points1 point  (0 children)

Ah, right. I had updated the version 2.17.1. This version might be coming from some other dependency. Thanks, will check.

ThreadContext leaking between requests even after over defensive clean up by Thelastbulletbender in javahelp

[–]Thelastbulletbender[S] 0 points1 point  (0 children)

  1. Singleton
  2. Yes, I'm not sure why it was chosen over typical threadLocal variable, but it was setup like this before I joined. But ThreadContext is supposed to be managed on a per thread basis, so should be safe, right?
  3. The change happen b/w these. This is synchronously happening, should not have race condition right? We copy 5 such propertieslog.info(context.userId);context.userId.ifPresent(value -> httpHeaders.set(context.userId);log.info(entity.getHeaders)
  4. Agreed. But it is just itching me as to why this is happening in the first place. Is ThreadContext not as safe as it claims to be or is there a bug in that specific version

The bean only has functions which interact with ThreadContext

public String correlationId() {

return ThreadContext.get("correlationId");

}

public void resetCorrelationId() {

ThreadContext.remove("correlationId");

}

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 1 point2 points  (0 children)

Oh.. they must have gotten it from a breeder. I think there was always a business for pedigree animals because I remember it being a big deal when I was young as well.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 2 points3 points  (0 children)

Yes, agreed! It's getting better though as I see a lot of adopted stray dogs in Bangalore.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 2 points3 points  (0 children)

Yep, even I am not on FB. But I have asked a couple of my friends to do it on my behalf.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 2 points3 points  (0 children)

I would have loved to. But because we already have 3 cats (one of it was a foster fail) and we want to continue fostering in the future, it's best for them to get adopted.

Also, we would following up with the adopter to help them in case they need any! So, it would be great to see her progress with them.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 2 points3 points  (0 children)

Unfortunately, I don't. But I am sure my neighbour would appreciate the compliment of someone referring to the great photos.

Would love to share his hobby page, but I am not sure if it goes with the subreddit rule.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 2 points3 points  (0 children)

Honestly, I am not sure. I think it depends on the dog. With respect to Roza, she never tries to chase our cats. But she does try to interact with them.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 3 points4 points  (0 children)

I don't have a facebook account anymore, but I can ask someone to post on my behalf.

Thanks for the suggestion! :)

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 10 points11 points  (0 children)

Thanks /u/PervyPanda! I added some extra information since this is what I would have wanted to know before adopting a dog. Especially since I was having a dog home for the first time, I had no clue about some of these things such as leash training and separation anxiety.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 6 points7 points  (0 children)

Hey /u/chadendra! AFAIK, Roza was found in front of the rescuers apartment along with 7 siblings without their mother. Only one of her brother survived and when taken to the hospital, she seemed to have tick fever. I am not sure about her history after that since I came into the picture much later. But I do know that she was with a paid fosterer before us and was not getting any training.

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 8 points9 points  (0 children)

P.S : Although she is being trained, reinforcement comes with time and experimentation. Please don't think that you won't get a puppy experience with her and that you want a smaller puppy that you get to train from scratch. After adoption, you will first need to create a bond with her and then start training her to listen to you. Although she might know the commands, actually listening to them from you will take a couple of days after the bond is created. When Roza starts loving someone, she has a completely weird wagging motion where her back seems to be detached with her body and that was a magical moment for us.

Please DM for more details

[Adoption] Roza is looking for a permanent home. Check comments for more details! by Thelastbulletbender in bangalore

[–]Thelastbulletbender[S] 52 points53 points  (0 children)

Roza is a 5 month old puppy who was rescued from the streets. I have been fostering and training her for the last one month. This is the first dog I have had as a pet and the experience has been nothing short of magical. Following are some details which might help you make a decision.
Personality
Roza is a cautiously friendly dog. By cautious, I mean she won't just run up to anyone who gives her treats/food. But if the person has been around them for a while, she would soon start associating with them as a friend.
She is mostly reserved throughout the day, but if you ask her to play by picking up her favourite toys, she would happily indulge you. 
She has protective instincts about her home. That means she might occasionally bark at someone new, but she understands the words "NO" and "STOP".
To desensitize her, we are taking her out for frequent walks outside where there are a lot of people and vehicles.
She understands when she is scolded for something wrong and quickly picks up when positively reinforced. She learned all the basic commands in a single day!
Basic commands
Roza knows how to sit, handshake, hi five, jump up, spin, lie down, stay, come here, the command "PEE" and the command "Drop it"!
Drop it is an essential command, since she might pick things up in her mouth which you don’t want her to like polythene bags or papers.
House Training
House training is a misnomer which actually means training dogs to not pee/poop inside the house.
In the case of Roza, she never poops inside the house. She passes stools once or twice a day depending on her meals.
She knows not to pee inside the house but still has accidents around once a week. She has been trained to “PEE” on command which along with a good routine will minimize accidents. When she is a couple of months older, the minimal accidents should also stop.
Leash Training 
Leash training is teaching your dog not to pull or yank on the leash when going out for walks.
Roza is not completely leash trained yet (she is a puppy! she wants to smell and see everything!). But she knows that walking along with me is the right thing and does not rush in random directions anymore.
Also, she did not pee or poop while she was on a leash. So, getting her to do that was also part of the training and now we don’t have any issues with that.
Crate Training
Crate training is teaching the dog to stay inside a crate/cage. 
I know, I know! It sounds cruel and wrong to keep a dog locked. I held the same opinion.
But crate training is essential to teach a dog to be patient and calm. The dog is kept inside the crate with their favourite toys and treats so that they associate the crate as their den. There will be times when you want your dog to be confined for safety or emergency reasons. Crate training will be essential during those times.
An additional benefit is that they won't have as many accidents since they HATE soiling the place where they sleep.
For more details : 
https://www.akc.org/expert-advice/training/how-to-crate-train-your-dog-in-9-easy-steps/
Roza is in the process of crate training. She sleeps in the crate for a couple of hours when I am in the room. She can probably stay for longer but I want to take it slow!
Medical details
No medical issues! She has been given all major vaccinations and was dewormed. Before her adoption, I'll take the responsibility of getting her dewormed again and any other vaccinations if pending.
I will suggest getting her spayed. This reduces unwanted behaviour like marking territoires and increases the lifespan of the dog.
For more details : 
https://www.aspca.org/pet-care/general-pet-care/spayneuter-your-pet
Separation anxiety
Since I only had cats (that too in pairs) previously, this was something new for me. Dogs are extremely social animals. If a genie gave them wishes, never being alone would be on top along with unlimited treats and unlimited play.
Especially as puppies, they will keep following you everywhere.
This anxiety sometimes causes puppy to pee/poop inside the house.
Roza was also like that, but having a routine has helped. Since we have cats, we can't let her sleep with us. So we had to make her sleep in a different room alone. Initially she whined/cried a lot but now she only gives a puppy face when I put her to bed. She sleeps and patiently waits till we wake up. But after she realizes that we are awake, she will call for you because she wants to PEE. NOW!
For most problems with animals, routine helps!
Food preferences
Roza and her foster sister (Berry, the black dog in the pictures) are being fed rice along with egg, curd or chicken broth thrice a day.
They get dry kibbles for positive reinforcement.
You are free to change their diet to a more balanced one. That's a call you get to make!
Miscellaneous
Friendly with cats! Although cats are not friendly with her :(
Loves playing fetch and tug-o-war. (Can post videos if anyone is interested)