In other words, have you ever written a riff that you later found out already existed? I do it all the time and it pisses me off. Most of the time, they're riffs that I already know subconsciously but since I can't pinpoint where I heard them from, I think they're mine. There's noting worse than writing a good riff and then finding out months later that someone else already came up with it; the only reasonable thing to do from there is to just scrap it and move on. Other times, I'll come up with a riff that's similar in structure to another song. Recently I've been trying to dabble into writing metal songs (I'm more of a classic rock player) and I made a riff that was really heavy but I realized 5 minutes later that it was the same structure as the main riff from Megadeth's Holy Wars. I get so paranoid when I come up with a new material because if it sounds really good to me, then I automatically assume that I probably heard it somewhere and forgot about it. I don't want to start making songs with those riffs because if they are from another band, then I'd be labeled as a plagiarist. Any thoughts?
I've had this happen many times. The only options are: scrap it or try to alter it in some way. Usually after I alter it it actually sounds better to me than the original. I don't think you have to worry about plagiarism, there're tons of riffs that are similar in many famous songs. Off the top of my head, Keep Away (Godsmack) = Hey Man Nice Shot (Filter), Comedown (Bush, the bassline) = Shot Through The Heart (Bon Jovi).

There's nothing wrong with having a similar sounding riff to another song, just as long as it doesn't sound like you're rewriting the song.
I reckon this happens with about half the riffs I write - possibly more.

I've thought a few times about starting a "Have I Stolen This Riff?" thread on here for people to post their ideas and get comments on if it's too similar to something else.
Gibson LP Traditional, LP GT, LP Studio, SG Standard x2
Barber Tone Press > EHX Worm >TC Polytune > EXH Glove > EHX East River Drive > Zoom G3 > TC Spark Mini Booster
Jet City JCA22H
My SoundCloud
^ Thats a great idea because this happens to me all the time as well
'93 Gibson LP Studio (498T/490R)-Ebony
'14 Gibson LP Standard (JB/Jazz)-Ocean Water Perimeter
Epi MKH LP Custom-7 (SD Custom Shop JB-7)-Ebony

Maxon od808|Boss NS-2|Boss CE-5|
Line6 G55|Korg Pitchblack Pro

JVM 210h|1960a(V30/G12t-75)
Please use Musician Talk or other appropriate forums for this type of discussion. Songwriting & Lyrics is for written (poetry, lyrics, prose, stories, etc.) original work.