P-traps are used in drains, toilets and sinks. A P-Trap is a U-shaped plumping fixture that does not allow odorous sewer gasses enter the room via the drain. Decomposing solid waste creates this odor. Yes, the smell is not pleasant, but more importantly the smell contains harmful bacteria and possible methane. P-traps are effective only when sinks, drains or toilets are used. When used, water exits at a fairly rapid rate to the connected main drain. Some of the water remains in the lower portions of the U-shaped pipe. The remaining water blocks the odor and dangerous gasses
https://awphomeinspections.com/p-trap-important-plumbing-drainage/
The P-trap cannot be effective if the water evaporates or if the trap is faulty. First, the p-trap will not do its duty if the water evaporates due to heat or if not in regular use. To remedy this, add more water. Most importantly, P-traps will tend to wear out quicker than most plumbing fittings because water is intended to stay there. Replace the P-trap if it is cracked. You do not want to have waste water leaking. From my experience, Replacing just the p-trap will not be enough. I would have to change the tailpipe and other connected plumbing fixtures as they are weak. Tightening them together with the new p-trap would crack or improperly seal the old and new fixtures. From my accounts, it’s best to replace the other fixtures if more than 2-3 years old with proper pipe thread compound and poly washers.
Contact a licensed plumber or handyman if you need your p-trap inspected or replaced.